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

Sun Microsystems Inc.

Entity Bean Component Contract

Enterprise JavaBeans v1.1, Final Release

Object interaction diagrams

9.5.4 Committing a transaction

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

container-provided classes

client

EJB

EJB

container instance

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/24/99

140

Sun Microsystem Inc

Object interaction diagrams

Enterprise JavaBeans v1.1, Final Release

Entity Bean Component Contract

Figure 31 OID of transaction commit protocol for an entity bean instance with container-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()

 

extract container-managed fields

 

update entity state in DB

 

prepare

 

commit

 

afterCompletion(status)

Option A: mark “not registered”

Option B:

mark “invalid state”

Option C:

ejbPassivate()

141

11/24/99

Sun Microsystems Inc.

Entity Bean Component Contract

Enterprise JavaBeans v1.1, Final Release

Object interaction diagrams

9.5.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.

11/24/99

142

Sun Microsystem Inc

Object interaction diagrams

Enterprise JavaBeans v1.1, Final Release

Entity Bean Component Contract

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

container-provided classes

client

EJB

EJB

container instance

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

143

11/24/99

Sun Microsystems Inc.

Entity Bean Component Contract

Enterprise JavaBeans v1.1, Final Release

Object interaction diagrams

Figure 33 OID of start of transaction for an entity bean instance with container-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:

read state from DB

register resource manager

 

 

set container managed fields

 

ejbLoad()

Option C:

ejbActivate()

 

read entity state from DB

 

register resource manager

 

set container managed fields

 

ejbLoad()

 

new

 

registerSynchronization(synchronization)

 

business method

business method

business method

11/24/99

144