📄 package-summary.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN""http://www.w3.org/TR/REC-html40/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc on Fri Dec 05 15:19:24 PST 2003 -->
<TITLE>
examples.ejb20.basic.statefulSession (WebLogic Server 8.1 Examples)
</TITLE>
<META NAME="keywords" CONTENT="examples.ejb20.basic.statefulSession package">
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style">
</HEAD>
<SCRIPT>
function asd()
{
parent.document.title="examples.ejb20.basic.statefulSession (WebLogic Server 8.1 Examples)";
}
</SCRIPT>
<BODY BGCOLOR="white" onload="asd();">
<!-- ========== START OF NAVBAR ========== -->
<A NAME="navbar_top"><!-- --></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0">
<TR>
<TD COLSPAN=3 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Package</B></FONT> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">Class</FONT> </TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</td><td valign=bottom align=right><b>WebLogic Server 8.1 Code Examples</b>, BEA Systems, Inc.</td></EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../examples/ejb20/basic/containerManaged/package-summary.html"><B>PREV PACKAGE</B></A>
<A HREF="../../../../examples/ejb20/basic/statelessSession/package-summary.html"><B>NEXT PACKAGE</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../index.html" TARGET="_top"><B>FRAMES</B></A>
<A HREF="package-summary.html" TARGET="_top"><B>NO FRAMES</B></A>
<SCRIPT>
<!--
if(window==top) {
document.writeln('<A HREF="../../../../allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="../../../../allclasses-noframe.html" TARGET=""><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
</TABLE>
<!-- =========== END OF NAVBAR =========== -->
<HR>
<H2>
Package examples.ejb20.basic.statefulSession
</H2>
This example is a package that demonstrates an Enterprise JavaBean written to the EJB 2.0 specification.
<P>
<B>See:</B>
<BR>
<A HREF="#package_description"><B>Description</B></A>
<P>
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=2><FONT SIZE="+2">
<B>Interface Summary</B></FONT></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD WIDTH="15%"><B><A HREF="Trader.html"><I>Trader</I></A></B></TD>
<TD>The methods in this interface are the public face of TraderBean.
</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD WIDTH="15%"><B><A HREF="TraderHome.html"><I>TraderHome</I></A></B></TD>
<TD>This interface is the home interface for the TraderBean.java,
which in WebLogic is implemented by the code-generated container
class TraderBeanC. </TD>
</TR>
</TABLE>
<P>
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=2><FONT SIZE="+2">
<B>Class Summary</B></FONT></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD WIDTH="15%"><B><A HREF="Client.html">Client</A></B></TD>
<TD>This class illustrates calling a stateful SessionBean and performing
the following exercises:
Create a Trader
Buy some shares using the Trader
Sell some shares using the Trader
Remove the Trader
</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD WIDTH="15%"><B><A HREF="TraderBean.html">TraderBean</A></B></TD>
<TD>TraderBean is a stateful SessionBean. </TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD WIDTH="15%"><B><A HREF="TradeResult.html">TradeResult</A></B></TD>
<TD>This class reflects the results of a buy/sell transaction.</TD>
</TR>
</TABLE>
<P>
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=2><FONT SIZE="+2">
<B>Exception Summary</B></FONT></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD WIDTH="15%"><B><A HREF="ProcessingErrorException.html">ProcessingErrorException</A></B></TD>
<TD>This class is used with the examples.ejb20.statefulSession package.
</TD>
</TR>
</TABLE>
<P>
<A NAME="package_description"><!-- --></A><H2>
Package examples.ejb20.basic.statefulSession Description
</H2>
<P>
<p>This example is a package that demonstrates an Enterprise JavaBean written to the EJB 2.0 specification.
The example is a stateful session EJB called
<font face="Courier New" size=-1>TraderBean</font>.
<p>
The example demonstrates:
<ul>
<li>Usage of a session EJB written to the EJB 2.0 specification
<li>Stateful persistence
<li>Using application-defined exceptions and utilities
<li><a href="#Client">Client</a> Application
</ul>
<h3>
Pre-Built Examples</h3>
<p>This EJB 2.0 example is shipped pre-built. However, if you want to re-run this example, you can build it following the instructions in <a href="#Build the example">Build the example</a> and then re-run it following the instructions in <a href="#Run the example">Run the example</a>.
<a name="Client"></a><h2>Client Application</h2>
The Client
application performs these steps:
<ol>
<li>Contacts the Trader home ("TraderHome") through JNDI to find the EJB
<li>Creates a Trader
<li>Sells shares of "MSFT"
<li>Buys shares of "BEAS"
<li>Gets the change in the cash account
<br>(The EJB does not actually "buy" or "sell"; it simulates the actions of accessing a database)
<li>Removes the Trader
</ol>
The application demonstrates how repeated calls to the same session EJB
have a persistent state -- the change in the cash account -- that is maintained across all the calls.
Notice that neither the client nor the EJB do anything to maintain that state: the
container handles it transparently. All the logic for the cash account is encapsulated
in the EJB, unlike the
<a href="../statelessSession/package-summary.html">stateless session example</a>,
where all persistence is provided by the client.
<p>
To get the most out of this example, first read through the source code files
to see what is happening.
<ul>
<li>Client applications
<dd><a href="Client.java">Client.java</a>
<p>
<li>Interfaces
<dd><a href="Trader.java">Trader.java</a>
<dd><a href="TraderHome.java">TraderHome.java</a>
<dd><a href="TradeResult.java">TradeResult.java</a>
<p>
<li>Deployment
<dd><a href="ejb-jar.xml">ejb-jar.xml</a>
<dd><a href="weblogic-ejb-jar.xml">weblogic-ejb-jar.xml</a>
<p>
<li>Exception
<dd><a href="ProcessingErrorException.java">ProcessingErrorException.java</a>
<p>
<li> Server (EJBean)
<dd><a href="TraderBean.java">TraderBean.java</a>
</ul>
Start with the XML deployment files <a href="ejb-jar.xml">ejb-jar.xml</a> and <a href="weblogic-ejb-jar.xml">weblogic-ejb-jar.xml</a> to find the general structure of the EJB, which classes are used for the
different objects and interfaces, then look at
<a href="Client.java">Client.java</a> to see how the application works.
<p>
These three sections cover what to do:
<p>
<ol>
<li><a href="#Build the example">Build the example</a>
<li><a href="#Start the Examples server">Start the Examples server</a>
<li><a href="#Run the example">Run the example</a>
</ol>
<h3><a name="Build the example">Build the example</a></h3>
Set up your development shell as described in
<a href=../../../examples.html#environment>Setting up your environment</a>.
<p>
We provide a build script for you to build the example:
<p>The build script is <b><a href="build.xml">build.xml</a></b>.
<p>Run the build script using the following Java ant command:
<pre>prompt><b> ant</b></pre>
<p>
The script will build the example and place the files in the
correct locations in your WebLogic Server distribution:
<ul>
<li>Client.jar file: in <font face="Courier New" size=-1>SAMPLES_HOME\server\examples\build\clientclasses</font>
<li>EJB (in EAR file): in <font face="Courier New" size=-1>SAMPLES_HOME\domains\examples\applications\ejb20_basic_statefulSession.ear</font>
</ul>
<p>
Running the build script places the EJB in the <font face="Courier New"
size=-1>%applications%</font> directory, where it automatically
deploys once the server is started. If you are already running the server and build
another EJB, it is automatically placed in this directory and instantly deployed.
<p>
Additional information on using the build scripts
is found in
<a href="../../../examples.html#buildScripts">More About Building Examples</a>.
<h3><a name="Start the Examples server">Start the Examples server</a></h3>
<ol>
<li><a href=../../../examples.html#startServer>Start the Examples server</a>.
<!-- Taking this out because the EJB deploys automatically when server starts; no need for manual deployment instructions
<p>
<li><a href=../../../examples.html#console >
Start the Administration Console.</a>
<p>
<li>Click the Deployments node in the left pane and select EJB.
<p>
A list of deployed EJBs displays in the left pane.
<p>
<li>Choose the EJB that you want to deploy from the list of deployment units.
<p>
<li>On the Edit EJB Descriptor page in the right pane, select the Targets tab.
<p>
<li> Verify that the EJB is deployed on the examplesServer. The examplesServer should be listed in the Chosen column.
-->
</ol>
<h3><a name="Run the example"></a>Run the example</h3>
<ol>
<p>
<li>Run the client in a separate command line window. Set up your client as described in
<a href=../../../examples.html#environment>Setting up your environment</a>,
and then run the client by entering:
<!--
<pre><font face="Courier New">prompt><b> java examples.ejb20.basic.statefulSession.Client</b></font></pre>
<p>
If you're not running the WebLogic Server with its default settings,
you will have to run the client using:
-->
<pre> prompt><b> ant run </b> </pre>
<p>
<li>You should receive output similar to this:
<pre><font face="Courier New">Beginning statefulSession.Client...
Creating trader
Selling 200 of MSFT
200 shares sold at a price of 150.0
Buying 250 of BEAS
250 shares bought at a price of 100.0
Change in Cash Account: $5000.0
Removing trader
End statefulSession.Client...
</font></pre>
</ol>
<h2>There's more...</h2>
Read more about EJB in
<a href="http://e-docs.bea.com/wls/docs81/ejb/index.html">BEA
WebLogic Server Enterprise Java Beans</a>.
<P>
<P>
<HR>
<!-- ========== START OF NAVBAR ========== -->
<A NAME="navbar_bottom"><!-- --></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0">
<TR>
<TD COLSPAN=3 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_bottom_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Package</B></FONT> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">Class</FONT> </TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</td><td valign=bottom align=right>Documentation is available at<br> <a href=http://e-docs.bea.com/wls/docs81>http://e-docs.bea.com/wls/docs81</a></td></EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../examples/ejb20/basic/containerManaged/package-summary.html"><B>PREV PACKAGE</B></A>
<A HREF="../../../../examples/ejb20/basic/statelessSession/package-summary.html"><B>NEXT PACKAGE</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../index.html" TARGET="_top"><B>FRAMES</B></A>
<A HREF="package-summary.html" TARGET="_top"><B>NO FRAMES</B></A>
<SCRIPT>
<!--
if(window==top) {
document.writeln('<A HREF="../../../../allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="../../../../allclasses-noframe.html" TARGET=""><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
</TABLE>
<!-- =========== END OF NAVBAR =========== -->
<HR>
<a href=http://e-docs.bea.com/wls/docs81/copyright.html>Copyright</a> © 2003 BEA Systems, Inc. All Rights Reserved.
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -