帝国软件
  设为首页 加入收藏 关于我们
 
解密帝国网站管理系统v4.6
栏 目:
 
您的位置:首页 > 技术文档 > JAVA编程 >
EJB设计模式
作者:未知 发布时间:2005-03-12 来源:JSP天空网
第一个设计模式非常简单。一个公司和雇员的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并没有展示出在雇员和公司之间有何
关系。
  
评论】【加入收藏夹】【 】【打印】【关闭
※ 相关链接
 ·EJB设计模式3  (2005-03-12)
 ·EJB设计模式4  (2005-03-12)
 ·EJB设计模式5  (2005-03-12)
 ·ejb入门  (2005-03-12)
 ·EJB设计模式1  (2005-03-12)
 ·EJB设计模式2  (2005-03-12)

   栏目导行
  PHP编程
  ASP编程
  ASP.NET编程
  JAVA编程
   站点最新
·致合作伙伴的欢迎信
·媒体报道
·帝国软件合作伙伴计划协议
·帝国网站管理系统采集使用教程
·帝国网站管理系统模板制作教程
·帝国CMS模板下载
·Discuz6.0.1UC版通行证发布
·帝国网站管理系统之网站迁移教程
·帝国网站管理系统实例入门教程下载
·《帝国网站管理系统》实例入门教程
   类别最新
·谈谈JDBC
·JDBC专题介绍
·JDBC接口技术
·利用weblogic的POOL(连接池)连接
·Jsp中调用Oracle存储过程的小例子
·JSP数据库操作例程
·JSP数据库连接大全
·用连接池提高Servlet访问数据库的效
·一种简单JDBC连接池的实现
·数据库连接池Java实现小结
 
关于帝国 | 广告服务 | 联系我们 | 程序开发 | 网站地图 | 留言板 帝国网站管理系统