| Author |
sessionSynchronization
|
Kris Reid
Ranch Hand
Joined: Jan 05, 2005
Posts: 247
|
|
Why can't statless bens implement sessionSynchronization? Can BMT Session beans implement sessionSynchronization? It would be pointless but can they? Can EntityBeans implement sessionSynchronization?
|
 |
Paul Codillo
Ranch Hand
Joined: Aug 21, 2002
Posts: 38
|
|
Originally posted by Kris Reid: Why can't statless bens implement sessionSynchronization? Can BMT Session beans implement sessionSynchronization? It would be pointless but can they? Can EntityBeans implement sessionSynchronization?
1.) Stateless beans cannot implement sessionSynchronization because transactions in stateless session beans are not allowed to span multiple method calls. As soon as a method returns, the transaction is over. Begin/Commit is governed by the scope of the method. There is no more sense to call the sessionSynchronization methods. 2.) They can (im not sure) but might not be called by the container since it expects the bean provider to explicitly call begin and commit. 3.) Entitiy beans have onLoad() and onStore() methods instead of the sessionSynchronization methods. I'm not sure if implementing is legal. I doubt it.
|
paul.com<br />SCJP, SCWCD, SCBCD, SCEA
|
 |
Chengwei Lee
Ranch Hand
Joined: Apr 02, 2004
Posts: 884
|
|
By allowing stateless session beans to implement SessionSynchronization, we're actually implying that session beans can maintain state across transactions, which is not true. Hence, it is not allowed.
You can't. Because by having BMT, you know exactly when you're starting & ending the transactions. The exact boundaries of the transactions are made known to you. Hence, you don't have to rely on implementing the SessionSynchronization interface.
As of EJB 2.0, entity beans can only be of CMT type. As pointed out by Paul, you've the benefits of ejbLoad & ejbStore. Also, the name of the interface sortof indicated that its meant for session beans only.
|
SCJP 1.4 * SCWCD 1.4 * SCBCD 1.3 * SCJA 1.0 * TOGAF 8
|
 |
 |
|
|
subject: sessionSynchronization
|
|
|