Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
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 Entity Bean Component Contract for Container

9.9 The responsibilities of the Container Provider

This section describes the responsibilities of the Container Provider to support entity beans. The Container Provider is responsible for providing the deployment tools, and for managing entity 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 described in this section 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.

9.9.1 Generation of implementation classes

The deployment tools provided by the container provider are responsible for the generation of additional classes when the entity 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 Persistence Manager Provider, and by examining the entity bean’s deployment descriptor.

The deployment tools must generate the following classes:

A class that implements the entity bean’s home interface (i.e. the entity EJBHome class).

A class that implements the entity bean’s remote interface (i.e. the entity EJBObject class).

The deployment tools may also generate a class that mixes some container-specific code with the entity bean class. The code may, for example, help the container to manage the entity bean instances at runtime. Tools can use subclassing, delegation, and code generation.

The deployment tools may also allow generation of additional code that wraps the business methods and that is used to customize the business logic for an existing operational environment. For example, a wrapper for a debit function on the Account Bean may check that the debited amount does not exceed a certain limit, or perform security checking that is specific to the operational environment.

9.9.2 Entity EJBHome class

The entity EJBHome class, which is generated by deployment tools, implements the entity bean’s home interface. This class implements the methods of the javax.ejb.EJBHome interface, and the type-specific create and finder methods specific to the entity bean.

The implementation of each create<METHOD>(...

) method invokes a matching ejbCre-

ate<METHOD>(...

) method, followed

by the matching ejbPostCreate<METHOD>(...

)

method, passing the create<METHOD>(...

) parameters to these matching methods.

 

The implementation of the remove(...) methods defined in the javax.ejb.EJBHome interface must activate an instance (if an instance is not already in the ready state) and invoke the ejbRemove method on the instance.

173

5/31/00

Sun Microsystems Inc.

Entity Bean Component Contract for Container Managed PersistenceEnterprise JavaBeans 2.0, Public Draft The responsibilities of the

The implementation of each find<METHOD>(...) method invokes a matching ejbFind<METHOD>(...) method. The implementation of the find<METHOD>(...) method must create an entity object reference for the primary key returned from the ejbFind<METHOD> and return the entity object reference to the client. If the ejbFind<METHOD> method returns a collection of primary keys, the implementation of the find<METHOD>(...) method must create a collection of entity object references for the primary keys and return the collection to the client.

Before invoking the ejbFind<METHOD>(...) method, the container must first synchronize the state of any entity bean instances that are participating in the same transaction context as is used to execute the ejbFind<METHOD>(...) by invoking the ejbStore() method on those entity bean instances.

The implementation

of each <METHOD>(...

) home method invokes a matching ejb-

Home<METHOD>(...

) method defined in the entity bean’s class.

9.9.3 Entity EJBObject class

The entity EJBObject class, which is generated by deployment tools, implements the entity bean’s remote interface. It implements the methods of the javax.ejb.EJBObject interface and the business methods specific to the entity bean.

The implementation of the remove(...) method (defined in the javax.ejb.EJBObject interface) must activate an instance (if an instance is not already in the ready state) and invoke the ejbRemove method on the instance.

The implementation of each business method must activate an instance (if an instance is not already in the ready state) and invoke the matching business method on the instance.

9.9.4 Handle class

The deployment tools are responsible for implementing the handle class for the entity bean. The handle class must be serializable by the Java Serialization protocol.

As the handle class is not entity bean specific, the container may, but is not required to, use a single class for all deployed entity beans.

9.9.5 Home Handle class

The deployment tools responsible for implementing the home handle class for the entity bean. The handle class must be serializable by the Java Serialization protocol.

Because the home handle class is not entity bean specific, the container may, but is not required to, use a single class for the home handles of all deployed entity beans.

5/31/00

174

Sun Microsystems Inc

The responsibilities of the Container Provider Enterprise JavaBeans 2.0, Public Draft Entity Bean Component Contract for Container

9.9.6 Meta-data class

The deployment tools are responsible for implementing the class that provides meta-data information to the client view contract. The class must be a valid RMI-IIOP Value Type, and must implement the javax.ejb.EJBMetaData interface.

Because the meta-data class is not entity bean specific, the container may, but is not required to, use a single class for all deployed enterprise beans.

9.9.7 Instance’s re-entrance

The container runtime must enforce the rules defined in Section 9.6.11.

9.9.8 Transaction scoping, security, exceptions

The container runtime must follow the rules on transaction scoping, security checking, and exception handling described in Chapters 16, 20, and 17.

9.9.9 Implementation of object references

The container should implement the distribution protocol between the client and the container such that the object references of the home and remote interfaces used by entity bean clients are usable for a long period of time. Ideally, a client should be able to use an object reference across a server crash and restart. An object reference should become invalid only when the entity object has been removed, or after a reconfiguration of the server environment (for example, when the entity bean is moved to a different EJB server or container).

The motivation for this is to simplify the programming model for the entity bean client. While the client code needs to have a recovery handler for the system exceptions thrown from the individual method invocations on the home and remote interface, the client should not be forced to re-obtain the object references.

9.9.10 EntityContext

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

175

5/31/00