We have an existing application running EJB2 EJBs. However, we have an opportunity at the moment to reconsider certain aspects of the architecture. And, EJB3 beckons, as do several of the Java 1.5 constructs.
However, the world has moved a long way since we last looked at these architectural tradeoffs. And I am no longer feeling as confident of our approach as I once did.
Specifically, I would like to hear your thoughts on how we should approach architecting three of our key ?modules?. I think that these answers will steer the rest of our decisions.
DB: We have a stateless EJB that handles our access to our database (we don?t use Hibernate and fire off a lot of SQL). We rely heavily on the connection pooling provided by the AS. The DB EJB is called by our MDBs, other EJBs and all our JSP pages.
I think that this should remain a stateless EJB. Am I correct?
Page: We have another stateless EJB which manages the lifecycle of the JSP pages and provides a range of utility functions to the pages themselves (from date manipulation, to database access via the DB EJB referenced above). The EJB is created by the web tier, and could conceivably be accessed only by other objects in the web tier.
I think this should become a POJO managed by Tomcat. Do I need to worry about connection pooling or any other performance related issues?
Logging: A ?module? that provides logging functionality to all our components, both in the web tier, but also the MDBs.
As this module is used from both the web and EJB tier, I think that this should move into a JAR with similar modules (encryption etc) and be deployed as a library function. Is this correct?
A bunch of stuff has been written on the EJB, not EJB debate. But, my feeling is that it isn?t nearly as clear-cut as many of the writers make out.
The book, Mastering EJB 3 (http://www.theserverside.com/tt/books/wiley/masteringEJB3/downloads/MasteringEJB4thEd.pdf - free registration required) has a useful chapter 13 which also speaks to these questions.
I am very interested in hearing your opinions!