Weld 2.2 (CDI 1.2 reference implementation) released!

2014-4-15   Jozef Hartinger

Today we released Weld 2.2.0.Final - the reference implementation of Contexts and Dependency Injection for Java EE 1.2 (CDI 1.2). Besides implementing the changes in the specification, this release comes with several new features, performance improvements and more than 50 bug fixes.

CDI 1.2

CDI 1.2 is a maintenance release of the CDI specification. It contains a number of small fixes and clarifications as well as several enhancements. Most notable changes for application developers are related to the definition of bean defining annotations.

In CDI 1.2, the set of bean defining annotations now contains:

  • all the normal scope annotations (e.g. @RequestScoped, @ApplicationScoped, …​)

  • the built-in @Dependent scope

  • @Interceptor and @Decorator annotations

  • stereotype annotations

As a result, any class annotated with a bean defining annotation is by default recognized by the application server and registered as a CDI bean. The beans.xml file is optional.

In addition, there are other fixes, clarifications and minor enhancements in this maintenance release of the CDI specification. See the release notes for the complete list of changes.

Performance

Weld is now capable of using bytecode-scanning utilities, such as the Jandex tool, to speed up deployment. This is especially notable in extra large deployments (e.g. 5000+ classes) where we observed up to 20% faster deployment.

In addition, there are noticeable improvements in the following areas:

  • runtime performance of observers, interceptors and decorators

  • session replication overhead (failover)

  • memory consumption

Weld 2.2 on WildFly

WildFly does not come with Weld 2.2 support yet. It is however easy to patch an existing WildFly installation to use Weld 2.2.

To do so, follow these steps:

  1. Download a patch appropriate for the WildFly version (e.g. 8.0.0.Final) from the download section

  2. In the WildFly installation, run the CLI console

    sh jboss-cli.sh
  3. From the console run the following command:

    patch apply /path/to/wildfly-8.0.0.Final-weld-2.2.0.Final-patch.zip

Your installation is now patched!

Weld SE and Servlet

Weld comes with the SE module which allows CDI to be used in plain Java SE environment. In Weld 2.2 we added partial support for implicit bean archives. Partial support here means that the beans.xml file is still required, but bean-discovery-mode=”annotated” can be specified for Weld to only discover classes explicitly annotated with bean defining annotations (see above).

In addition to the Weld SE module, Weld also provides the Weld Servlet module which makes it possible to use Weld on top of a plain Servlet container, such as Apache Tomcat or Jetty.

In this release we simplified configuration by bootstrapping Weld using the ServletContainerInitializer.

Furthermore, Weld Servlet now supports Jetty 9.1. At the same time, the support for Tomcat 6 was dropped. To summarize, Weld Servlet is currently supported on the following Servlet containers:

  • Tomcat 7, 8

  • Jetty 7, 8, 9.0, 9.1

Acknowledgement

We greatly appreciate your contributions to this release. Big thanks go to: Martin Kouba, Matúš Abaffy, Matej Briškár, Ron Šmeral, Marek Schmidt, Marko Lukša, Tomáš Remeš, Stuart Douglas, Radoslav Husár, Max Pimm, Alexandre Gattiker, Antonin Stefanutti and Steve Moyer.