Enterprise JavaBean (EJB) Interview Questions and Answers


Can you control when passivation occurs?

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).

Posted by:Richards