Enterprise Bean interacts with containers through one of the following three mechanisms: callback method, ejbcontext interface, or JNDI.
Callback method:
Each bean implements the sub-type of the enterprisebean interface, which defines some methods called callback methods.
. Each callback method prompts a different event to the bean during its lifecycle. When the container wants to use a bean,
When you store the state of the bean to a database, terminate the transaction, and remove the bean from the memory, it will call these methods.
The bean. The callback method allows the bean to execute internal adjustments immediately before or after the event.
Ejbcontext:
Each bean will get an ejbcontext object, which is a direct reference to the container. The ejbcontext interface provides
Is used to interact with the container, so that bean can request information about the environment, such as the client's identity or
Or bean can obtain its own remote reference.
Java Naming and Directory Interface (JNDI ):
JNDI is a standard extension of the Java platform for accessing naming systems, such as LDAP, Netware, and file systems. Each
Bean automatically has access to a specific naming system (called environment naming context (ENC. ENC is managed by the container
Bean uses JNDI to access ENC. Jndi enc allows beans to access resources, such as JDBC connections and other
Enterprise Bean and its attributes.
The Local interface indicates the life cycle method (creation, destruction, and search) of the component, and the remote interface indicates the commercial method of the bean.
. The remote and local interfaces expand the javax. EJB. ejbobject and javax. EJB. ejbhome interfaces respectively.
EJB objects and local Objects Act as proxies for bean objects because they represent bean receiving method calls. EJB object master
To act as a proxy for bean business methods, the local object mainly serves as a proxy for bean lifecycle methods.
Session beans generally have the following attributes:
Execute on behalf of a single client
It can be transactional.
Allows you to update data in a shared database.
Relatively short lifetime
The lifetime is usually the client's lifetime.
Any persistent data is managed by bean
Can be deleted based on container judgment
Will be deleted when the EJB server fails.
Entity beans generally have the following attributes:
Represents the data in the database
Is transactional
Allow multiple users to access
Can exist for a long time
Persistent data can be managed by containers
Continue to survive when the EJB server fails