Over a million developers have joined DZone.
Platinum Partner

The Coming of Java EE Extensions in JSR-299

· Java Zone

The Java Zone is brought to you in partnership with ZeroTurnaround. Discover how you can skip the build and redeploy process by using JRebel by ZeroTurnaround.

Final approval voting for the Java Contexts and Dependency Injection for the Java EE platform (aka JSR-299 and CDI) will finish today and the results will be published on December 10th.  Pete Muir, the project lead for the JSR-299 reference implementation, Weld, told DZone that the 299 spec will probably be approved by the JCP.  In a phone conversation with DZone, Muir said the JSR-299 specification will bring sweeping changes to the Java EE platform.  The spec will give Java EE "a massive boost," he says, by providing extensions for the Java EE space.  

The idea behind extensions, Muir says, is that you can very easily write and add functionality (e.g. excel spreadsheet generation and security modules) that will run in any container that supports JSR-299.  "One of the things that has been very difficult in Java EE before is to actually build extensions to the built-in functionality," said Muir.  Before JSR-299, he says, added functionalities were badly needed in the Java EE 6 application lifecycle.  "There was no way of knowing, for example, whether an application was starting or ending," said Muir.  "There was no way of knowing what Beans there were in the application and what classes were being deployed as part of the application."  Now, with JSR-299's complete Metadata SPI, developers can register lifecycle listeners and asked to be notified when events happen, such as start up/shut down, class processing, and bean creation.  "There's a lot of pretty powerful hooks into the Java EE platform as a result of these extensions," Muir says.

DZone asked Muir where JBoss got the inspiration for Java EE extensions.  Muir said, "CDI/299 took lessons we learned from developing Seam and designed a new contextual dependency injection engine based on this, as well as other frameworks like Guice. Seam also provided a lot of other extensions to the Java EE space, which we will continue to develop for Seam 3, and in fact offer these as portable extensions to any CDI environment."  Muir said the Seam security module is one example of an existing solution that could be added to Java EE through an extension.  This was a good example, he said, because the Java EE security module is powerful, but not easy to use.  Vendors won't be the only parties who build extensions through JSR-299, Muir said.  "Anybody can build an extension, you don't have to be a vendor or anything like that.  You can add extra functionality to the Java EE platform or you can, in fact, replace quite a lot of the core functionality with something that you think is better."  That's a lot of new power for developers.

Here are some major features of JSR-299 and it's RI, Weld:
                                                                                                                                 This is a candidate for the Weld logo
  • Wicket integration
  • A bundle for OSGi containers
  • GWT integration for Weld coming soon
Can be used in:
  • GlassFish V3
  • JBoss AS 5.2.0 Beta1
  • Java SE 5.0 and above
  • Tomcat 6
  • Jetty 6.1  (Muir says Jetty 7 hasn't been tested but it will likely work with that too.)

This specification defines a powerful set of complementary services that help improve the structure of application code.

  • A well-defined lifecycle for stateful objects bound to lifecycle contexts, where the set of contexts is extensible
  • A sophisticated, typesafe dependency injection mechanism, including the ability to select dependencies at either development or deployment time, without verbose configuration
  • Support for Java EE modularity and the Java EE component architecture - the modular structure of a Java EE application is taken into account when resolving dependencies between Java EE components
  • Integration with the Unified Expression Language (EL), allowing any contextual object to be used directly within a JSF or JSP page
  • The ability to decorate injected objects
  • The ability to associate interceptors to objects via typesafe interceptor bindings
  • An event notification model
  • A web conversation context in addition to the three standard web contexts defined by the Java Servlets specification
  • An SPI allowing portable extensions to integrate cleanly with the container

Pete Muir works at JBoss and is the lead developer for the Seam and Weld open source projects.  Download Weld, the reference implementation for JSR-299, here.

The Java Zone is brought to you in partnership with ZeroTurnaround. Discover how you can skip the build and redeploy process by using JRebel by ZeroTurnaround.


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}