WebLogic Server 6.0 Code Examples, BEA Systems, Inc.

Package examples.ejb.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.ejb.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.

After you are familiar with the classes and deployment files, follow the instructions given to build and run the examples:

  1. Build the examples
  2. Configure the server
  3. Run the examples

Build the examples

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

This example ships "pre-built"; you can either run it as shipped, or rebuild the example and run it to test that you are able to successfully build and run EJBeans.

We provide separate build scripts for Windows NT and UNIX:

These scripts 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 /config/examples/applications, where it automatically deploys once the server is started. Also, if you are already running the server and build another 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 .

    For your convenience, a sample connection pool, called demoPool is included with this example. You can use this connection pool with any of the EJB examples.

  4. Make sure that the connection is available for use.

    # In the left-hand pane, expand the Services node and choose JDBC.

    # Click demoPool to display the configuration information in the right-hand pane.

    # Click the Connections tab and review the attribute settings to make sure that they are correct.

  5. In particular, make sure that the URL and Driver Classname attributes are set for the correct database. This example connection pool is pre-configured for Cloudscape. For other databases, you will need to set an appropriate url and driver, such as

    	  URL=jdbc:weblogic:oracle,\
    	  DriverName=weblogic.jdbc.oci.Driver,\

    In this example, the fileRealm for the access control list (ACL) is pre-configured to allow access for everyone.

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

Run the example

    Set up your client as described in Setting up your environment, and then run it by entering:

    $ java examples.ejb.extensions.readMostly.Client "t3://WebLogicURL:Port"

    where:

  • 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/docs60

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