I, like many others, have drifted away from EJB after some early experience. Even before the advent of lightweight containers, I found myself finding other mechanisms for putting together distributed systems (largely because of the number of pieces I had to manage with the EJBs). I understand that EJB3 has made inroads into the number of artifacts required (via extensive use of annotations) but is it enough to make me take another look at EJB?
I'm curious what arguments the authors of EJB In Action would make to developers who have other options now. What does EJB offer over the competition these days? Why should I consider looking at it again?
I don't think it's EJB 3 vs Spring or Java EE vs Spring. Hoowevr like other EJB 3 books we have not closed our mind and preach EJB 3 and do not utter a word about Spring. We strongly believe It's about building effective applications using EJB 3 (or whatever ) technology makes sense to you?
Do you know that Spring has built integration with JPA and also implemented partial features of EJB 3 as part of Pitchfork project?
Our book is about EJB 3 and the Java Persistence API. It's about learning EJB 3 and effectively using it even if with Spring 2.0. We have covered in the cases when EJB 3 makes sense and suggest you to consider Spring when it's makes sense.
As you can imagine, as an EJB 3 author it isn't really "politically correct" to talk about EJB 3 as a direct competitor to other technologies, particualrly Spring. As Debu hinted though, what technology stack you choose is largly dependent on what is important to you. Throughout the book, we've mentioned cases where EJB 3 has advantages, where Spring has advantages and where integrating both is a great idea. In short, EJB 3 definitely makes the EJB technolgy a viable choice again.
Here are some pros to using EJB 3: 1. As you mentioned, EJB 3 gets rid of the number of artifacts necessary for development. 2. With EJB 3, you have the option of using either XML or annotations, annotations being a lot less labor-intensive than verbose XML. 3. Becuase EJB is a total standards based platform, you get all enterprise services at your finger-tips without having to do a ton of configuration yourself (case in point--declarative transaction management in Spring vs. EJB3; another case in point, out of the box messaging, remoting and web services capabilities). 4. EJB 3 "seamlessly" (no pun intended) integrates with presenation tier technologies like JSF and Servlets. 5. Intelligent defaulting for most features makes enterprise development a lot of fun. This is generally not true of Spring. 6. A compelling state management model in stateful session beans. This is especially true if you are using JBoss seam.
Here are some strengths unique to Spring: 1. Much more robust AOP support. 2. If you make heavy use configuration through injecting collections, strings and so forth, Spring has better support for that. 3. Spring is more extensible if you happen to want to make changes to the container's behaviour or core functionality. 4. If you like tinkering with the nuts and bolts of a "container" or happen to have very complex application requirements, such as having fine-grained control over transactions, security, remoting, choice of persistence mechanism and so on, Spring is a better choice.