📄 ejb3.html
字号:
return result.setScale(2,BigDecimal.ROUND_UP); } public BigDecimal yenToEuro(BigDecimal yen) { BigDecimal result = yen.multiply(euroRate); return result.setScale(2,BigDecimal.ROUND_UP); } public ConverterBean() {} public void ejbCreate() {} public void ejbRemove() {} public void ejbActivate() {} public void ejbPassivate() {} public void setSessionContext(SessionContext sc) {}}<a name="wp79843"> </a></pre></div><a name="wp79846"> </a><h3 class="pHeading2">Compiling the Source Files</h3><a name="wp79847"> </a><p class="pBody">Now you are ready to compile the remote interface (<code class="cCode">Converter.java</code>), home interface (<code class="cCode">ConverterHome.java</code>), and the enterprise bean class (<code class="cCode">ConverterBean.java</code>).</p><div class="pSmartList1"><ol type="1" class="pSmartList1"><a name="wp79848"> </a><div class="pSmartList1"><li>In a terminal window, go to this directory:</li></div><a name="wp81510"> </a><p class="pBodyRelative"><code class="cCode"><</code><code class="cVariable">INSTALL</code><code class="cCode">>/j2eetutorial14/examples/ejb/converter/</code> </p><a name="wp79850"> </a><div class="pSmartList1"><li>Type the following command:</li></div><a name="wp79851"> </a><p class="pBodyRelative"><code class="cCode">asant build</code></p></ol></div><a name="wp79852"> </a><p class="pBody">This command compiles the source files for the enterprise bean and the J2EE application client, placing the class files in the <code class="cCode">converter/build</code> subdirectory (not the <code class="cCode">src</code> directory). The Web client in this example requires no compilation. For more information about <code class="cCode">asant</code>, see <a href="About.html#wp67678">Building and Running the Examples</a>.</p><hr><a name="wp79857"> </a><p class="pNote">Note: When compiling the code, the preceding <code class="cCode">asant</code> task includes the <code class="cCode">j2ee.jar</code> file in the classpath. This file resides in the <code class="cCode">lib</code> directory of your J2EE Application Server installation. If you plan on using other tools to compile the source code for J2EE components, make sure that the classpath includes the <code class="cCode">j2ee.jar</code> file.</p><hr><a name="wp79859"> </a><h3 class="pHeading2">Packaging the Enterprise Bean</h3><a name="wp79860"> </a><p class="pBody">To package an enterprise bean, you run the Edit Enterprise Bean wizard of the <code class="cCode">deploytool</code> utility. During this process, the wizard performs the following tasks:</p><div class="pSmartList1"><ul class="pSmartList1"><a name="wp79861"> </a><div class="pSmartList1"><li>Creates the bean's deployment descriptor</li></div><a name="wp79863"> </a><div class="pSmartList1"><li>Packages the deployment descriptor and the bean's classes in an EJB JAR file</li></div><a name="wp81057"> </a><div class="pSmartList1"><li>Inserts the EJB JAR file into the <code class="cCode">ConverterApp.ear</code> file</li></div></ul></div><a name="wp79867"> </a><p class="pBody">To start the Edit Enterprise Bean wizard, select File<span style="font-family: Symbol"><img src="images/arrwrite.gif" border="0" alt="Right Arrow"></span>New<span style="font-family: Symbol"><img src="images/arrwrite.gif" border="0" alt="Right Arrow"></span>Enterprise Bean. The wizard displays the following dialog boxes.</p><div class="pSmartList1"><ol type="1" class="pSmartList1"><a name="wp79868"> </a><div class="pSmartList1"><li>Introduction dialog box</li></div><div class="pSmartList2"><ol type="a" class="pSmartList2"><a name="wp79869"> </a><div class="pSmartList2"><li>Read the explanatory text for an overview of the wizard's features.</li></div><a name="wp79870"> </a><div class="pSmartList2"><li>Click Next.</li></div></ol></div><a name="wp79871"> </a><div class="pSmartList1"><li>EJB JAR dialog box</li></div><div class="pSmartList2"><ol type="a" class="pSmartList2"><a name="wp79872"> </a><div class="pSmartList2"><li>Select the button labelled Create New JAR Module in Application.</li></div><a name="wp81095"> </a><div class="pSmartList2"><li>In the combo box below this button, select <code class="cCode">ConverterApp</code>.</li></div><a name="wp81098"> </a><div class="pSmartList2"><li>In the JAR Display Name field, enter <code class="cCode">ConverterJAR</code>.</li></div><a name="wp81515"> </a><div class="pSmartList2"><li>Click Edit.</li></div><a name="wp81516"> </a><div class="pSmartList2"><li>In the tree under Available Files, locate the <code class="cCode">converter/build</code> subdirectory. (If the target directory is many levels down in the tree, you can simplify the tree view by entering all or part of the directory's path name in the Starting Directory field.)</li></div><a name="wp79877"> </a><div class="pSmartList2"><li>In the Available Files tree select these classes: <code class="cCode">Converter.class</code>, <code class="cCode">ConverterBean.class</code>, and <code class="cCode">ConverterHome.class</code>. (You may also drag and drop these class files to the Contents text area.)</li></div><a name="wp80727"> </a><div class="pSmartList2"><li>Click Add.</li></div><a name="wp79878"> </a><div class="pSmartList2"><li>Click OK.</li></div><a name="wp79879"> </a><div class="pSmartList2"><li>Click Next.</li></div></ol></div><a name="wp79880"> </a><div class="pSmartList1"><li>General dialog box</li></div><div class="pSmartList2"><ol type="a" class="pSmartList2"><a name="wp79881"> </a><div class="pSmartList2"><li>Under Bean Type, select the Session button.</li></div><a name="wp79882"> </a><div class="pSmartList2"><li>Select the Stateless button.</li></div><a name="wp79883"> </a><div class="pSmartList2"><li>In the Enterprise Bean Class combo box, select <code class="cCode">converter.ConverterBean</code>.</li></div><a name="wp79884"> </a><div class="pSmartList2"><li>In the Enterprise Bean Name field, enter <code class="cCode">ConverterEJB</code>.</li></div><a name="wp79885"> </a><div class="pSmartList2"><li>In the Remote Home Interface combo box, select <code class="cCode">converter.ConverterHome</code>. </li></div><a name="wp79886"> </a><div class="pSmartList2"><li>In the Remote Interface combo box, select <code class="cCode">converter.Converter</code>.</li></div><a name="wp79887"> </a><div class="pSmartList2"><li>Click Next. </li></div></ol></div><a name="wp80742"> </a><div class="pSmartList1"><li>In the Configuration Options dialog box, click Next.</li></div><a name="wp80749"> </a><div class="pSmartList1"><li>Click Finish.</li></div></ol></div> </blockquote> <img src="images/blueline.gif" width="550" height="8" ALIGN="BOTTOM" NATURALSIZEFLAG="3" ALT="Divider"> <table width="550" summary="layout" id="SummaryNotReq1"> <tr> <td align="left" valign="center"> <font size="-1"> <a href="http://java.sun.com/j2ee/1.4/download.html#tutorial" target="_blank">Download</a> <br> <a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/faq.html" target="_blank">FAQ</a> <br> <a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/history.html" target="_blank">History</a> </td> <td align="center" valign="center"><a accesskey="p" href="EJB2.html"><img id="LongDescNotReq1" src="images/PrevArrow.gif" width="26" height="26" border="0" alt="Prev" /></a><a accesskey="c" href="J2EETutorialFront.html"><img id="LongDescNotReq1" src="images/UpArrow.gif" width="26" height="26" border="0" alt="Home" /></a><a accesskey="n" href="EJB4.html"><img id="LongDescNotReq3" src="images/NextArrow.gif" width="26" height="26" border="0" alt="Next" /></a><a accesskey="i" href="J2EETutorialIX.html"></a> </td> <td align="right" valign="center"> <font size="-1"> <a href="http://java.sun.com/j2ee/1.4/docs/api/index.html" target="_blank">API</a> <br> <a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/search.html" target="_blank">Search</a> <br> <a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/sendusmail.html" target="_blank">Feedback</a></font> </font> </td> </tr> </table> <img src="images/blueline.gif" width="550" height="8" ALIGN="BOTTOM" NATURALSIZEFLAG="3" ALT="Divider"><p><font size="-1">All of the material in <em>The J2EE(TM) 1.4 Tutorial</em> is <a href="J2EETutorialFront2.html">copyright</a>-protected and may not be published in other workswithout express written permission from Sun Microsystems.</font> </body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -