网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网络编程 > Java
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,Apache,Tomcat,phpmyadmin,Gzip,触发器,socket
网络编程:ASP教程,ASP.NET教程,PHP教程,JSP教程,C#教程,数据库,XML教程,Ajax,Java,Perl,Shell,VB教程,Delphi,C/C++教程,软件工程,J2EE/J2ME,移动开发
本月文章推荐
.Struts 中bean:present使用方法.
.调整JavaTMI/O性能.
.Java Web Start 1.0.1_01的安装向.
.一个最简单的servlet.
.CopyFile 方法.
.用javaapi进行sort.
.我为什么没有使用Spring.
.一个Java先行者的追寻之路.
.Java SE 6 入门之脚本引擎加大程.
.手机操作系统及移动开发.
.集成EJB和CORBA/CORBA客户端访问.
.Java Mail API及其应用 —— 一个.
.JDBC里取得Oracle存储过程动态结.
.JBuilder2005+JBOSS+Oracle9i环境.
.Java开发应用软件JCreator的使用.
.在Java中发送邮件的一个相当完善.
.在Java中应用State设计模式.
.EJB设计模式(3).
.Nokia发布SNAP,辅助J2ME网络游戏.
.初步了解 Corba 的模块模型概况.

EJB设计模式1

发表日期:2008-1-5



  第一个设计模式非常简单。一个公司和雇员的Entity Bean和下面给出的Entity Bean的代码片断是类似的。它们是由jbuilder4的EntityBean模版生成的。所有的字段都声明为public的cmp字段。
  Code snippet for Company Entity Bean
  public class CompanyBean implements EntityBean {
  EntityContext entityContext;
  public Integer comId; //the primary key
  public String comName; //the company name
  public String comDescription //basic description
  public Timestamp mutationDate //eXPlained later
  public Integer ejbCreate() throws
  CreateException {
  return null;
  }
  //various get() and set() for every column/field
  // which are exposed in the Remote Interface as well
  Code snippet for Employee Entity Bean
  public class EmployeeBean implements EntityBean {
  
  EntityContext entityContext;
  public Integer empId; //the primary key
  public Integer comId; //the company foreign key
  public String empFirstName; //the employee firstname
  public String empLastName // the employee lastname
  public Timestamp mutationDate //explained later
  public Integer ejbCreate() throws
  CreateException {
  return null;
  }
  
  //various get() and set() for every column/field
  // which are exposed in the Remote Interface as well
  这个设计模式虽然很简单,但是却有很多缺点,比如,对每一个字段的访问都会导致对get()和set()方法的一次远程调用。而远程过程调用(RPCs)是非常耗费资源的,并且,对于在实际中通常要求的组合的访问会导致一系列的远程调用。可以说,这个模式在实际中可用性很差。上面展示的设计模式可以作为其他设计模式的基础,比如RAD,原型设计,测试等。这时,那个代表雇员的Employee Entity Bean并没有展示出在雇员和公司之间有何关系。
上一篇:EJB入门文章 人气:743
下一篇:使用EJB组件你需要了解些什么呢? 人气:884
浏览全部Java的内容 Dreamweaver插件下载 网页广告代码 祝你圣诞节快乐 2009年新年快乐