Java EJB Programming Question:

Can you control when passivation occurs?

Tweet Share WhatsApp

Answer:

The developer, according to the specification, cannot directly control when passivation occurs. Although for Stateful Session Beans, the container cannot passivate an instance that is inside a transaction. So using transactions can be a a strategy to control passivation. The ejbPassivate() method is called during passivation, so the developer has control over what to do during this exercise and can implement the require optimized logic. Some EJB containers, such as BEA WebLogic, provide the ability to tune the container to minimize passivation calls.

Taken from the WebLogic 6.0 DTD -The passivation-strategy can be either default or transaction. With the default setting the container will attempt to keep a working set of beans in the cache. With the transaction setting, the container will passivate the bean after every transaction (or method call for a non-transactional invocation).

Download Java EJB Programming PDF Read All 27 Java EJB Programming Questions
Previous QuestionNext Question
Can the primary key in the entity bean be a Java primitive type such as int? What is the advantage of using Entity bean for database operations, over directly using JDBC API to do database operations? When would I use one over the other?