This sample demonstrates the usage of stateless session EJBs using a simple stock trader application. This sample demonstrates how the client must maintain any persistent state -- such as the change in the cash account -- across repeated calls to the session EJB. All the logic for the balance is encapsulated in the client, where all the persistence is provided by the container and the logic is maintained in the EJB.
The EJB in this sample provides basic trading methods such as buying and selling stocks. Since there are no persistent stores involved in this sample, all the stock data are set in the deployment descriptor of the EJB as environment properties. The container supplies the data to the EJB through JNDI lookup operation.
The following directory contains the Java source files and XML based deployment descriptors.
Windows NT:
$TUXDIR\samples\j2ee\ejb\basic\statelessSession
UNIX:
$TUXDIR/samples/j2ee/ejb/basic/statelessSession
A common build script is provided for all the EJB samples and it can be found in the following directory:
$TUXDIR\samples\j2ee\ejb
$TUXDIR/samples/j2ee/ejb
The following table lists and describes all the files for this sample application:
ejb-jar.xml
The XML deployment descriptor file used to help add the bean to the EJB container.
weblogic-ejb-extensions.xml
A file containing the WLE extensions to the deployment descriptor DTD
Client.Java
The Java source code for the client
TraderBean.java
The Java source code for the stateless session bean. This class contains the business logic method implementations and methods required by EJB 1.1 specification.
Trader.java
The Java source code for the Remote interface of the TraderBean class
TraderBean
TraderHome.java
The Java source code for the Home interface of the TraderBean class
TradeResult.java
Application-specific utility class used to carry a trade execution result between the EJB and the client.
ProcessingErrorException.java
Application-specific exception thrown by the TraderBean class for business methods.
The following table lists and describes the utility files for this sample application. These files are generated based on the WLE installation environment. Since a common build script is provided for all the EJB samples, instructions to build and execute the samples are provided later in Building and Running the EJB Sample Applications. The following files generated in the same directory as where the source files are found.
runme.cmd
The Windows NT batch file that contains commands to set the environment, boot the server, and execute the client for this sample
runme.ksh
The UNIX Korn shell script that contains commands to boot the server and execute the client for this sample
run_client.cmd
The batch file to run the client on Windows NT systems
run_client.ksh
The script file to run the client on UNIX systems
setenv.cmd
The batch file to set the necessary environment variables on Windows NT systems
setenv.ksh
The script file to set the necessary environment variables on UNIX systems
ubbconfig
The WLE server configuration file to be used on UNIX systems
ubbconfig.nt
The WLE server configuration file to be used on Windows NT systems
ejb_basic_statelessSession.jar
The ejb-jar file that contains the source file classes, the container-specific class files generated by the ejbc command, and the deployment descriptor files. This is the ejb-jar file that is deployed on the WLE server.
ejbc
See the topic Building and Running the EJB Sample Applications for information about how to build and run the stateless session bean sample application.
The javadoc for the stateless session bean sample is available at the following location:
Package samples.j2ee.ejb.basic.statelessSession