Skip Headers
Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide
10g (10.1.3.5.0)

Part Number E13981-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

Configuring a Life Cycle Callback Interceptor Method on an EJB 3.0 Session Bean

You can specify an EJB 3.0 session bean class method as a callback interceptor method for any of the following life cycle events (see "Using Annotations"):

Note:

Do not specify pre-passivate or post-activate life cycle callback methods on a stateless session bean.

The session bean class life cycle callback method must have the following signature:

void <METHOD>()

You can also specify one or more life cycle callback methods on an interceptor class that you associate with an EJB 3.0 session bean (see "Configuring a Life Cycle Callback Interceptor Method on an Interceptor Class of an EJB 3.0 Session Bean").

For more information, see the following:

Using Annotations

You can specify an EJB 3.0 session bean class method as a life cycle callback method using any of the following annotations:

  • @PostConstruct

  • @PreDestroy

  • @PrePassivate (stateful session beans only)

  • @PostActivate (stateful session beans only)

Example 5-3 shows how to use the @PostConstruct annotation to specify EJB 3.0 stateful session bean class method initialize as a life cycle callback method.

Example 5-3 @PostConstruct

@Stateful
public class CartBean implements Cart {
    private ArrayList items;
 
    @PostConstruct
    public void initialize() {
        items = new ArrayList();
    }
...
}