bernie wrote:
Is it alright now to do away with EJB in ANY application (including "mission-criticals")? Have other open source/commercial tools matured now to a point of being able to do well the advantages that EJB is said to have? I am not inclined to using EJB but my mind is open. I'd like to have your opinions on this, including substitute tools.
You can certainly
not do away with EJB in ANY application. If your application is internally distributed in its nature, meaning that it needs remoting at the internal component level as opposed to exposing remote services to clients, remote EJBs are still a viable choice. A particular case for remote EJBs is distributed transaction propagation, and load balancing at the component level.
However, 90 percent or more of J2EE web applications out there aren't internally distributed or at least are not deployed that way. If you need to scale such apps, simply set up a farm of web servers, each with its own colocated deployment of the whole app, potentially with HttpSession clustering. For that kind of applications, remote EJBs do not provide any benefit: That's why local EJBs are typically chosen for such scenarios.
It's exactly the use of
local EJBs that should be looked at more closely. Essentially, declarative transaction management is the single most important benefit. Instance pooling just makes sense if you keep non-threadsafe instance variables - it's hard to think of a compelling case where that would be necessary (note that a DataSource or a SessionFactory are perfectly threadsafe). And declarative security at the component level simply isn't necessary in colocated apps.
I consider Spring's support for declarative transaction management on plain POJOs a very viable alternative to local SLSBs that are just used for declarative transactions (which assumably more than 90 percent are). It's easier to configure (without additional deployment steps) and particularly easier to test (without an EJB container). And it provides more options, like configurable isolation levels, association of Hibernate Sessions and JDO PersistenceManagers with managed transactions, etc.
As a side note, Spring's generic AOP support allows for security check interceptors and even instance pooling invokers if you really need those. In almost all scenarios, singleton business objects with a transactional proxy are perfectly sufficient. Spring also provides support for exposing existing business objects as remote services (out-of-the-box for Caucho's Hessian and Burlap web service protocols), but without transaction propagation.
So all things considered: I recommend Spring-managed business objects for all local transaction needs, completely replacing local SLSBs. Note that those business objects do not have to be aware of Spring at all, allowing for easy reuse in other environments. But if you need internal distribution at the component level, particularly with remote transaction propagation, I still recommend remote EJBs.
Juergen