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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 設計模式1設計模式
- 1/24 設計模式之策略設計模式 Strategy Pattern設計模式
- 前端設計模式(1)--工廠模式前端設計模式
- Head First 設計模式(1)-----策略模式設計模式
- 設計模式(06)——設計原則(1)設計模式
- javascript設計模式1–前言JavaScript設計模式
- 淺讀設計模式 - 1設計模式
- 設計模式 1 (Python版)設計模式Python
- 設計模式 #1(7大設計原則)設計模式
- ejb
- 《設計模式》 - 1. 單例模式( Singleton )設計模式單例
- 設計模式解析-1:觀察者模式設計模式
- JAVA設計模式 1 設計模式介紹、單例模式的理解與使用Java設計模式單例
- java 新世界設計模式(1)Java設計模式
- 轉載-Java設計模式之DecoratorJava設計模式
- 玩轉 iOS 開發:《iOS 設計模式 — 代理模式》iOS設計模式
- 淺談java之設計模式(1)Java設計模式
- 玩轉 iOS 開發:《iOS 設計模式 — 工廠模式》iOS設計模式
- 1.設計模式之初體驗—精讀《JavaScript 設計模式》Addy Osmani著設計模式JavaScript
- 設計模式之感悟和實踐1設計模式
- 設計模式(Swift) - 1.MVC和代理設計模式SwiftMVC
- 1.設計模式與物件導向設計模式物件
- 設計模式總結(實踐篇1)設計模式
- 設計模式(Swift) – 1.MVC和代理設計模式SwiftMVC
- Unity應用架構設計(1)—— MVVM 模式的設計和實施(Part 1)Unity應用架構MVVM模式
- 《JavaScript設計模式與開發實踐》模式篇(1)—— 單例模式JavaScript設計模式單例
- 設計模式(四)Singleton設計模式設計模式
- 設計模式----工廠設計模式設計模式
- Java設計模式——模板設計模式Java設計模式
- 設計模式-工廠設計模式設計模式
- ① EJB無狀態的bean(建立EJB的基礎教程)Bean
- Javascript設計模式學習1(熱身篇)JavaScript設計模式
- 前端常用設計模式(1)--裝飾器(decorator)前端設計模式
- 設計模式之單例設計模式設計模式單例
- EJB簡單理解
- 【設計模式】設計模式(一)-- 大話設計模式讀書筆記設計模式筆記
- C# 設計模式(1)——簡單工廠模式、工廠模式、抽象工廠模式C#設計模式抽象
- 初探Java設計模式1:建立型模式(工廠,單例等)Java設計模式單例
- [翻譯]微服務設計模式 - 1. 單體應用模式微服務設計模式