Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Enterprise JavaBeans™ Specification, Version 2.0 - Sun Microsystems.pdf
Скачиваний:
14
Добавлен:
24.05.2014
Размер:
2.71 Mб
Скачать

Sun Microsystems Inc

The responsibilities of the container provider Enterprise JavaBeans 2.0, Public Draft

Session Bean Component Contract

The methods defined in this interface must follow the rules for RMI/IIOP. This means that their argument and return values must be of valid types for RMI/IIOP, and that their throws clauses must include the java.rmi.RemoteException.

The home interface is allowed to have superinterfaces. Use of interface inheritance is subject to the RMI/IIOP rules for the definition of remote interfaces.

A session bean’s home interface must define one or more create<METHOD>(...) methods. A stateless session bean must define exactly one create() method with no arguments.

Each create method must be named “ create<METHOD>”, and it must match one of the ejbCreate<METHOD> methods defined in the session bean class. The matching ejbCreate<METHOD> method must have the same number and types of arguments. (Note that the return type is different.)

The return type for a create<METHOD> method must be the session bean’s remote interface type.

All the exceptions defined in the throws clause of an ejbCreate<METHOD> method of the session bean class must be defined in the throws clause of the matching create<METHOD> method of the home interface.

The throws clause must include javax.ejb.CreateException.

6.11The responsibilities of the container provider

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

6.11.1 Generation of implementation classes

The 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:

A class that implements the session bean’s home interface (session EJBHome class).

A class that implements the session bean’s remote interface (session EJBObject class).

85

5/31/00

Sun Microsystems Inc.

Session Bean Component Contract

Enterprise JavaBeans 2.0, Public Draft The responsibilities of the container provider

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.

6.11.2 Session EJBHome class

The 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<METHOD> methods specific to the session bean.

The implementation

of each create<METHOD>(...

) method invokes a matching ejbCre-

ate<METHOD>(...

) method.

 

6.11.3 Session EJBObject class

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

6.11.4 Handle classes

The deployment tools are responsible for implementing the handle classes for the session bean’s home and remote interfaces.

6.11.5 EJBMetaData class

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

6.11.6 Non-reentrant instances

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

5/31/00

86

Sun Microsystems Inc

The responsibilities of the container provider Enterprise JavaBeans 2.0, Public Draft

Session Bean Component Contract

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

6.11.7 Transaction scoping, security, exceptions

The container must follow the rules with respect to transaction scoping, security checking, and exception handling, as described in Chapters 16, 20, and 17, respectively.

6.11.8 SessionContext

The container must implement the SessionContext.getEJBContext() method such that the bean instance can use the Java language cast to convert the returned value to the session bean’s remote interface type. Specifically, the bean instance does not have to use the PortableRemoteObject.narrow(...) method for the type conversion.

87

5/31/00

Sun Microsystems Inc.

Session Bean Component Contract

Enterprise JavaBeans 2.0, Public Draft The responsibilities of the container provider

5/31/00

88