Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide 10g Release 3 (10.1.3) B14428-02 |
|
![]() Previous |
![]() Next |
This chapter describes the various options that you must configure in order to use an EJB 2.1 session bean.
Table 12-1 lists these options and indicates which are basic (applicable to most applications) and which are advanced (applicable to more specialized applications).
For more information, see:
Table 12-1 Configurable Options for an EJB 2.1 Session Bean
Options | Type |
---|---|
|
Advanced |
"Configuring Passivation Criteria" |
Advanced |
"Configuring Passivation Location" |
Advanced |
"Configuring Bean Instance Pool Size" |
Basic |
"Configuring Bean Instance Pool Timeouts for Session Beans" |
Advanced |
"Configuring a Transaction Timeout for a Session Bean" |
Advanced |
"Configuring a Lifecycle Callback Method for an EJB 2.1 Session Bean" |
Basic |
You can enable and disable passivation for stateful session beans (see "Using Deployment XML").
You may choose to disable passivation for any of the following reasons:
Incompatible object types: if you cannot represent the non-transient attributes of your stateful session bean with object types supported by passivation (see "What Object Types Can Be Passivated?"), you can exchange increased memory consumption for the use of other object types by disabling passivation.
Performance: if you determine that passivation is a performance problem in your application, you can exchange increased memory consumption for improved performance by disabling passivation.
Secondary storage limitations: if you cannot provide sufficient secondary storage (see "Configuring Passivation Location"), you can exchange increased memory consumption for reduced secondary storage requirements by disabling passivation.
For more information, see:
Table 12-2 lists the attributes, values, and defaults for configuring passivation in the server.xml
file element sfsb-config
.
You can specify under what conditions OC4J passivates a stateful session bean (see "Using Deployment XML").
For more information, see:
Table 12-3 lists the attributes, values, and defaults for configuring passivation criteria in the orion-ejb-jar.xml
file element session-deployment
.
Table 12-3 orion-ejb-jar.xml Element session-deployment Passivation Criteria
Attribute | Values | Default |
---|---|---|
Positive, integer number of seconds before passivation occurs. To disable this criteria, specify a value of "never". |
"300" |
|
memory-threshold |
Percentage of JVM memory that can be consumed before passivation occurs. To disable this criteria, specify a value of "never". |
"80" |
max-instances |
Maximum positive integer number of bean instances allowed in memory—either instantiated or pooled. When this value is reached, OC4J attempts to passivate beans using the least recently used (LRU) algorithm. To allow an infinite number of bean instances, the To disable instance pooling, set See "Configuring Bean Instance Pool Size" for more information. |
"0" (unlimited) |
max-instances-threshold |
Percentage of Specify an integer that is translated as a percentage. If you define that the To disable, specify "never." |
"90" |
passivate-count |
Positive, integer number of beans to be passivated if any of the resource thresholds ( Passivation of beans is performed using the least recently used algorithm. To disable this option, specify a value of "0". |
One-third of |
resource-check-interval |
The frequency, as a positive, integer number of seconds, at which OC4J checks resource thresholds ( To disable this option specify a value of "never". |
"180" |
You can specify the directory and file name to which OC4J serializes a stateful session bean when passivated (see "Using Deployment XML").
For more information, see:
Table 12-4 lists the attributes, values, and defaults for configuring passivation location in the orion-ejb-jar.xml
file element session-deployment
.
Table 12-5 lists the EJB 2.1 session bean callback methods you can specify (see "Using Java").
Table 12-5 EJB 2.1 Session Bean Lifecycle Callback Methods
Method | Description |
---|---|
The container invokes this method to create an instance of the bean. |
|
The container invokes this method right after it reactivates the bean. |
|
The container invokes this method right before it passivates the bean. You can turn off passivation for stateful session beans (see "Configuring Passivation"). |
|
A container invokes this method before it ends the life of the session object. This method performs any required clean-up—for example, closing external resources such as file handles. |
|
|
This method associates a bean instance with its context information. The container calls this method after the bean creation. The enterprise bean can store the reference to the context object in an instance variable, for use in transaction management. Beans that manage their own transactions can use the session context to get the transaction context. |
Session bean callback method signatures are defined in the javax.ejb.SessionBean
interface.
Note: Using EJB 2.1, you must implement all session bean callback methods. If you do not need to take any action, implement an empty method. |
For more information, see "Callback Methods".
Example 12-1 shows how to implement an EBJ 2.1 session bean callback method.