📄 ejb设计模式1.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0057)http://eps.www85.cn4e.com/java/article/devshow.asp?id=123 -->
<HTML><HEAD><title>csdn_EJB设计模式1</TITLE>
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<STYLE type=text/css>TD {
FONT-FAMILY: "Verdana", "Arial", "宋体"; FONT-SIZE: 9pt
}
A {
COLOR: #660000; TEXT-DECORATION: underline
}
A:hover {
COLOR: #660000; TEXT-DECORATION: none
}
.line {
LINE-HEIGHT: 14pt
}
</STYLE>
<META content="MSHTML 5.00.2920.0" name=GENERATOR></HEAD>
<BODY bgColor=#ffffff text=#000000>
<table><tbody>
<TR>
<TD height=21>
<DIV align=center><B><FONT size=3>EJB设计模式1 <BR><FONT
size=2> </FONT></FONT></FONT>
<HR align=center color=#cccccc noShade SIZE=1>
</DIV></TD></TR>
<TR>
<TD class=line><FONT
color=#333300><BR><BR>设计模式 1<BR>第一个设计模式非常简单。一个公司和雇员的Entity Bean和<BR>下面给出的Entity Bean的代码片断是类似的。它们是由jbuilder4的<BR>EntityBean模版生成的。所有的字段都声明为public的cmp字段。<BR><BR><BR>Code snippet for Company Entity Bean<BR>public class CompanyBean implements EntityBean {<BR>EntityContext entityContext;<BR>public Integer comId; //the primary key<BR>public String comName; //the company name<BR>public String comDescription //basic description<BR>public Timestamp mutationDate //explained later<BR>public Integer ejbCreate(<params>) throws<BR>CreateException {<BR>return null;<BR>}<BR>//various get() and set() for every column/field<BR>// which are exposed in the Remote Interface as well<BR><BR>Code snippet for Employee Entity Bean<BR>public class EmployeeBean implements EntityBean {<BR>EntityContext entityContext;<BR>public Integer empId; //the primary key<BR>public Integer comId; //the company foreign key<BR>public String empFirstName; //the employee firstname<BR>public String empLastName // the employee lastname<BR>public Timestamp mutationDate //explained later<BR>public Integer ejbCreate(<params>) throws<BR>CreateException {<BR>return null;<BR>}<BR>//various get() and set() for every column/field<BR>// which are exposed in the Remote Interface as well<BR><BR><BR>这个设计模式虽然很简单,但是却有很多缺点,比如,对每一个<BR>字段的访问都会导致对get()和set()方法的一次远程调用。而远<BR>程过程调用(RPCs)是非常耗费资源的,并且,对于在实际中通<BR>常要求的组合的访问会导致一系列的远程调用。可以说,这个模<BR>式在实际中可用性很差。上面展示的设计模式可以作为其他设计<BR>模式的基础,比如RAD,原型设计,测试等。这时,那个代表雇<BR>员的Employee Entity Bean并没有展示出在雇员和公司之间有何<BR>关系。<BR></FONT></TD></TR>
<TR>
<TD height=5>
<HR align=center color=#cccccc noShade SIZE=1>
</TD></TR></TBODY></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -