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

Sun Microsystems Inc.

Support for Transactions

Enterprise JavaBeans v1.1, Final ReleaseAccess from multiple clients in the same trans-

The diamond case is transparent to the Bean Provider—the Bean Provider does not have to code the enterprise bean differently for the bean to participate in a diamond. Any solution to the diamond problem implemented by the Container is transparent to the bean and does not change the semantics of the bean.

11.7.4 Application Assembler and Deployer’s responsibilities

This Subsection specifies the Application Assembler and Deployer’s responsibilities with respect to the diamond case involving an entity object.

The Application Assembler and Deployer should be aware that distributed diamonds might occur. In general, the Application Assembler should try to avoid creating unnecessary distributed diamonds.

If a distributed diamond is necessary, the Deployer should advise the Container (using a Container-spe- cific API) that an entity objects of the entity bean may be involved in distributed diamond scenarios.

11.7.5 Transaction diamonds involving session objects

While it is illegal for two clients to access the same session object, it is possible for applications that use session beans to encounter the diamond case. For example, program A starts a transaction and then invokes two different session objects.

Figure 48 Transaction diamond scenario with a session bean

 

EJB Container

 

 

Session

read and cache

TX1

instance 1

Account 100

Program A

 

 

TX1

 

 

 

Session

 

 

instance 2

read and cache

 

 

 

 

Account 100

If the session bean instances cache the same data item (e.g. the current balance of Account 100) across method invocations in the same transaction, most likely the program is going to produce incorrect results.

The problem may exist regardless of whether the two session objects are the same or different session beans. The problem may exist (and may be harder to discover) if there are intermediate objects between the transaction initiator and the session objects that cache the data.

11/24/99

184

Sun Microsystem Inc

Access from multiple clients in the same transaction contextEnterprise JavaBeans v1.1, Final Release

Support for Transactions

There are no requirements for the Container Provider because it is impossible for the Container to detect this problem.

The Bean Provider and Application Assembler must avoid creating applications that would result in inconsistent caching of data in the same transaction by multiple session objects.

185

11/24/99

Sun Microsystems Inc.

Support for Transactions

Enterprise JavaBeans v1.1, Final ReleaseAccess from multiple clients in the same trans-

11/24/99

186