Skip Headers
Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide
10g Release 3 (10.1.3)
B14428-01
  Go To Documentation Library
Home
Go To Product List
Solution Area
Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
Next
Next
 

Configuring a Lifecycle Callback Method for an EJB 2.1 Session Bean

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

ejbCreate

The container invokes this method to create an instance of the bean.

ejbActivate

The container invokes this method right after it reactivates the bean.

ejbPassivate

The container invokes this method right before it passivates the bean. You can turn off passivation for stateful session beans (see "Configuring Passivation").

ejbRemove

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.

setSessionContext

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".

Using Java

Example 12-1 shows how to implement an EBJ 2.1 session bean callback method.

Example 12-1 EJB 2.1 Session Bean Callback Method Implementation

public void ejbActivate()
{
    // when bean is activated
}