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

In this special case, the type of the argument of the findByPrimaryKey method must be declared as java.lang.Object, and the return value of ejbCreate() must be declared as java.lang.Object. The Bean Provider must specify the primary key class in the deployment descriptor as of the type java.lang.Object.

The primary key class is specified at deployment time in the situations when the Bean Provider develops an entity bean that is intended to be used with multiple back-ends that provide persistence, and when these multiple back-ends require different primary key structures.

Use of entity beans with a deferred primary key type specification limits the client application programming model, because the clients written prior to deployment of the entity bean may not use, in general, the methods that rely on the knowledge of the primary key type.

The implementation of the enterprise bean class methods must be done carefully. For example, the methods should not depend on the type of the object returned from EntityContext.getPrimaryKey(), because the return type is determined by the Deployer after the EJB class has been written.

13.2 Object interaction diagrams

This section uses object interaction diagrams to illustrate the interactions between an EJB 1.1 entity bean instance and its container.

13.2.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 classes shown in the diagrams should be considered as an illustrative implementation rather than as a prescriptive one

267

5/31/00

Sun Microsystems Inc.

EJB 1.1 Entity Bean Component Contract for Container Managed PersistenceEnterprise JavaBeans 2.0, Public Draft Object interaction

13.2.2 Creating an entity object

5/31/00

268

Sun Microsystems Inc

Object interaction diagrams

Enterprise JavaBeans 2.0, Public Draft EJB 1.1 Entity Bean Component Contract for

Figure 51 OID of creation of an entity object with EJB 1.1 container-managed persistence

container-provided classes

client

EJB

EJB container

entity

synchro-

instance transaction database

 

Home

Object

context

nization

service

 

 

 

 

 

 

javax.transaction.UserTransaction.begin()

create(args)

ejbCreate(args)

extract container-managed field

create entity representation in DB

register resource manager

new

ejbPostCreate(args)

new

registerSynchronization(synchronization)

business method

business method

269

5/31/00

Sun Microsystems Inc.

EJB 1.1 Entity Bean Component Contract for Container Managed PersistenceEnterprise JavaBeans 2.0, Public Draft Object interaction

13.2.3 Passivating and activating an instance in a transaction

5/31/00

270

Sun Microsystems Inc

Object interaction diagrams

Enterprise JavaBeans 2.0, Public Draft EJB 1.1 Entity Bean Component Contract for

Figure 52 OID of passivation and reactivation of an entity bean instance with EJB 1.1 CMP

container-provided classes

client

EJB

EJB

container entity

synchro-

instance transaction database

 

Home

Object

context

nization

service

 

 

 

 

 

 

business method

business method

ejbStore()

extract container-managed fields update entity state in DB

ejbPassivate()

business method

ejbActivate()

read entity state from DB

set container-managed fields

ejbLoad()

business method

business method

business method

271

5/31/00