I've been heads down the last week working on an assignment to give my Large Scale Distributed Systems class. Normally, I wouldn't spend that much time on any given assignment, but I wanted the assignment to be based on EJB3.0 and this was my first exposure to the new specification.
JBoss supports EJB3.0 in version 4 of their server, but you have to add in some additional JAR files to make it work. I'm not familiar with the level of support for EJB3.0 in other application servers. If you know something, leave a comment.
As I said, I've only been playing with EJB3.0 for a few weeks, but I have a few initial reactions:
- First and foremost, the beans in EJB3.0 are significantly less complex. Entity beans are just plain old Java objects (POJOs) and the container manages the mapping of these objects to a relational database and the persistence of POJOs to the database. For example, the interfaces for EJBs do not have to implement EJBObject or EJBLocalObject. In addition, lifecycle methods like ejbPassivate, ejbActivate, ejbLoad, ejbStore, etc. are no longer required.
- The metadata annotation feature of Java 1.5 is put to use in annotating entity and session beans to give hints as to the behaviors that you want from the bean. In the past I've used XDoclet to simplify bean building, but EJB3.0 doesn't require it because of the annotations.
- While I've not done any performance tests, they seem faster. Now in addition to moving to EJB3.0, I also moved from JBoss 3 to JBoss 4 and that could be the difference.
- The change to POJOs for entity beans has been advertised as Hibernate in EJB, but you don't feel like you're using Hibernate; the connection is more conceptual than anything else. I've only used the mapping from entity objects to the relational table, not the other way around.
- Documentation is sparse. There's been lots of questions that I've had trouble finding answers to. I'm sure that will change. As long as your application follows the few examples fairly closely, you'll be able to gather what to do from them, but that only goes so far.