There are some key changes which are going to be part of EJB 3.1 . Some important changes are cataloged here
1) Session bean business interfaces are going to be optional. The intent is to bring the Session beans as close to POJO’s. Another advantage is that the it makes using EJB 3.1 beans easier to use in Web Beans (JSR 299).
2) Singleton Beans – These are the middleware equivalent of the GOF singleton pattern. These can be used to store shared application scope data. Although there are alternatives for caching shared data, the issue with these solutions is that they lack services like thread management, security, transaction management etc. Singleton beans being Enterprise beans have these services provided by the container. All singleton methods are assumed to be thread-safe and transactional(@Required). Thread safety can be changed using @ConcurrencyAttribute and transaction demarcation can be done the standard way transaction demarcation and transaction attributes. Concurrency management can also be managed at the bean level using @ConcurrenyManagement(BEAN) and synchronizing on methods you want to be thread-safe
3) Timer service – The main enhancements is the ability to trigger EJB methods using a cron like scheduling using the @Schedule. The bean method can be triggered based on seconds till the level of year.
4) EJB packaging — As of now, EJB’s need to go as a separate jar file. A typical ear contains a separate ejb-jar for an EJB and a war for the web app. However for simple applications, it would be possible to place the EJB’s directly in the war’s WEB-INF/classes to simplify the packaging process.
5) Asynchronous invocation of session beans- Although MDB’s provide the capability of using asynchronous invocations, it is an overkill for using for simple applications. You are forced to use messages and JMS even for very simple scenarios. With EJB 3.1, session beans can be invoked asynchronously.
6) EJB Lite — a subset of the EJB features based on the Java EE 6 profiles(ref –http://weblogs.java.net/blog/robc/archive/2008/02/profiles_in_the_1.html).
1. JSR 316: Java EE 6, http://jcp.org/en/jsr/detail?id=316.
2. JSR 318: Enterprise JavaBeans 3.1, http://jcp.org/en/jsr/detail?id=318.
3. JSR 299: Web Beans, http://jcp.org/en/jsr/detail?id=299.
4. Spring Pitchfork Project, http://static.interface21.com/projects/pitchfork/files/m4/docs/reference/html_single/.