Enterprise Bean interacts with the container in one of the following three mechanisms: a callback method, an EJBCONTEXT interface or JNDI.
Tonging method:
Each bean will implement the subtype of the EnterpriseBean interface, which defines some methods, called a callback method.
. Each callback method prompts a different event during the life cycle of the bean, and when the container should use a bean,
Store its status to the database, end transactions, remove these methods when removing this bean from memory,
Know this bean. The callback method allows Beans to perform internal adjustments immediately before or after the event.
EJBCONTEXT:
Each bean gets an EJBCONTEXT object that is a direct reference to the container. EJBCONTEXT interface
Method for interacting with containers, so that bean can request information about the environment, such as its client's identity or matter
The status of the service, or Bean can get its own remote reference.
Java Name and Directory Interface (JNDI):
JNDI is a standard extension of the Java platform for accessing naming systems such as LDAP, NetWare, file systems, and more. Each
The bean automatically has access to a particular naming system (called environment name context (ENC))). ENC consists of container
The bean uses JNDI to access the ENC. JNDI ENC allows Bean to access resources, such as JDBC connections, others
Enterprise bean, and attributes specific to this bean.
Local interface represents the lifecycle method of the component (creation, destroying, looking up), and the remote interface represents the business method of bean
. Remote and local interfaces extends Javax.ejb.ejbobject and javax.ejb.ejbhome interface
EJB objects and local objects serve as a proxy for bean objects because they call on the bean receiving method. EJB object owner
To serve as a proxy for the Bean business method; local objects are mainly served as a proxy for the BEAN survival cycle method.
Session beans typically have the following properties:
On behalf of a single client
It can be transactional
Can update the data in the shared database
Relative survival period
Its survival is usually the survival of the client.
Any persistent data is managed by bean
Can be deleted according to the determination of the container
Will be deleted when the EJB server fails
Entity beans typically have the following properties:
Data representing the database
Transactional
Allow multiple users to access together
Can be existed for a long time
Persistent data can be managed by container
Can continue to survive after the EJB server fails