JAVA学习网首页 把生活查询网加入收藏 把JAVA学习网设为首页 联系方式
    Hi,JAVA学习
JAVA基础 设计模式 数据库 JavaBeans J2EE JavaDelphi 用户界面 综合文章  
EJB设计模式1
时间:22/04/2007
作者:网络
来源:网络
小提示点这里把文章加入您的收藏夹,方便下次查看
设置文章字体大小:[ ]

 

设计模式 1
第一个设计模式非常简单。一个公司和雇员的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(<params>) 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(<params>) 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并没有展示出在雇员和公司之间有何
关系。
上一篇:javabean10118

下一篇:EJB设计模式1

  • /* 冒泡排序算法 */
  • J2ME在移动设备上的应用(电子书)
  • 利用高级Java、算法、三角学、分布计算设计自己的智能机器人
  • EnterpriseJavaBeansDistilled(3)
  • 设计模式在EJB中的应用(转帖)
  • Junit FAQ(001-016)
  • 设计模式袖珍版 连续转载之 - Bridge
  • JAVA如何调用C/C++方法
  • 伟大的Hessian
  • Develop with DUIL
  • JSP/Servlet的重定向技术综述
  • Java 命名约定有哪些?
  • 第一次java实验:"*号画圆"
  • J2EE系统优化的几点体会(一、对象)
  • 基于目录结构认证的问题
  • JSF - Request Processing Lifecycle
  • EnterpriseJavaBean 入门
  • 正则表达式和Java编程语言
  • 返回】 【顶部】 【关闭
    Copyright © 2005-2010 www.594k.com All Rights Reserved.
    版权所有:JAVA学习网 备案序号:皖ICP备06004238号