Today we had the first conference day at DEVOXX, the European JAVA meeting. The key note was, as usual, dedicated to new evolutions in the JAVA world. One of these topics was the new JAVA EE 6.0
The new and noteworthy in JAVA EE 6.0
The master words for describing the SUN effort are flexibility, modularity and extensibility. A lot of new things comes from the OSGI orientation of the JEE specification.
The final JEE 6.0 is planned for December 10 2009 and Glassfish is still the official reference implementation. The new features are:
- A new set of API
- The Web profile
- Dependency injection
- Improvement of existing API
A REST FULL Web service API which is annotation-based enables to call and receive REST request.
Bean validation API
Bring the concept of JSF validation within the EJB and completely integrated with JSF and JPA.
@NotNull String name;
@size(Max=40) String address
Or even custom one @email String mail; on which the developer can define its own constraint.
The Web profile
Who has never said something like “when I create a JEE application do I need to load the whole JEE framework, isn’t too heavy, just for a web app?”. The idea behind the web profile is to provide, just and only, the set of J2EE components needed for Web development. However, in this profile you will find a lot of JSRs such as:
- Servlet 3.0
- JavaServer Pages (JSP) 2.2
- ExpressionLanguage (EL) 2.2
- Debugging Support for Other Languages (JSR-45) 1.0
- Standard Tag Library for JavaServer Pages (JSTL) 1.2
- JavaServer Faces (JSF) 2.0
- Common Annotations for Java Platform (JSR-250) 1.1
- Enterprise JavaBeans (EJB) 3.1 Lite
- Java Transaction API (JTA) 1.1
- Java Persistence API (JPA) 2.0
Apache  gives this definition of web profile: “The JEE 6 web profile is a specified minimal configuration targeted for small footprint servers that support “typical” web applications.”
Modular web applications
There are several interesting things in the new modular approach of the specification manly all based around the new OSGI integration. Indeed, OSGI is in the core of the new JEE specification. We can cite the notion of library which can be a web fragment, a part of a web application. In addition, a simple OSGI bundle which expose a service can be injected directly in a JEE component such as a servlet or a managed-bean. That’s really a great improvement.
We can also cite the notion of ServeltContainerInitializer which aims the developer to look-up into the different application components to browse the annotation for registration services or resources for instance.
That’s nothing else than the JSR 299 and JSR 330.
A bunch of new annotation such as @Resource Datasource myDB; or even @inject @Loggedin User user.
We can see that the specification tends to get close to frameworks such as Seam or Spring. However, Seam still defines the concept of outjection and the concept of conversation which is not yet defined in the specification.
We can not really speak about revolution; instead I would speak about completeness of the specification.
We can find new annotations such as:
@Singleton, this can be seen as strange in a world who always speaks about multi core, grid and cloud.
@Asynchronous for asynch invocation.
The new interesting thing is that the EJB container can run on JAVA SE! Before, we used to have a JEE container for testing, today EJB can be tested locally with a simple JRE. In addition it means that SE applications can, for instance, instantiate Enterprise beans and benefit of the transactional API.
Finally the key note finished on a demo of a preview of Glassfish V3. The demo (From Eclipse) highlighted several interesting things:
- The re-deploy with session preservation. This means that you can re-deploy your web application while preserving your current sessions and contexts.
- The injection of a service exposed by a pure OSGI bundle into a servlet. That’s a real promising feature. The bundle jar file has just to be copied in a special directory of the AS and it can be directly injected into a servlet by “@Resource(“service name”) ServiceInterface myService”.
The JEE 6.0 has been designed in the aim to be modular, flexible and extensible and OSGI has a central place in theses three terms. As a result the container is becoming lighter and more efficient. The real objective is to get back all developers gone for Spring or other lighter Enterprise frameworks.
 JBoss Seam, http://jbpm.org
 The Glassfish project, https://glassfish.dev.java.net
 Apache Geronimo Roadmap, http://cwiki.apache.org/GMOxDEV/road-map-for-jee6-web-profile.html