posted 21 years ago
The 'purpose of the Rule' is to allow the Stateful Bean using BMT to execute multiple business methods in the same transaction.
Consider a scenario:
A stateful session Bean uses BMT. Client calls multiple methods, method_1() , method_2(), .. method_n() which are to be executed in the same transaction.
Flow:
1. Client invokes the bean's method_1().
2. method_1() has BMT demarcation to start a transaction T_1 using UserTransaction.begin().
3. method_1() returns without completing transaction T_1.
4. method_2() is called next, since T_1 is already associated with the instance the method executes in transaction T_1.
5. method_2() returns without completing the transaction.
6. method_n() is the last to be called, it continues in T_1, and eventually commits/rollbacks the transaction T_1 using UserTransaction.commit().
Conditions:
a. If method_2() ( or method_n() ) attempts to open a new transaction in the above scenario, when T_1 is already open and has not been commited, it will throw javax.transaction.NotSupportedException in the UserTransaction.begin() method.
b. Stateless Beans are however required to complete the transaction before the business method returns (unlike Stateful Session Beans).
Note: If the client calls the method_1() in his own transaction , the client's transaction is always suspended before BMT starts its own transactions.
I hope it answers your question.
Regards,
Shafique.
[ March 03, 2004: Message edited by: Shafique Razzaque ]
Shafique Razzaque,<br />Senior Software Engineer,<br />Singapore.<br /> <br />Masters (in progress), SCEA (in progress), SCBCD (98%), SCJP (76%)