Scea Road - 7. EJB Container Model

xiaoxiao2021-03-06  101

The Lifecycle of an EJBDetailed documentation describing the lifecycle of an EJB can be found in the EJB specifications on the Sun web site and is llustrated in Figure 7-10 The following list provides a general description of the lifecycle states of an EJB session bean.: 1. The client locates the bean's home reference using the JNDI services provided by the application server.2. The JNDI service returns a home interface reference to the client.3. The client uses the home interface reference to call the home.create () method. in response, the home object then creates an JBObject. A new instance of the code in the bean class is also instantiated by the newInstance () method.4. The new instance of the bean class, called a session bean, is allocated a session context.5. The home object passes a reference to the EJBObject in the container to the client's remote interface.6. The client's remote interface is now able to invoke methods on the EJBObject in the container. This EJBObject will pass .

How The EJB Container Manages Lifecycle And How this Allows for IncreaSed Scalability

1. The container populates the free pool with a working set of bean instances.2. A client calls the create () method on a home object.3. The home object obtains a bean instance from the free pool.4. The home object forwards the create () arguments (if any) to the ejbCreate () method on the bean class.5. The bean class inserts a row into the table in the database.6. The bean class returns the primary key of the row to the home object.7. The container creates an EJB object for the bean class and sets its primary key.8. The home object invokes the ejbPostCreate () method on the bean class to finish the initialization process now that the EJB object can be referenced, because it now exists.9. The home object returns the remote reference to the EJB object back to the client.10. The client can now invoke the business methods on the bean class (via the remote reference) that have been defined as available. 11. When a client is finished, The Container Moves The Bean Back to The Free Pool List Aft AFT er calling ejbPassivate (for an entity bean) .Note that a substantial overhead is incurred when instantiating bean instances. Scalability within the EJB container environment is increased by preinstantiating a pool of bean instances (bean pool) and allowing them to be quickly utilized by clients .

转载请注明原文地址:https://www.9cbs.com/read-124570.html

New Post(0)