Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JavaEE Business and persistence, what is SessionBean, what is not?

 
Alexandre Fradin
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am preparing SCEA certification and I have a good understanding of EJBs, but I use to develop web-centric application with Spring where everything is POJO.
So I have some troubles to distinguish what is SessionBean or not in business and persistance layers.

Basicly in a web-centric Spring application I use the fold architecture :

Web tiers                                              | Business tier                | persistance tier
Backing bean <-> Business Delegate <-> Facades <-> Services <-> DAOs

I think that I can keep the same architecture in EJB-centric application (right?).

While Facades are necessary SessionBean, what about Services and DAOs? Pro & Cons?

If we want to rely on EJB resource injection mecanism at least DAOs should be SessionBean in order to resolve EntityManager. But we could use Spring (Spring EJB) to do that.
Is it a common practice?

Thanks.

 
raj sirohi
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Alexandre,

This is what I think.

"Basicly in a web-centric Spring application I use the fold architecture :

Web tiers | Business tier | persistance tier
Backing bean <-> Business Delegate <-> Facades <-> Services <-> DAOs

I think that I can keep the same architecture in EJB-centric application (right?)"

IMHO I would include service locator between business delegate and facades. This will decouple web tier from business tier.
DAO are called EAO ( entiry access objects ) now. since you are using session bean you can inject entity manager in the session bean and forego EAO/DAO, however I think its better to use EAOs that way all queries. CRUD operation are not sprinled all over the place.

Regards
Raj
 
Alexandre Fradin
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok thanks.

But which option is the best one for business layer between :
1) everything is SessionBean (Facades, Services, EAOs/DAOs)
or
2) just Facade is a Session bean in order to delimit transaction and the role restrictions, Service and EAOs/DAOs are POJOs. Spring might be used to provdie injection mecanism.

Annotations made EJB3 simpler, so the first one is easy to implement.
But what about performance? EJBs use more resources than POJOs, is it a good practice to implement everything as EJB while only Facade need transaction and security services?

Regards.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic