Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

EJB Endpoint or JSE + EJB EndPoint

 
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 ???
 
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
 
author
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
 
machines help you to do more, but experience less. Experience this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic