EJB設計模式1 (轉)
EJB設計模式1 (轉)[@more@]
第一個設計模式非常簡單。一個公司和僱員的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 Create() 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並沒有展示出在僱員和公司之間有何
關係。
設計 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 Create(
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(
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並沒有展示出在僱員和公司之間有何
關係。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10752043/viewspace-990172/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- EJB設計模式5 (轉)設計模式
- EJB設計模式2 (轉)設計模式
- EJB設計模式3 (轉)設計模式
- EJB設計模式4 (轉)設計模式
- EJB設計模式之Data Transfer Object (轉)設計模式Object
- EJB設計模式(第二版)之EJB Command (轉)設計模式
- EJB 程式設計模型 (轉)程式設計模型
- 尋書---<<ejb設計模式>>設計模式
- 設計模式1設計模式
- Java設計模式1:設計模式概論Java設計模式
- 設計模式1——單例模式設計模式單例
- 設計模式知識梳理(1) 設計模式概述設計模式
- 設計模式-策略模式(轉)設計模式
- 玩轉設計模式——設計模式之禪設計模式
- 設計模式入門(1)------單件(Singleton) (轉)設計模式
- 1/24 設計模式之策略設計模式 Strategy Pattern設計模式
- 前端設計模式(1)--工廠模式前端設計模式
- 設計模式解析-1:觀察者模式設計模式
- 設計模式應用之Observer模式(1)設計模式Server
- 設計模式(06)——設計原則(1)設計模式
- 設計模式—單例模式(轉)設計模式單例
- javascript設計模式1–前言JavaScript設計模式
- 淺讀設計模式 - 1設計模式
- 用Java實現的設計模式系列(1)-Factory (轉)Java設計模式
- 設計模式 #1(7大設計原則)設計模式
- Head First 設計模式(1)-----策略模式設計模式
- 設計模式——1工廠方法模式(FactoryMethod)設計模式
- C#設計模式(1)=>單例模式C#設計模式單例
- C#設計模式(1)——單例模式C#設計模式單例
- 1.1 《硬啃設計模式》 第1章 大話設計模式設計模式
- java 新世界設計模式(1)Java設計模式
- java設計模式1-10Java設計模式
- JAVA設計模式 1 設計模式介紹、單例模式的理解與使用Java設計模式單例
- jsp設計模式(轉)JS設計模式
- 《設計模式》 - 1. 單例模式( Singleton )設計模式單例
- 淺談java之設計模式(1)Java設計模式
- iOS 設計模式淺析 1 - 策略iOS設計模式
- 怎麼使用EJB來達到singleton模式 (轉)模式