Java Reference
In-Depth Information
to its status. Those methods are defined in the bean class that the implementa-
tion class extends. The classes one extends to implement a bean are:
SessionBean
EntityBean
MessageBean
Please forgive us right now for admitting that we will not cover message
beans in this topic beyond a brief description in the next section. For details
on message beans, take a look at Chapter 8 of Enterprise JavaBeans Component
Architecture by Gail Anderson and Paul Anderson (ISBN 0-13-035571-2).
Not all of the control methods need to be implemented in all cases, but
the full set is not that large or difficult to understand. They correspond to im-
portant “life events” in lifetime of the bean. The primary events are: creation,
destruction, passivation, activation, persist to DB, restore from DB, and context
switching.
Creation. A bean is created when its constructor is called. As we shall learn,
the calling of the constructor has absolutely no connection with a client request.
For session beans, the container maintains a pool of instances to handle client
requests. For entity beans, a bean (most commonly) represents a database table,
and the setEntityContext() method is used to move that bean from row
(instance) to row as needed.
In practice, this usually means that a number of instances of the bean are
created when the application server is started. Additional instances are created
as the demand for this bean (number of clients, number of calls per unit time)
increases.
Destruction. As you know, Java objects do not have explicit destructors,
but when a bean instance is destroyed, an explicit method in the Bean class is
called to permit shutdown operations to take place.
This is quite distinct from activation and passivation. Activation and pas-
sivation are operations carried out when the application server needs to shove
aside some Bean instances that may still be needed by clients in order to make
room for an active request that requires more than the available system
resources.
Passivation and activation. As we said above, passivation involves the
container asking the beans that are still potentially needed to step aside to allow
Search WWH ::




Custom Search