会员: 密码:  免费注册 | 忘记密码 | 会员登录 网页功能: 加入收藏 设为首页 网站搜索  
 安全技术技术文档
  · 安全配制
  · 工具介绍
  · 黑客教学
  · 防火墙
  · 漏洞分析
  · 破解专题
  · 黑客编程
  · 入侵检测
 安全技术论坛
  · 安全配制
  · 工具介绍
  · 防火墙
  · 黑客入侵
  · 漏洞检测
  · 破解方法
  · 杀毒专区
 安全技术工具下载
  · 扫描工具
  · 攻击程序
  · 后门木马
  · 拒绝服务
  · 口令破解
  · 代理程序
  · 防火墙
  · 加密解密
  · 入侵检测
  · 攻防演示
技术文档 > JAVA
EJB设计模式1
发表日期:2004-07-30 17:04:48作者: 出处:  


 

设计模式 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并没有展示出在雇员和公司之间有何
关系。
 

返回顶部】 【打印本页】 【关闭窗口

关于我们 / 给我留言 / 版权举报 / 意见建议 / 网站编程QQ群   
Copyright ©2003- 2024 Lihuasoft.net webmaster(at)lihuasoft.net 加载时间 0.00186