Skip Headers

Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide 10g Release 3 (10.1.3) B14428-01 |
| Home | Solution Area | Contents | Index

Previous | Next |

# Configuring EJB 3.0 and EJB 2.1 Stateful Session Bean Replication Policy

The general procedure for configuring EJB application clustering for an EJB 3.0 or EJB 2.1 stateful session bean is:

1. Configure your OC4J application cluster (see "Application Clustering in OC4J" in the Oracle Containers for J2EE Configuration and Administration Guide).

2. Configure a replication policy for stateful session beans on each node (see "Using Deployment XML"):

3. Deploy your EJB to any one of the nodes in the cluster.

For more information, see "State Replication".

## Using Deployment XML

To configure a replication policy, add a `<replication-policy>` element to one or more of the appropriate deployment descriptor files that Table 24-1 lists.

You can specify a single replication policy that OC4J applies globally or specify finer-grained replication policy at the application level for both Web and EJB components or EJB components only.

Configure the `trigger` attribute to one of the following:

- `onRequestEnd` — replicate at the end of each EJB method call

- `onShutdown` — replicate when the JVM is terminating normally

The `scope` attribute is always set to `allAttributes` for a stateful session bean.

For more information, see "State Replication Trigger".

Table 24-1 Deployment XML Files for Replication Policy Configuration

Scope | Affected Components | Deployment XML File | See also ...
--- | --- | --- | ---
Global | Web and EJB | `application.xml` | "Configuring Global Replication Policy in the application.xml File for Web and EJB Components"
Application-level | Web and EJB | `orion-application.xml` | "Configuring Application-Level Replication Policy in the orion-application.xml File for Web and EJB Components"
Application-level | EJB | `orion-ejb-jar.xml` | "Overriding Application-Level Replication Policy in the orion-ejb-jar.xml File for EJB Components"

### Configuring Global Replication Policy in the application.xml File for Web and EJB Components

When you configure the `application.xml` file with a state replication policy (see Example 24-1), it applies to all Web components and to all stateless session beans deployed to this instance of OC4J.

Example 24-1 The application.xml For a Global Replication Policy

    <application>
    ...
        <replication-policy
            trigger="onRequestEnd"        scope="allAttributes"
        />
    ...
    </application>

### Configuring Application-Level Replication Policy in the orion-application.xml File for Web and EJB Components

When you configure the `orion-application.xml` file with a state replication policy (see Example 24-2), it applies to all Web components and to all stateless session beans deployed to this instance of OC4J.

Example 24-2 The orion-application.xml For an Application-Level Replication Policy

    <orion-application>
    ...
        <replication-policy
            trigger="onShutdown"        scope="allAttributes"
        />
    ...
    </orion-application>

### Overriding Application-Level Replication Policy in the orion-ejb-jar.xml File for EJB Components

When you configure the `orion-ejb-jar.xml` file with a state replication policy for a stateful session bean (see Example 24-3), each bean can use a different type of replication independent of the Web component replication type.

Example 24-3 The orion-ejb-jar.xml For an Application-Level Replication Policy for EJBs

    <orion-ejb-jar>
    ...
        <session-deployment
            name="AirlinePOEndpointBean"
            max-tx-retries="0"
            location="AirlinePOEndpointBean"
            persistence-filename="AirlinePOEndpointBean">
    ...
            <replication-policy
                trigger="onRequestEnd"            scope="allAttributes"
            />
    ...
        </session-deployment>
    ...
    </orion-ejb-jar>