📄 lib0089.html
字号:
<html>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<head>
<title>Chapter 13: Building Business Objects</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="LiB0088.html"><img src="images/previous.gif" width="62" height="15" border="0" align="absmiddle" alt="Previous Section"></a>
<a href="LiB0090.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="ch13"></a>
<h1 class="chapter-title"><span class="chapter-titlelabel">Chapter 13: </span>Building Business Objects</h1><div class="section">
<h2 class="sect2-title">
<a name="430"></a>Overview</h2>
<a name="431"></a><a name="IDX-175"></a>
<p class="para">The business logic layer for J2EE applications combines data with business rules, constraints, and activities. I usually separate them from DAOs, VOs, and deployment wrappers, such as enterprise beans or Web services, to maximize the possibility of reuse. It's common for business objects (BOs) to use and coordinate the activities of multiple data access objects. <a class="internaljump" href="#ch13fig01">Figure 13.1</a> illustrates how business objects function in a layered architecture.</p>
<div class="figure">
<a name="432"></a><a name="ch13fig01"></a><span class="figuremediaobject"><a href="images/fig192%5F01%5F0%2Ejpg" NAME="IMG_36" target="_parent"><img src="images/fig192_01.jpg" height="250" width="350" alt="Click To expand" border="0"></a></span>
<br style="line-height: 1">
<span class="figure-title"><span class="figure-titlelabel">Figure 13.1: </span>Using Business Objects Within a Layered Architecture</span>
</div>
<div class="highlights">
<p class="first-para">Business objects are instantiated and invoked by other business objects or classes in the deployment layer, such as enterprise beans or Web services. They often instantiate and use classes in the data access layer, such as those discussed in the previous two chapters. This chapter provides coding guidelines used for business objects and presents examples taken from ProjectTrak.</p>
<p class="para">As an illustration, consider a business object in a purchasing application. Class <span class="fixed">PurchaseOrder</span> is in the business logic layer and is used by the deployment layer to provide the ability to view and submit purchase orders. <span class="fixed">PurchaseOrder</span> has the following methods:</p>
<p class="para">
<div class="informalexample">
<pre class="literallayout">
public PurchaseOrderVO getPurchaseOrderVO ();
public void setPurchaseOrderVO(PurchaseOrderVO po);
public void setPurchaseOrder (int ordered);
public void record ()
throws InsufficientCreditException;<a name="433"></a><a name="IDX-176"></a>
public void cancel ();
public PurchaseOrderVO[] getCustomerPurchaseOrders(
String custId);
</pre>
</div>
</p>
<p class="last-para">
<b class="bold">Business objects are responsible for transaction management.</b> Because business objects are the only classes that understand context, they should determine where transactions begin and when they are committed or rolled back. Business objects understand, for instance, which database inserts, updates, and deletes are necessary to perform a business function, such as adding a customer, defining a purchase order, or deactivating a retail product. These business functions can be saved together to form a composite transaction or can be issued individually.</p>
</div>
</div>
</div><br>
<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="LiB0088.html"><img src="images/previous.gif" width="62" height="15" border="0" align="absmiddle" alt="Previous Section"></a>
<a href="LiB0090.html"><img src="images/next.gif" width="41" height="15" border="0" align="absmiddle" alt="Next Section"></a>
</div></td></tr></table>
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -