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.
|