This section describes the responsibilities of session bean provider to ensure that a session bean can be deployed in any EJB container. EJB.6.10.1 Classes and InterfacesThe session bean provider is responsible for providing the following class files:
EJB.6.10.2 Session Bean ClassThe following are the requirements for session bean class:
EJB.6.10.3 ejbCreate MethodsThe session bean class must define one or more ejbCreate(...) methods whose signatures must follow these rules:
Compatibility Note EJB 1.0 allowed the ejbCreate method to throw the java.rmi.RemoteException to indicate a non-application exception. This practice is deprecated in EJB 1.1 ”an EJB 1.1 compliant enterprise bean should throw the javax.ejb.EJBException or another RuntimeException to indicate non-application exceptions to the container (see Section EJB.12.2.2). EJB.6.10.4 Business MethodsThe session bean class may define zero or more business methods whose signatures must follow these rules:
Compatibility Note EJB 1.0 allowed the business methods to throw the java.rmi.RemoteException to indicate a non-application exception. This practice is deprecated in EJB 1.1 ”an EJB 1.1 compliant enterprise bean should throw the javax.ejb.EJBException or another RuntimeException to indicate non-application exceptions to the container (see Section EJB.12.2.2). EJB.6.10.5 Session Bean's Remote InterfaceThe following are the requirements for the session bean's remote interface:
EJB.6.10.6 Session Bean's Home InterfaceThe following are the requirements for the session bean's home interface:
EJB.6.11 The Responsibilities of the Container ProviderThis section describes the responsibilities of the container provider to support a session bean. The container provider is responsible for providing the deployment tools and for managing the session bean instances at runtime. Because the EJB specification does not define the API between deployment tools and the container, we assume that the deployment tools are provided by the container provider. Alternatively, the deployment tools may be provided by a different vendor who uses the container vendor's specific API. EJB.6.11.1 Generation of Implementation ClassesThe deployment tools provided by the container are responsible for the generation of additional classes when the session bean is deployed. The tools obtain the information that they need for generation of the additional classes by introspecting the classes and interfaces provided by the enterprise bean provider and by examining the session bean's deployment descriptor. The deployment tools must generate the following classes:
The deployment tools may also generate a class that mixes some container-specific code with the session bean class. This code may, for example, help the container to manage the bean instances at runtime. The tools can use subclassing, delegation, and code generation. The deployment tools may also allow the generation of additional code that wraps the business methods and is used to customize the business logic to an existing operational environment. For example, a wrapper for a debit function on the AccountManager bean may check that the debited amount does not exceed a certain limit. EJB.6.11.2 Session EJBHome ClassThe session EJBHome class, which is generated by the deployment tools, implements the session bean's home interface. This class implements the methods of the javax.ejb.EJBHome interface and the create methods specific to the session bean. The implementation of each create(...) method invokes a matching ejbCreate(...) method. EJB.6.11.3 Session EJBObject ClassThe session EJBObject class, which is generated by the deployment tools, implements the session bean's remote interface. It implements the methods of the javax.ejb.EJBObject interface and the business methods specific to the session bean. The implementation of each business method must activate the instance (if the instance is in the passive state) and invoke the matching business method on the instance. EJB.6.11.4 Handle ClassesThe deployment tools are responsible for implementing the handle classes for the session bean's home and remote interfaces. EJB.6.11.5 EJBMetaData ClassThe deployment tools are responsible for implementing the class that provides meta-data to the client view contract. The class must be a valid RMI Value class and must implement the javax.ejb.EJBMetaData interface. EJB.6.11.6 Non-Reentrant InstancesThe container must ensure that only one thread can be executing an instance at any time. If a client request arrives for an instance while the instance is executing another request, the container must throw the java.rmi.RemoteException to the second request. Note A session object is intended to support only a single client. Therefore, it would be an application error if two clients attempted to invoke the same session object. One implication of this rule is that an application cannot make loopback calls to a session bean instance. EJB.6.11.7 Transaction Scoping, Security, ExceptionsThe container must follow the rules with respect to transaction scoping, security checking, and exception handling, as described in Chapters EJB.11, EJB.15, and EJB.12, respectively. |