Skip Headers

# Understanding the EJB Entity Beans With BMP Architecture

Previous

Next

BMP is the part of the J2EE component model that lets you, the bean provider, implement the entity bean's persistence directly in the entity bean class or in one or more helper classes that you provide.

This architecture is an extension of the three-tier architecture, in which the persistent data is bean managed within an entity bean using code that you implement. The client code accesses the data through the entity bean interface.

TopLink BMP is an extension of the TopLink persistence framework that provides base class `BMPEntityBase` as a starting point for your BMP development. This class provides an implementation for all methods (except `ejbPassivate`) required by the EJB specifications prior to 3.0. Subclass `BMPEntityBase` to create a TopLink-enabled entity bean with bean-managed persistence.To use the `BMPEntityBase` class, perform the following:

1. Create a TopLink session (see Understanding TopLink Sessions) for your application.

2. Add a `BMPWrapperPolicy` to each descriptor that represents an entity bean with bean-managed persistence.

   The `BMPWrapperPolicy` provides TopLink with the information to create remote objects for entity beans and to extract the data out of a remote object.

3. Create the home and remote interfaces.

4. Create deployment descriptors (see "Integrating TopLink With an Application Server " and "Creating TopLink Files for Deployment").

5. Package your application (see "Packaging a TopLink Application").

6. Deploy the beans (see "Deploying a TopLink Application").

To make full use of TopLink session and unit of work features, TopLink provides a hook into its functionality through the `BMPDataStore` class. Use this class to translate EJB-required functionality into simple calls.

The `BMPDataStore` class provides implementations of `LOAD` and `STORE`, multiple finders, and `REMOVE` functionality. The `BMPDataStore` class requires a TopLink session. A single instance of `BMPDataStore` must exist for each bean type deployed within a session. When creating a `BMPDataStore`, pass in the session name of the session that the `BMPDataStore` must use to persist the beans and the class of the bean type being persisted. Store the `BMPDataStore` in a global location so that each instance of a bean type uses the correct `store` method.

TopLink BMP support (see Figure: Three-Tier BMP Architecture) lets you combine the standard interfaces of entity beans with bean-managed persistence with TopLink flexibility, performance, and productivity.

Three-Tier BMP Architecture

Description of "Three-Tier BMP Architecture"

TopLink supports BMP. To use BMP support, the home interface must inherit from the `oracle.toplink.ejb.EJB20Home`. To make calls to the `BMPEntityBase`, the `findAll` method must call the EJB 2.0 version of the methods. These methods are prefixed with `ejb20`. For example, in the EJB 2.0 version, the `findAll` method appears as `ejb20FindAll`.

To use local beans, use the `oracle.toplink.ejb.EJB20LocalHome` setting instead of the default `oracle.toplink.ejb.EJB20Home`. Instead of the `oracle.toplink.ejb.BMPWrapperPolicy` setting, use the `oracle.toplink.ejb.bmp.BMPLocalWrapperPolicy` setting.

To accommodate both local and remote configurations, ensure the following:

- For a bean that has a single interface, use the corresponding wrapper policy (local or remote) for the descriptor.

- Beans can only participate in relationships as either local or remote interfaces, not both.

For more information, see the following:

- "Integrating TopLink With an Application Server "

- "Creating TopLink Files for Deployment"

- "Packaging a TopLink Application"

- "Deploying a TopLink Application"

- "Configuring Persistence Type"

- "Configuring the Server Platform"