BEA Systems Logo Banner Arc  
  Stateful Session Bean Sample


Stateful Session Bean Sample

This sample application shows how repeated calls to the same session bean have a persistent state -- the change in the cash account -- that is maintained across all the calls. Notice that neither the client nor the EJBean do anything to maintain that state: the container handles it transparently. All the logic for the cash account is encapsulated in the bean, unlike the statless session sample where all persistence is provided by the client.

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 the JNDI lookup operation.

This samples provides two types of clients: one is a simple single threaded client, and the other is a multi-threaded client.

Main Directory Location

The following directory contains the Java source files and XML based deployment descriptors.

Windows NT:

$TUXDIR\samples\j2ee\ejb\basic\statefulSession 

UNIX:

$TUXDIR/samples/j2ee/ejb/basic/statefulSession 

A common build script is provided for all the EJB samples and it can be found in the following directory:

Windows NT:

$TUXDIR\samples\j2ee\ejb 

Unix:

$TUXDIR/samples/j2ee/ejb 

Files

The following table lists and describes all the files for this sample application:

File Description

ejb-jar.xml

The XML deployment descriptor file used to add the bean to the EJB container

weblogic-ejb-extensions.xml

The WLE extensions to the deployment descriptor DTD

Client.Java

The Java source code for the client application

MultiClient.Java

The Java source code for the multithreaded client application

TraderBean.java

The Java source code for the stateful 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

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

Utility Files

The following table lists and describes the utility files for this sample application. These files are generated based on the WLE installation environment. Because 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.

File Description

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 application on Windows NT systems

run_client.ksh

The script file to run the client application on UNIX systems

run_mclient.ksh

The script file to run the multithreaded client application on UNIX systems

run_mclient.cmd

The batch file to run the multithreaded client application on Windows NT systems

setenv.cmd

The batch file to set the necessary environment variables on Windows NT systems

setnv.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

Building and Running the Sample

See the topic Building and Running the EJB Sample Applications for information about how to build and run the stateful session bean sample application.

Javadoc

The javadoc for the stateful session bean sample is available at the following location:

Package samples.j2ee.ejb.basic.statefulSession 

 
 
    BEA Home | Corporate Info | News | Solutions | Products | Partners | Services | Events | Download | How to Buy
 Copyright © 1999, BEA Systems, Inc. All rights reserved.
 Contact BEAdocsupport@beasys.com