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

11.3 The responsibilities of the Container Provider

This section describes the responsibilities of the Container Provider to support bean managed persistence 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 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.

11.3.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 entity Bean 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.

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

245

5/31/00

Sun Microsystems Inc.

Entity Bean Component Contract for Bean Managed PersistenceEnterprise JavaBeans 2.0, Public DraftThe responsibilities of the Con-

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.

The implementation of the ejbHome<METHOD>(...) methods are provided by the bean provider.

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

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

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

246