Multiple choice technology architecture

You are using an EJB3.0 Stateful Session Bean for storing shopping cart information. You would like to invoke a particular method to store state data whenever bean passivates. What is the best way to achieve it?

  1. You must write ejbPassivate() method. Shift the logic to this method.

  2. Mention the method name in the deployment descriptor

  3. Use annotations

  4. There is no such facility in EJB3.0

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

EJB 3.0 uses lifecycle callback annotations like @PrePassivate to handle passivation events. The annotated method is automatically invoked when the container passivates the bean. This eliminates the need to implement callback interfaces or use deployment descriptors.