All Examples  All EJB Examples

Packages examples.ejb.extensions.readMostly

Enterprise JavaBean entity bean example packages and classes
demonstrating a read-mostly Entity EJB pattern

about this example

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 Setting the cache strategy for entity EJBs for more information about the read-only and read-write strategies.

how to use this example

To get the most out of this example, first read through the source code files. In particular, start with the XML deployment files 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:

  1. Build the examples
  2. Set your environment
  3. Run the examples

Build the examples

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

We provide separate build scripts for Windows NT and UNIX:

These scripts will build the example and place the files in the correct locations:

Set your environment

  1. Setup a connection pool in the weblogic.properties file.

    For your convenience, a template is included in the file; search for "weblogic.jdbc.connectionPool.demoPool", and uncomment and edit the appropriate lines:

      # You can use this connection pool with any of the EJB examples.
      # Uncomment to use:
      weblogic.jdbc.connectionPool.demoPool=\
             url=jdbc:cloudscape:demo,\
             driver=COM.cloudscape.core.JDBCDriver,\
             initialCapacity=1,\
             maxCapacity=2,\
             capacityIncrement=1,\
             props=user=none;password=none;server=none
    You can use this pool for Cloudscape. For other databases, you'll need to set an appropriate url and driver, such as
    	  url=jdbc:weblogic:oracle,\
    	  driver=weblogic.jdbc.oci.Driver,\

  2. Add an access control list (ACL) for users of the pool:
      # Add an ACL for the connection pool:
      weblogic.allow.reserve.weblogic.jdbc.connectionPool.demoPool=everyone

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

Run the examples

  1. Start the WebLogic Server.

    If you're starting the Server from the command line, you'll need to add an entry such as c:/weblogic/eval/cloudscape/lib/cloudscape.jar to the Java system classpath before starting the server, as described in the Administrators Guide Setting up and starting the WebLogic Server.

  2. If you have not registered the EJB in weblogic.properties, deploy it now with the command:
    $ java weblogic.deploy deploy system_password readmostly c:\weblogic\myserver\ejb_extensions_readMostly.jar

  3. Set up your client as described in Setting your development environment, and then run it by entering:
    $ java examples.ejb.extensions.readMostly.Client

    If you're not running the WebLogic Server with its default settings, you will have to run the client using:

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

    where:

    Parameters are optional, but if any are supplied, they are interpreted in this order:

there's more

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

Copyright © 2000 BEA Systems, Inc. All rights reserved.

Last updated 03/22/2000