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

11.4.4 Committing a transaction

Figure 44 OID of transaction commit protocol for an entity bean instance with bean-managed persistence

container-provided classes

client

EJB

EJB

container entity

synchro-

instance

transaction database

 

 

Home

Object

context

nization

 

service

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

javax.transaction.UserTransaction.commit()

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

beforeCompletion()

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

ejbStore()

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

write state

to DB

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

prepare

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

afterCompletion(status)

 

commit

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Option A:

mark “not registered”

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Option B:

mark “invalid state”

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Option C:

ejbPassivate()

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

11.4.5 Starting the next transaction

The following diagram illustrates the protocol performed for an entity bean instance with bean-managed persistence at the beginning of a new transaction. The three options illustrated in the diagram correspond to the three commit options in the previous subsection.

251

5/31/00

Sun Microsystems Inc.

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

Object interaction diagrams

Figure 45 OID of start of transaction for an entity bean instance with bean-managed persistence

container-provided classes

client

EJB

EJB

container entity

synchro-

instance transaction database

 

Home

Object

context

nization

service

 

 

 

 

 

 

javax.transaction.UserTransaction.begin()

business method

Option A: do nothing

Option B: ejbLoad()

read state from DB register resource manager

Option C: ejbActivate()

ejbLoad()

read state from DB register resource manager

new

registerSynchronization(synchronization)

business method

business method

business method

5/31/00

252

Sun Microsystems Inc

Object interaction diagrams

Enterprise JavaBeans 2.0, Public Draft

Entity Bean Component Contract for Bean

11.4.6 Removing an entity object

Figure 46 OID of removal of an entity bean object with bean-managed persistence

container-provided classes

client

EJB

 

EJB container

entity

synchro-

instance transaction database

 

 

Home

Object

context

nization

 

 

service

 

remove()

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

ejbRemove()

 

 

 

 

remove representation

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

in DB

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

253

5/31/00

Sun Microsystems Inc.

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

Object interaction diagrams

11.4.7 Finding an entity object

Figure 47 OID of execution of a finder method on an entity bean instance with bean-managed persistence

container-provided classes

client

EJB

EJB

container entity

synchro-

instance transaction database

 

Home

Object

context

nization

service

 

 

 

 

 

 

find<METHOD>(args)

ejbFind<METHOD>(args)

search DB

new

11.4.8 Adding and removing an instance from the pool

The diagrams in Subsections 11.4.2 through 11.4.7 did not show the sequences between the “does not exist” and “pooled” state (see the diagram in Section 11.1.4).

5/31/00

254

Sun Microsystems Inc

Object interaction diagrams

Enterprise JavaBeans 2.0, Public Draft

Entity Bean Component Contract for Bean

Figure 48 OID of a container adding an instance to the pool

container-provided classes

EJB

EJB

container entity

synchro-

instance transaction database

Home

Object

context

nization

service

 

 

 

 

 

new

new

setEntityContext(ec)

Figure 49 OID of a container removing an instance from the pool

container-provided classes

EJB

EJB

container entity

synchro-

instance transaction database

Home

Object

context

nization

service

 

 

 

 

 

unsetEntityContext()

255

5/31/00

Sun Microsystems Inc.

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

Object interaction diagrams

5/31/00

256