Java EE 6 Proposed Final Draft Hints at Future Direction of the Platform
The expert group for JSR-316 (Java EE 6) recently released a proposed final draft for the specification. Three significant changes since the early review draft are the additions of JSR-330 (Dependency Injection for Java), JSR-299 (Contexts and Dependency Injection for the Java EE Platform hereafter referred to as "CDI"), and JSR-303 (Bean Validation) as required components to both the full platform and the web profile. To align CDI with JSR-330 a second proposed final draft has been submitted for the former which re-uses the dependency injection annotations as defined by JSR-330, adds constructor injection for EJB session beans and makes some other minor changes.
The expert group has also added a specification document for managed beans in addition to the web profile and full specification documents they were already producing. Managed beans, which are Java classes treated as managed components by a container, are a widely used concept shared by both CDI and JavaServer Faces. In addition the introduction of EJB Lite, which allows EJB session beans to be used outside of a full Java EE container, means that three variants of the concept exist within the Java EE platform alone. Similar concepts exist on other widely used frameworks such as Spring and Seam. Managed beans support a small set of basic services such as resource injection, lifecycle callbacks and interceptors. Other specifications can build on this definition and add other services, so for example CDI adds dependency injection, EJB session beans add transactions, remoting, and so on. Writing on his blog Roberto Chinnici provides the following example:
Given a JAX-RS resource class, you can turn it into a managed bean by adding a @ManagedBean annotation, or an EJB component annotation (@Stateful) or one of many potential CDI annotations (e.g. the @Default qualifier). What's more, one can also take the opposite view, and see the resulting class as coming from a managed bean or an EJB component that has been turned into a JAX-RS resource class by the addition of a JAX-RS @Path annotation. The same thing can be done with a servlet, or a JAX-WS endpoint class, or (mostly) any other component type in Java EE 6.
Whilst the managed bean specification is currently small in scope, it is significant in that it indicates the overall direction of travel which Sun envisages for the EE platform as a whole. Whilst further refactoring will be required to make the entire Java EE platform work this way, it isn't difficult to see how the combination of managed beans and the annotation-based programming model introduced in version 5 of the EE Platform will ultimately allow developers to pick and choose from any of the services offered by the EE container on any component. At the same time, the simple managed bean model complements the existing set of extensibility points and service provider interfaces within the platform, providing a standardised mechanism for Java framework and product developers to cleanly layer on top of the platform; a major goal for EE 6.
Sun's GlassFish version 3 is likely to be the first application server to offer full platform support and previews for it are already available. The next beta of JBoss 5.2 will include some EE 6 support including JavaServer Faces (JSF) 2.0, Java Persistence (JPA) 2.0, Bean Validation and the new version of CDI. SpringSource are also supporting parts of the new standard. Spring 3.0 includes support for JSF 2.0, JPA 2, Bean Validation and JSR-330. Future 3.x releases of Spring are expected to support other EE 6 APIs, including Servlet 3.
In terms of IDE support NetBeans 6.8 will include support for JSF 2.0 including Facelets, JPA 2.0, and incremental deployment with GlassFish version 3. The milestone 2 release is currently available for download. JetBrains are also tracking EE 6 closely and IntelliJ IDEA 9 is expected to support JPA 2.0, EJB 3.1, JSF 2.0, Servlet 3, CDI and Bean Validation, as well as GlassFish 3.
CDI Reference Implementation
The reference implementation is used in GlassFish V3 and the upcoming JBoss AS 5.2.0.Beta1 release (watch Jason's blog for details!). Our implementation also adds support for Servlet containers such as Tomcat and Jetty. Furthermore you could choose to use Wicket as your view layer, or perhaps Swing via the Java SE support. If you are using an OSGi container, there's a bundle for that too! If you are getting started, there are a few examples in the distribution to guide you. If you are looking for help, try our forums, or perhaps join us on IRC.
Re: CDI Reference Implementation
and the upcoming JBoss AS 5.2.0.Beta1 release
About that specially, shouldn't it be released already? I seem to remember it being planned for the 15th of this month. Of course I don't want to sound impatient, but just wondering ;)
I'm greatly looking forward to all this new stuff. Java EE 6 really got me exciting again about development. Can't wait to try some of the stuff in Jboss AS 5.2. Keep up the good work guys!
In terms of IDE support NetBeans 6.8 will include support for JSF 2.0 including Facelets, JPA 2.0 [...] JetBrains are also tracking EE 6 closely and IntelliJ IDEA 9 is expected to support JPA 2.0, EJB 3.1, JSF 2.0, Servlet 3, CDI and Bean Validation
It seems Eclipse is a little behind here. To the best of my knowledge, both WTP and MyEclipse are still struggling with full support for Java EE 5...
Todd Montgomery Dec 19, 2014