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

Sun Microsystems Inc

Object interaction diagrams

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

The container must provide the implementation of the getConnection methods as part of the resource manager connection factory implementation that is provided to the persistence manager. In a typical implementation, the container’s implementation of the resource manager connection factory interface should note the transactional context and identity of the persistence manager’s calling thread and delegate to the resource-specific resource manager connection factory interface, described in [11].

It is the responsibility of the container (not the persistence manager) to manage transactions on all connections enlisted in the distributed transaction context and on those for which the container uses the local transaction optimization (i.e., all connections acquired from any resource manager connection factory that provides container management of the transactional enlistment of connections).

9.11.6 Persistence manager responsibilities

The persistence manager, if it is using an optimistic concurrency control strategy may register a javax.transaction.Synchronization object with the transaction manager.

The persistence manager may only use the getTransaction() and getStatus() methods of the javax.transaction.TransactionManager interface. If the persistence manager calls any other method of the javax.transaction.TransactionManager interface, the container must raise an IllegalStateException.

The persistence manager may only use the getStatus(), registerSynchronization(), and setRollbackOnly() methods of the javax.transaction.Transaction interface. If the persistence manager calls any other method of the javax.transaction.Transaction interface, the container must raise an IllegalStateException.

The persistence manager must not use any of the low-level XA and connection pooling interfaces on any resource manager connection factory or connection. These low-level interfaces are intended for the integration of a resource adaptor (e.g., JDBC driver) with the container and are not for use by the persistence manager.

The persistence manager is responsible for the transaction management of all local connections (i.e., those connections that are obtained by the persistence manager from any resource manager connection factory that provides non-enlisted transactions).

9.12 Object interaction diagrams

This section uses object interaction diagrams to illustrate the interactions between an entity bean instance, its persistence manager, and its container.

181

5/31/00

Sun Microsystems Inc.

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

Object interaction dia-

9.12.1 Notes

The object interaction diagrams illustrate a box labeled “container-provided classes.” These classes are either part of the container or are generated by the container tools. These classes communicate with each other through protocols that are container implementation specific. Therefore, the communication between these classes is not shown in the diagrams.

The class labeled “Transaction object” denotes the transaction object that the persistence manager obtains from the container by invoking the getTransaction() method on the transaction manager object provided to the persistence manager by the container.

The classes labeled “instance” and “persistence manager instance” denote those portions of the entity bean class as seen or provided by the Bean Provider and the persistence manager’s generated code respectively.

The classes shown in the diagrams should be considered as an illustrative implementation rather than as a prescriptive one.

5/31/00

182

Sun Microsystems Inc

Object interaction diagrams

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

9.12.2 Creating an entity object

183

5/31/00

Sun Microsystems Inc.

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

Object interaction dia-

Figure 27 OID of creation of an entity object with container-managed persistence

container-provided classes

client

EJB

EJB

Transaction

entity

synchro-

persistence

instance transaction database

manager

 

Home

Object

object

context

nization

instance

service

 

 

 

 

 

 

 

 

javax.transaction.UserTransaction.begin()

create(args)

new

registerSynchronization(synchronization)

ejbCreate(args)

ejbCreate(args)

setXX()

registerSynchronization(synchronization)

new

ejbPostCreate(args)

ejbPostCreate(args)

setYY()

business method

business method

5/31/00

184