⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mdb5.html

📁 j2eePDF格式的电子书
💻 HTML
字号:
<?xml version="1.0" encoding="ISO-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">  <head>    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />    <meta http-equiv="Content-Style-Type" content="text/css" />    <title>Deploying and Running SimpleMessageApp</title>    <link rel="StyleSheet" href="document.css" type="text/css" media="all" />    <link rel="StyleSheet" href="catalog.css" type="text/css" media="all" />    <link rel="Table of Contents" href="J2EETutorialTOC.html" />    <link rel="Previous" href="MDB4.html" />    <link rel="Next" href="MDB6.html" />    <link rel="Index" href="J2EETutorialIX.html" />  </head>  <body>    <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="MDB4.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="MDB6.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">    <blockquote><a name="wp79767"> </a><h2 class="pHeading1">Deploying and Running SimpleMessageApp</h2><a name="wp80804"> </a><p class="pBody">To deploy and run this example, go to the <code class="cCode">&lt;</code><code class="cVariable">INSTALL</code><code class="cCode">&gt;/j2eetutorial14/examples/ejb/simplemessage</code> directory.</p><a name="wp79772"> </a><h3 class="pHeading2">Creating the Administered Objects</h3><a name="wp80270"> </a><p class="pBody">This example requires the following:</p><div class="pSmartList1"><ul class="pSmartList1"><a name="wp80272"> </a><div class="pSmartList1"><li>A JMS connection factory resource</li></div><a name="wp80273"> </a><div class="pSmartList1"><li>A JMS destination resource</li></div><a name="wp80275"> </a><div class="pSmartList1"><li>A physical destination to which the destination resource refers</li></div></ul></div><a name="wp80276"> </a><p class="pBody">If you ran the simple JMS examples in Chapter <a  href="JMS.html#wp78297">29</a> and did not delete the resources afterwards, you already have these resources and do not need to perform these steps.</p><a name="wp81565"> </a><p class="pBody">To start the Admin Console, follow the instructions in <a  href="WebApp3.html#wp213824">Starting the Admin Console</a>.</p><a name="wp81577"> </a><p class="pBody">To create the connection factory, perform the following steps:</p><div class="pSmartList1"><ol type="1" class="pSmartList1"><a name="wp81578"> </a><div class="pSmartList1"><li>Expand the Java Message Service node, then click Connection Factories.</li></div><a name="wp81579"> </a><div class="pSmartList1"><li>Click New. The Create JMS Connection Factory screen appears.</li></div><a name="wp81580"> </a><div class="pSmartList1"><li>In the JNDI Name field, type <code class="cCode">jms/QueueConnectionFactory</code>.</li></div><a name="wp81581"> </a><div class="pSmartList1"><li>Choose<code class="cCode"> javax.jms.QueueConnectionFactory</code> from the Type menu.</li></div><a name="wp81582"> </a><div class="pSmartList1"><li>Select the Enabled checkbox.</li></div><a name="wp81583"> </a><div class="pSmartList1"><li>Click OK.</li></div></ol></div><a name="wp81587"> </a><p class="pBody">To create the physical destination, perform the following steps:</p><div class="pSmartList1"><ol type="1" class="pSmartList1"><a name="wp81588"> </a><div class="pSmartList1"><li>In the left-hand pane, click Physical Destinations.</li></div><a name="wp81589"> </a><div class="pSmartList1"><li>Click New. The Create Physical Destination pane appears.</li></div><a name="wp81590"> </a><div class="pSmartList1"><li>In the Physical Destination Name field, type <code class="cCode">PhysicalQueue</code>.</li></div><a name="wp81591"> </a><div class="pSmartList1"><li>Choose <code class="cCode">queue</code> from the Type menu.</li></div><a name="wp81592"> </a><div class="pSmartList1"><li>Click OK.</li></div></ol></div><a name="wp81596"> </a><p class="pBody">To create the destination resource and link it to the physical destination, perform the following steps:</p><div class="pSmartList1"><ol type="1" class="pSmartList1"><a name="wp81597"> </a><div class="pSmartList1"><li>In the left-hand pane, click Destination Resources.</li></div><a name="wp81598"> </a><div class="pSmartList1"><li>Click New. The Create JMS Destination Resource pane appears.</li></div><a name="wp81599"> </a><div class="pSmartList1"><li>In the JNDI Name field, type <code class="cCode">jms/Queue</code>.</li></div><a name="wp81600"> </a><div class="pSmartList1"><li>Choose <code class="cCode">javax.jms.Queue</code> from the Type menu.</li></div><a name="wp81601"> </a><div class="pSmartList1"><li>Select the Enabled checkbox.</li></div><a name="wp81655"> </a><div class="pSmartList1"><li>Under Additional Properties, click Add.</li></div><a name="wp81656"> </a><div class="pSmartList1"><li>Type <code class="cCode">Name</code> in the Name field.</li></div><a name="wp81657"> </a><div class="pSmartList1"><li>Type <code class="cCode">PhysicalQueue</code> in the Value field.</li></div><a name="wp81602"> </a><div class="pSmartList1"><li>Click OK.</li></div></ol></div><a name="wp81615"> </a><p class="pBody">If you are in a hurry, you can create all the administered objects described in this section by using the following <code class="cCode">asant</code> target:</p><div class="pPreformattedRelative"><pre class="pPreformattedRelative">asant create-resources<a name="wp81616"> </a></pre></div><a name="wp80821"> </a><p class="pBody">This target is in the file <code class="cCode">&lt;</code><code class="cVariable">INSTALL</code><code class="cCode">&gt;/j2eetutorial14/examples/ejb/common/targets.xml</code>.</p><a name="wp79784"> </a><h3 class="pHeading2">Deploying the Application</h3><div class="pSmartList1"><ol type="1" class="pSmartList1"><a name="wp81867"> </a><div class="pSmartList1"><li>In <code class="cCode">deploytool</code>, open the <code class="cCode">SimpleMessageApp.ear</code> file, which resides in this directory:</li></div><a name="wp81908"> </a><p class="pBodyRelative"><code class="cCode">&lt;</code><code class="cVariable">INSTALL</code><code class="cCode">&gt;/j2eetutorial14/examples/ejb/provided-ears/</code></p><a name="wp81876"> </a><div class="pSmartList1"><li>Deploy the <code class="cCode">SimpleMessageApp</code> application. </li></div><a name="wp81877"> </a><div class="pSmartList1"><li>In the Deploy Module dialog box, </li></div><div class="pSmartList2"><ol type="a" class="pSmartList2"><a name="wp81889"> </a><div class="pSmartList2"><li>Select the Return Client JAR checkbox.</li></div><a name="wp81896"> </a><div class="pSmartList2"><li>In the field below the check box, enter the following:</li></div><a name="wp81897"> </a><p class="pBodyRelative"><code class="cCode">&lt;</code><code class="cVariable">INSTALL</code><code class="cCode">&gt;/j2eetutorial14/examples/ejb/simplemessage</code></p></ol></div></ol></div><a name="wp81866"> </a><h3 class="pHeading2">Running the Client</h3><a name="wp79786"> </a><p class="pBody">After you deploy the application, you run the client as follows:</p><div class="pSmartList1"><ol type="1" class="pSmartList1"><a name="wp79787"> </a><div class="pSmartList1"><li>In the directory <code class="cCode">&lt;</code><code class="cVariable">INSTALL</code><code class="cCode">&gt;/j2eetutorial14/examples/ejb/simplemessage</code>, type the following command on a single line:</li></div><a name="wp79788"> </a><p class="pBodyRelative"><code class="cCode">appclient -client SimpleMessageAppClient.jar</code></p><a name="wp79790"> </a><div class="pSmartList1"><li>The client displays these lines:</li></div><a name="wp79791"> </a><p class="pBodyRelative"><code class="cCode">Sending message: This is message 1<br />Sending message: This is message 2<br />Sending message: This is message 3</code></p><a name="wp79792"> </a><div class="pSmartList1"><li>In the server log file, the following lines should be displayed:</li></div><a name="wp80308"> </a><p class="pBodyRelative"><code class="cCode">MESSAGE BEAN: Message received: This is message 1<br />MESSAGE BEAN: Message received: This is message 2<br />MESSAGE BEAN: Message received: This is message 3</code></p></ol></div><a name="wp81022"> </a><h3 class="pHeading2">Removing the Administered Objects</h3><a name="wp81023"> </a><p class="pBody">You may use the Admin Console to delete the connection factory and queue after you run the example. These resources are needed for the JMS examples in Chapters <a  href="JMS.html#wp78297">29</a> and <a  href="JMSJ2EEex.html#wp78297">30</a>, however, so if you plan to run those examples, do not delete the resources.</p>    </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="MDB4.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="MDB6.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 + -