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

9.12.3 Passivating and activating an instance in a transaction

185

5/31/00

Sun Microsystems Inc.

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

Object interaction dia-

Figure 28 OID of passivation and reactivation of an entity bean instance with container managed persistence

container-provided classes

client

EJB

EJB

container entity

synchro-

persistence

instance database

manager

 

Home

Object

context

nization

instance

 

 

 

 

 

 

 

business method

business method

ejbStore()

ejbStore()

ejbPassivate()

ejbPassivate()

business method

ejbActivate()

ejbActivate()

ejbLoad()

ejbLoad()

business method

getXX()

getConnection()

read entity state from database

5/31/00

186

Sun Microsystems Inc

Object interaction diagrams

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

9.12.4 Committing a transaction

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

 

 

container-provided classes

 

persistence manager

 

 

 

 

 

provided classes

 

 

 

 

 

 

 

 

 

client

EJB

container entity

synchro-

 

synchro-

persistence

instance

transaction database

 

nization

manager

 

Object

context

nization

 

 

service

 

 

 

instance

 

 

 

 

 

 

 

 

 

 

javax.transaction.UserTransaction.commit()

 

beforeCompletion()

ejbStore()

 

 

ejbStore()

before

 

Completion()

 

getConnection()

 

verify cache and update entity state in database

close connection

 

 

prepare

 

commit

afterCompletion(status)

after

 

Completion(status)

 

Option A: mark “not registered”

Option B:

mark “invalid state”

Option C:

 

ejbPassivate()

 

 

ejbPassivate()

187

5/31/00

Sun Microsystems Inc.

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

Object interaction dia-

9.12.5 Starting the next transaction

The following diagram illustrates the protocol performed for an entity bean instance with con- tainer-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.

5/31/00

188

Sun Microsystems Inc

Object interaction diagrams

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

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

container-provided classes

client

EJB

Transaction

 

synchro-

persistence

instance

transaction

database

 

manager

 

 

Object

object

container nization

instance

 

 

service

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

javax.transaction.UserTransaction.begin()

business method new

registerSynchronization(synchronization)

Option A:

do nothing

Option B:

ejbLoad()

registerSynchronization(synchronization)

ejbLoad()

Option C:

ejbActivate()

ejbActivate()

ejbLoad()

registerSynchronization(synchronization)

ejbLoad()

business method

getXX()

registerSynchronization(synchronization) if option A was used

getConnection()

read entity state from database

189

5/31/00