Skip to content


EJB pro and con

Recent days I’ve been studying EJB 3.0, with help of the book EJB in Action by Manning. Today, I got into a small discussion about what EJB delivers. As a newbie with no real practical experience, some advantages still quickly come to mind:

  • EJB is a specification, not only an API. It’s also a way you should develop your application. It provides well proven best practices and specific roles for each component in the application.
  • EJB provides real enterprise scalability with zero extra implementation and very limited configuration. I’ve used Terracotta, and although this is very easy, it still requires know-how and extra byte code instrumentation in order to work. EJB provides out of the box clustering, pooling of business beans, security and AOP functionality.
  • EJB integrates natively with major technologies like JMS, JSP, JCA and JAAS. Security and transactional management comes free.
  • Exposing EJB remotely is only 1 annotation away (@Remote and @WebService)
  • Vendor support and interchangeability: since EJB is a specification, not an implementation, multiple vendors are available. Switching between them should, on paper, be easy. Vendor independence can be very important if the application will be maintained and expanded for a longer period of time.

Disadvantages in my humble eyes:

  • Integration tests: since EJB requires in container testing for Dependency Injection, it has to load the entire application (or I’m still missing something). This is for me a serious drawback. Unit testing on the other hand is easily done the beans are simple POJO’s.
  • EJB requires configuration from the application server side. This, for me, is rather new. I’m used to Spring applications where the war/ear defines the application.
  • EJB misses some graceful solutions to common problems, something Spring does a lot better. I’m thinking about DbUnit integration when running tests, Reflection utils, accessing remote web services (not only SOAP), integration with LDAP, Quartz, JMX, etc etc…

I truly believe there is a lot to like in the EJB 3.0 specification. Then again, I’m not willing to sacrifice every advantage of Spring. Luckily their are already efforts on integrating the two. Using EJB for as much as possible and Spring to integrate the wide array of other frameworks is the way for me.

Andries

Posted in Uncategorized.

Tagged with .


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.

 



Improve Your Life, Go The myEASY Way™