|
Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide
10g Release 3 (10.1.3) B14428-01 |
|
![]() Previous |
![]() Next |
You can specify an EJB 3.0 session bean class method as a callback method for any of the following lifecycle events (see "Using Annotations"):
Post-construct: a method called before the first business method invocation on the session bean and after OC4J performs any dependency injection.
Pre-destroy: a method called before OC4J removes the session bean. Typically, you use this method to release any resources that your session bean is holding.
Pre-passivate: a method called before OC4J passivates the session bean. Applicable to stateful session beans only. Use only if you need to close resources prior to passivation.
Post-activate: a method called immediately after OC4J reactivates a formerly passivated session bean. Applicable to stateful session beans only. Use only if you need to reopen resources after reactivation.
|
Note: Do not specify pre-passivate or post-activate lifecycle callback methods on a stateless session bean. |
The session bean class lifecycle callback method must have the following signature:
public void <MethodName>()
For more information, see "Callback Methods".
You can specify an EJB 3.0 session bean class method as a lifecycle callback method using any of the following annotations:
Example 5-1 shows how to use the @PostConstruct annotation to specify EJB 3.0 stateful session bean class method initialize as a lifecycle callback method.