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

Sun Microsystems Inc

Type narrowing of object references

Enterprise JavaBeans 2.0, Public Draft Entity Bean Component Contract for Container

Chapter 9 Entity Bean Component Contract for Container Managed Persistence

The entity bean component contract for container managed persistence is the contract between an entity bean, its container, and its persistence manager. It defines the life cycle of the entity bean instances, the model for method delegation of the client-invoked business methods, and the model for the delegation of the management of the entity bean’s persistent state and relationships. The main goal of this contract is to ensure that an entity bean component using container managed persistence is portable across all compliant EJB Containers.

This chapter defines the enterprise Bean Provider’s view of this contract and responsibilities of the Container Provider and Persistence Manager Provider for managing the life cycle of the enterprise bean instances and their persistent state and relationships.

107

5/31/00

Sun Microsystems Inc.

Entity Bean Component Contract for Container Managed PersistenceEnterprise JavaBeans 2.0, Public Draft

Overview

9.1 Overview

In accordance with this architecture, a bean provider develops a set of beans and dependent object classes for an application and determines the relationships among them. For each bean, the bean provider specifies an abstract persistence schema that defines the methods for accessing the bean’s con- tainer-managed fields and relationships. The bean provider likewise specifies an abstract persistence schema for each dependent object class that is related to the bean. The bean or dependent object class accesses these fields and relationships at runtime by means of the methods defined for its abstract persistence schema.

The persistent fields and relationships of the abstract persistence schema are specified in the deployment descriptor that is produced by the bean provider. The deployer, using the persistence manager provider’s tools, determines how the persistent fields and relationships are mapped to a database or other persistent store, and generates the necessary additional classes and interfaces that enable the persistence manager to manage the persistent fields and relationships of the beans and dependent objects at runtime. The persistence for these fields and relationships is provided by the persistence manager at runtime.

The entity bean component contract for container managed persistence has been substantially changed in the EJB 2.0 specification. Entity beans that use the EJB 1.1 component contract for container manager persistence must still be supported in EJB 2.0 containers. However, the contracts are separate and the bean provider must choose one or the other. The EJB 1.1 entity bean contract for container managed persistence is defined in Chapter 13 “EJB 1.1 Entity Bean Component Contract for Container Managed Persistence” .

9.2Data Independence between the Client View, the Entity Bean View, and the Persistence View

When designing an entity bean with container managed persistence, the Bean Provider must be mindful of the distinction between the client view of the entity bean, and the entity bean’s view of its persistent state. In particular, there need be no direct relationship between these two. While the EJB component model provides a separation between the client view of a bean (as presented by its remote interface) and the entity bean instance (which provides the implementation of the client view), the EJB architecture for container managed persistence adds to this a separation between the entity bean instance (as defined by the bean provider) and its persistent state. The container managed persistence architecture thus provides not only a layer of data independence between the client view of a bean and the bean instance, but also between the bean instance and its persistent representation. This allows an entity bean to be evolved independently from its clients, without requiring the redefinition or recompilation of those clients, and it allows an entity bean to be redeployed across different persistence managers and different persistent storage types, without requiring the redefinition or recompilation of the entity bean class.

Chapter 8 describes the Client View of an Entity Bean. This view is no different for an entity bean with container managed persistence than for an entity bean with bean managed persistence.

5/31/00

108