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 3.0 MDB

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

The message-driven bean class method must have the following signature:

public void <MethodName>()

For more information, see "Callback Methods".

Using Annotations

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

  • @PostConstruct

  • @PreDestroy

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

Example 10-4 @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
    }
...
}