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 MDB

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

The message-driven 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 message-driven bean (see "Configuring a Life Cycle Callback Interceptor Method on an Interceptor Class of an EJB 3.0 MDB").

For more information, see the following:

Using Annotations

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

  • @PostConstruct

  • @PreDestroy

Example 10-9 shows how to use the @PostConstruct annotation to specify EJB 3.0 message-driven bean class method initialize as a life cycle callback method.

Example 10-9 @PostConstruct in an EJB 3.0 Message-Driven Bean

@MessageDriven
public class MessageLogger implements MessageListener {
    @Resource javax.ejb.MessageDrivenContext mc;

    public void onMessage(Message message) {
    ....
    }

    @PostConstruct
    public void initialize() {
        // Initialization logic
    }
...
}