|
|
-
All bean classes must implement javax.ejb.EnterpriseBean,
or one of its subinterfaces, at some level.
-
Like java.io.Serializable, this is simply a marker interface; it does not
define any constants or methods.
-
Interestingly, it also extends java.io.Serializable.
-
Session beans implement javax.ejb.SessionBean.
-
This extends javax.ejb.EnterpriseBean.
-
It does define methods:
-
ejbActivate, called when the container is going to activate the
bean.
-
ejbPassivate, called when the container is going to make the bean
inactive.
-
ejbRemove: when the container is going to terminate the session
object.
-
setSessionContext, sets the session context, which contains properties
of the session.
-
You can see that the first three methods are all lifecycle methods, and
are called by the EJB container. You can implement these if you want
to do something when these life events occur; otherwise, you can simply
ignore them.
-
Entity Beans implement javax.ejb.EntityBean
.
-
This also extends javax.ejb.EnterpriseBean.
-
Though it does not extend javax.ejb.SessionBean, it has the same methods
(though the coutnerpart to setSessionContext is setEntityContext), plus
a few more:
-
ejbLoad: this is called to instruct the bean to synchronize its
state with the underlying database.
-
ejbStore: this is called to instruct the bean to store its data
in the underlying database.
-
unsetEntityContext: unsets the entity context.
-
Message Driven Beans implement javax.ejb.MessageDrivenBean.
This has two methods: ejbRemove and setMessageDrivenContext.
The EJB Object and the EJB Container Interceptor
|