📄 lib0034.html
字号:
<html>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<head>
<title>Deployment Layer</title>
<link rel="STYLESHEET" type="text/css" href="images/xpolecat.css">
<link rel="STYLESHEET" type="text/css" href="images/ie.content.css">
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td><div STYLE="MARGIN-LEFT: 0.15in;"><a href="toc.html"><img src="images/teamlib.gif" width="62" height="15" border="0" align="absmiddle" alt="Team LiB"></a></div></td>
<td align="right"><div STYLE="MARGIN-LEFT: 0.15in;">
<a href="LiB0033.html"><img src="images/previous.gif" width="62" height="15" border="0" align="absmiddle" alt="Previous Section"></a>
<a href="LiB0035.html"><img src="images/next.gif" width="41" height="15" border="0" align="absmiddle" alt="Next Section"></a>
</div></td></tr></table>
<br>
<div class="chapter">
<a name="ch05"></a>
<div class="section">
<h2 class="first-section-title"><a name="161"></a><a name="ch05lev1sec5"></a>Deployment Layer</h2><a name="162"></a><a name="IDX-62"></a><a name="163"></a><a name="IDX-63"></a>
<p class="para">Objects in the deployment layer—called deployment wrappers—are the heart of J2EE architecture. Deployment wrappers publish business object functionality to Java classes that could be on separate machines (including anything in the presentation tier). Examples of deployment wrappers include enterprise beans (e.g., session beans, message-driven beans), RMI services, and Web services. CORBA services are also deployment wrappers but are not considered a traditional part of J2EE architecture.</p>
<p class="para">I consider entity beans to be DAOs, not deployment wrappers. Although technically you can call entity beans from remote clients, doing so slows performance and is therefore not recommended. Calls to entity beans are usually consolidated in session beans. This practice is known as a session bean fa鏰de.</p>
<p class="para">
<b>Use enterprise beans to publish business logic.</b> Some developers consider enterprise beans to represent business logic. Although it is technically possible to consolidate what I call business objects and enterprise beans into the same class, I don't recommend it. Keeping the business logic separate gives you complete deployment flexibility. You can deploy the same business object as an enterprise bean, message-driven bean, a CORBA service, a Web service, or even a client application with no changes to the underlying business object. Separating the business logic into deployment-independent classes does create additional classes, but the classes are less complex.</p>
<p class="para">
<b>Document a deployment wrapper as one class in your object model, even though it's composed of several classes.</b> Take a stateless session bean example. A session bean has a client proxy, an interface, a bean, and a home object implementation. With the exception of the home implementation, all these classes will contain the same method signatures. There's no value in tediously documenting every piece of the deployment layer.</p>
<div class="section">
<h3 class="sect3-title">
<a name="164"></a><a name="ch05lev2sec6"></a>Choosing Deployment Wrappers</h3>
<p class="first-para">You can have multiple deployment wrappers for the same business object. For example, it is not uncommon to create a message-driven bean and a Web service deployment for a customer object.</p>
<p class="para">Each type of deployment wrapper has its advantages and disadvantages. Choosing which type of deployment wrapper to use is difficult if you haven't substantially completed use-case analysis and prototyping (<a href="LiB0018.html#84" target="_parent" class="chapterjump">chapter 3</a>) or defining application interfaces (<a href="LiB0023.html#97" target="_parent" class="chapterjump">chapter 4</a>). <a class="internaljump" href="#ch05table03">Table 5.3</a> summarizes the differences between the types of deployment wrappers.</p>
<a name="165"></a><a name="ch05table03"></a>
<table class="table" border="1">
<caption class="table-title">
<span class="table-title"><span class="table-titlelabel">Table 5.3: </span>Features of Deployment Wrapper Types</span>
</caption>
<thead>
<tr valign="top">
<th class="th" scope="col" align="left">
<p class="table-para">
<b class="bold">Feature</b>
</p>
</th><th class="th" scope="col" align="left">
<p class="table-para">
<b class="bold">EJB</b>
</p>
</th><th class="th" scope="col" align="left">
<p class="table-para">
<b class="bold">Web Services</b>
</p>
</th><th class="th" scope="col" align="left">
<p class="table-para">
<b class="bold">Messaging/JMS</b>
</p>
</th><th class="th" scope="col" align="left">
<p class="table-para">
<b class="bold">RMI</b>
</p>
</th><th class="th" scope="col" align="left">
<p class="table-para">
<b class="bold">HTTP</b>
</p>
</th><th class="th" scope="col" align="left">
<p class="table-para">
<b class="bold">CORBA</b>
</p>
</th>
</tr>
</thead>
<tbody>
<tr valign="top">
<td class="td" align="left">
<p class="table-para">
<b class="bold">Caller platform requirements</b>
</p>
</td><td class="td" align="left">
<p class="table-para">Java-compliant only</p>
</td><td class="td" align="left">
<p class="table-para">Any</p>
</td><td class="td" align="left">
<p class="table-para">Any</p>
</td><td class="td" align="left">
<p class="table-para">Java-compliantonly</p>
</td><td class="td" align="left">
<p class="table-para">Any</p>
</td><td class="td" align="left">
<p class="table-para">Any</p>
</td>
</tr>
<tr valign="top">
<td class="td" align="left">
<p class="table-para">
<b class="bold">Communication method supported</b>
</p>
</td><td class="td" align="left">
<p class="table-para">Synch. only</p>
</td><td class="td" align="left">
<p class="table-para">Both</p>
</td><td class="td" align="left">
<p class="table-para">Both</p>
</td><td class="td" align="left">
<p class="table-para">Synch. only</p>
</td><td class="td" align="left">
<p class="table-para">Synch. only</p>
</td><td class="td" align="left">
<p class="table-para">Synch. only</p>
</td>
</tr>
<tr valign="top">
<td class="td" align="left">
<p class="table-para">
<b class="bold">Coupling</b>
</p>
</td><td class="td" align="left">
<p class="table-para">Tight</p>
</td><td class="td" align="left">
<p class="table-para">Loose</p>
</td><td class="td" align="left">
<p class="table-para">Loose</p>
</td><td class="td" align="left">
<p class="table-para">Tight</p>
</td><td class="td" align="left">
<p class="table-para">Loose</p>
</td><td class="td" align="left">
<p class="table-para">Loose</p>
</td>
</tr>
<tr valign="top">
<td class="td" align="left">
<p class="table-para">
<b class="bold">Transaction support</b>
</p>
</td><td class="td" align="left">
<p class="table-para">Local and JTA</p>
</td><td class="td" align="left">
<p class="table-para">Local and JTA</p>
</td><td class="td" align="left">
<p class="table-para">Local</p>
</td><td class="td" align="left">
<p class="table-para">Local</p>
</td><td class="td" align="left">
<p class="table-para">Local</p>
</td><td class="td" align="left">
<p class="table-para">Local</p>
</td>
</tr>
<tr valign="top">
<td class="td" align="left">
<p class="table-para">
<b class="bold">Requires J2EE container?</b>
</p>
</td><td class="td" align="left">
<p class="table-para">Yes</p>
</td><td class="td" align="left">
<p class="table-para">No</p>
</td><td class="td" align="left">
<p class="table-para">No</p>
</td><td class="td" align="left">
<p class="table-para">No</p>
</td><td class="td" align="left">
<p class="table-para">No</p>
</td><td class="td" align="left">
<p class="table-para">No</p>
</td>
</tr>
<tr valign="top">
<td class="td" align="left">
<p class="table-para">
<b class="bold">Supports clustering for scalability and availability?</b>
</p>
</td><td class="td" align="left">
<p class="table-para">Yes</p>
</td><td class="td" align="left">
<p class="table-para">Yes</p>
</td><td class="td" align="left">
<p class="table-para">Yes</p>
</td><td class="td" align="left">
<p class="table-para">No</p>
</td><td class="td" align="left">
<p class="table-para">Yes</p>
</td><td class="td" align="left">
<p class="table-para">Yes</p>
</td>
</tr>
</tbody>
</table>
<a name="166"></a><a name="IDX-64"></a>
<p class="para">Faced with deciding which deployment wrappers to use and which business objects to publish, ask yourself the following questions; your answers will help you navigate through the decision-making process.</p>
<div class="qandaset">
<table border="0" cellpadding="0">
<tr class="qandaentry">
<td class="td" valign="top" width="2%">
<p class="first-para">
<a name="N275"><b>Q:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -