🎴 Flashcard Mode

Enterprise JavaBeans Architecture

Card1 / 20
Mastered0
Review0
QuestionClick to flip

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?

AnswerClick to flip back
A
Use annotations
💡 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.

Change Mode