• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EJB Endpoint or JSE + EJB EndPoint

 
Dushy Inguva
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Here are two of the possible approaches for a high-end webservice implementation.
1. Use a EJB-Endpoint (Stateless Session) and talk to a Entity Bean.
2. Use a JSE endpoint and talk to a Entity Bean. (Will my transactions get propagated from the JSE to Entity Bean?)
Yes I'm aware of the Session Facade pattern. But, what am i losing if i take the second approach?
Dushy
 
Dushy Inguva
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anybody ???
 
Edy Yu
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In your option two, I don't think you can (easily) start a transaction from a JSE endpoint(a POJO bean) and propagate the tx to the entity beans.
Your option one sounds like a good idea which start and control your trasaction level in your session facade(your stateless session bean).
My 2CENTS
 
Richard Monson-Haefel
author
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use the UserTransaction object in a JSE to explicitly start a transaction and then propagate that transaction to your entity beans if you wish - provided the tx attributes on the bean permit propagation.
You can access the UserTransaction object directly from JNDI in a JSE as follows:
javax.transaction.UserTransaction userTransaction = (javax.transaction.UserTransaction)
jndiEnc.lookup("java:comp/UserTransaction");
userTransaction.begin();

userTransaction.commit();
This is covered in section 11.1.1 under EJB Endpoints but it also applies to JSE's and Servlets in a J2EE 1.4 application server.
That said, if you need transactions you are better off using the EJB Endpoint. It's a stateless session bean so its very lightweight (although a more difficult to develop and deploy).
Use EJB when you need transaction (global transactions) support and JSE when you do not.
I hope that helps,
Richard
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic