Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EJB Stateless Session Bean with DAOs

 
Andrew Burger
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am wondering the pros and cons of each way to implement a Stateless Session Bean with DAO objects. If there is a another way then these that is better, please let me know.




or



[ March 22, 2007: Message edited by: Andrew Burger ]
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My recommendation is always to not do stuff in the stateless session bean directly. Add another layer between your EJBs and the DOA layer. Make POJO classes that actually implement you business logic, then have your EJB create an instance of these POJO Service classes and call a method in it. Then in that POJO class is where you create instances of your DAO through a DAOFactory.

This allows the reuse of the service POJO Use Case object for other services that might need the same code, and takes out the need for these other services to do a local or remote lookup of the EJB that has that code. Plus you can test these POJOs outside of the container.

Mark
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic