Chapter 5. Session Bean in Its Container

Session beans, like all enterprise beans, reside at runtime within an EJB container. The EJB container manages the session beans and provides numerous system-level services to support its session beans.

This chapter describes the support that an EJB container implements for session beans. Typically, a container provides services to session beans on two occasions: at deployment and later, when the session bean is used by a client. These built-in container services simplify application development because the application programmer does not have to develop this portion of the logic as part of the application.

This chapter also describes how the EJB container manages session beans. The chapter explains how the container facilitates locating a session bean's home interface and creating a session object, how it handles a client's invocation of the business methods of the bean, how it handles a session bean that has timed out or is removed, and so forth. This chapter also discusses the special classes that support the distributed object protocol, which the container generates for the bean at runtime.

Although a bean developer will likely find the material in this chapter informative and interesting, this knowledge is not necessary to develop session beans. The container services are present in all EJB containers; they exist "under the covers," and the developer can assume that they are there and can treat them like a black box. In most cases, the services are transparent to the bean code; in other cases, the container exposes them as a simple API to the bean. We present a description of the services that the container performs for session beans, merely to give the reader an appreciation of the container's work.

Certain things happen in the EJB environment when a session bean is deployed in a container and subsequently invoked by a client. We focus on how the EJB container handles and manages container artifacts, home interface lookup, session object creation, business method invocation, transaction management, passivation and activation, session object removal and timeout, and invocation of other session beans.

  • Container artifacts These are the additional classes that the EJB container generates to manage the session bean at runtime and to support the distributed object protocol.

  • Home interface lookup A client performs a JNDI lookup of the session bean's home interface.

  • Session object creation A client program creates a new session object when invoking a create method on a session bean home object.

  • Business method invocation A client program invokes the business methods on the session object.

  • Transaction management The container creates and manages a transaction transparently to the session bean class.

  • Passivation and activation The container reclaims resources by moving the session object state to secondary memory: passivation. Later, the container restores the session object state activation when the session object is needed to handle a client-invoked business method.

  • Session object removal and timeout The container removes a session object when the client invokes the remove method or when the bean's timeout limit is reached.

  • Invocation of other session beans One session bean may be a client of another session bean.



Applying Enterprise Javabeans
Applying Enterprise JavaBeans(TM): Component-Based Development for the J2EE(TM) Platform
ISBN: 0201702673
EAN: 2147483647
Year: 2003
Pages: 110

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net