WebLogic Server 7.0 Code Examples, BEA Systems, Inc.

Package examples.ejb11.extensions.readMostly

This example includes a read-only entity EJB called Stock and a read-write entity EJB named StockWriter.

See:
          Description

Interface Summary
Stock The remote interface for the StockBean read-only EJB.
StockHome The home interface for the StockBean read-only EJB.
StockWriter The remote interface for the StockWriterBean.
StockWriterHome The home interface for the StockWriterBean.
 

Class Summary
Client This class illustrates how to use a read-only EJB and a read-write EJB together to provide "read-mostly" access to a set of data.
StockBean StockBean is a read-only EntityBean.
StockWriterBean StockWriterBean is an EntityBean.
 

Package examples.ejb11.extensions.readMostly Description

This example includes a read-only entity EJB called Stock and a read-write entity EJB named StockWriter. Both EJBs work together to provide "read-mostly" access to a set of data. See BEA WebLogic Server Enterprise Java Beans for more information about the read-only and read-write strategies for entity EJBs.

To get the most out of this example, first read through the source code files.

In particular, start with the XML deployment files ejb-jar.xml, weblogic-ejb-jar.xml, Stock-cmp-rdbms.xml and StockWriter-cmp-rdbms.xml to find the general structure of the EJB, which classes are used for the different objects and interfaces, then look at Client.java to see how the application works.

Pre-Built Examples

This EJB 1.1 example is not shipped pre-built. Before you can run this example, you must first build it following the instructions in Build the example.

After you are familiar with the classes and deployment files, follow the instructions in the following foru sections to build and run the examples:

  1. Set Up the database
  2. Build the example
  3. Configure the server
  4. Run the examples

Set Up the database

This example is preconfigured to work with the PointBase database, included with the WebLogic Server distribution. As you'll use a database for the persistent storage of the entity EJBean, you'll need to set it up. Note that the persistent storage is completely invisible to the client; the actual storage is handled by the EJBean directly and not the container. With database persistence, each instance of an EJBean is written to a row in a table.

If you want or need to run this example with Oracle, see Database SetUp for instructions.

Build the example

Set up your development shell as described in Setting up your environment.

We provide a build script for you to build the example:

The build script is build.xml.

Run the build script using the following Java ant command:

prompt> ant

The script will build the example and place the files in the correct locations in your WebLogic Server distribution:

Running the build script places the EJB in the %applications% directory, where it automatically deploys once the server is started. Also, if you are already running the server and then build the EJB, it is automatically placed in this directory and instantly deployed.

Additional information on using the build scripts is found in Building Enterprise JavaBean examples

Configure the server

  1. Start the WebLogic Server.

  2. Start the Administration Console.

  3. Setup a connection pool in the Administration Console.

  4. Click the Deployments node in the left pane and select EJB.

    A list of deployed EJBs displays in the left pane.

  5. Choose the EJB that you want to deploy from the list of deployment units.

  6. On the Edit EJB Descriptor page in the right pane, select the Targets tab.

  7. Verify that the EJB is deployed on the examplesServer. The examplesServer should be listed in the Chosen column.

    If you need more information about how to use connection pools, read Programming WebLogic JDBC.

Run the example

  1. Set up your client as described in Setting up your environment, and then run it by entering:
      prompt> ant run  

  2. If you're running the Client example, you should get output similar to this from the client application:
Beginning readMostly.Client...

Creating a StockWriter for BEAS
Looking up Stock info for BEAS
BEAS:
	Price: 100.0
	Volume: 1000
	52 Week High: 100.0
	52 Week Low: 100.0
Removing the StockWriter

Ending readMostly.Client...
	 

There's more...

Read more about EJB in BEA WebLogic Server Enterprise Java Beans.


Documentation is available at
http://e-docs.bea.com/wls/docs70

Copyright © 2002 BEA Systems, Inc. All Rights Reserved.