CDI tagcloud

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.

CDI 1.2 and Weld 2.2

2014-2-4: Jozef Hartinger

Work on a maintenance release of the CDI specification (CDI 1.2) has started recently. Now is the best time to add feedback on issues being addressed. Most of the discussion happens in the cdi-dev mailing list or the IRC channel.

Weld 2.2 is going to be the reference implementation of CDI 1.2. Besides implementing the changes introduced in the maintenance release, we are going to focus on improving non-functional characteristics in this release of Weld:

  • bootstrap time

  • memory footprint

  • throughput

  • maximum number of concurrent clients

  • session replication overhead

Today, we released Weld 2.2.0.Alpha1. The most significant changes include:

  • Added new SPI that allows bytecode-scanning frameworks (such as jandex) to be integrated. This yields improved bootstrap time especially with large deployments.

  • Reduced memory consumption (our tests show 6-12% less memory used after bootstrap with large deployments)

  • Improved event/observer performance

  • Java Web Start support finally got in (thanks to Alexandre Gattiker for the patch!)

  • Improved Servlet container support (Jetty 9.1, ServletContainerInitializer used to bootstrap Weld, Tomcat 8 support)

  • A new Groovy example (groovy-numberguess) was added

  • Many other bug fixes and improvements. See the release notes for a complete list of changes

Now, we continue to work on Weld 2.2. Expect the final version in late March. In the meantime, try this release and let us know what you think in the forum. If you are interested in Weld make sure you check our community page or the list of open issues awaiting contribution.

Three new Weld releases

2014-1-14: Jozef Hartinger

This week we are releasing three new builds of Weld. Firstly, Weld 2.1.2.Final was released. This is a bug-fixing release with 11 issues resolved. Most notably:

  • The conversation context is now initialized lazily. This resolves the problem with custom character encoding that many of you run into. See the reference documentation for details.

  • Weld now runs fine on JDK8

  • Jetty 9.1 is now supported by weld-servlet

In addition, Weld 1.1.17.Final (CDI 1.0) was released with several bug fixes.

Last but not least, there was a memory leak identified in GlassFish caused partly by GlassFish and partly by Weld. GlassFish still uses Weld 2.0. Although we do not maintain the 2.0 branch any longer and advice everyone to upgrade to Weld 2.1, the memory leak may be a problem for GlassFish users that are not able to upgrade to Weld 2.1 themselves. Therefore, we decided to do one more 2.0 release where this problem is fixed so that GlassFish users stuck on Weld 2.0 have an easy fix. Enjoy Weld 2.0.5.Final!

Now, our focus shifts completely towards Weld 2.2 where performance optimization and lowering memory consumption are the main goals. Expect first Alpha of Weld 2.2 by the end of January.

If you are interested in Weld make sure you check our community page or the list of open issues awaiting contribution.

Weld 2.1.1.Final

2013-12-11: Jozef Hartinger

Weld 2.1.1.Final was released. More than 20 issues were addressed in this release. See the release notes for details. Thanks to everyone involved in this release!

Weld 2.1.0.Final

2013-10-22: Jozef Hartinger

I am pleased to announce that Weld 2.1.0.Final has just been released. Weld is the reference implementation of Contexts and Dependency Injection for Java EE (CDI). Here is the highlight of what’s new in Weld 2.1.0:

  • OSGi support with Pax CDI

  • Improved runtime performance and memory consumption

  • Better integration with various Servlet dispatch types

  • SLF4j was replaced with jboss-logging

  • 30 fixed bugs

The future of Weld-OSGi

Weld-osgi is a framework that allows the CDI programming model to be used in the OSGi environment. The framework was developed entirely by the Weld community and became a part of Weld since version 1.2.0

The framework provides three main features:

  1. The CDI programming model can be used within OSGi bundles.

  2. The OSGi service layer and utility facilities are accessible through CDI injection

  3. The CDI event bus can be used for both inter-bundle communication and delivering OSGi events.

The weld-osgi framework served as an inspiration for a standardization effort, known as RFC-193 (formerly RFP-146). The proposal is now part of the OSGi early draft

Due to the tight schedule of CDI 1.1, weld-osgi did never make it to Weld 2.0 and was therefore left behind, stuck in the gradually abandoned 1.2 branch.

In the meantime, work on the reference implementation of RFC-193 begun. The reference implementation is known as Pax CDI and it is an open-source project hosted on GitHub. Pax CDI aims to be portable across OSGi implementations as well as CDI implementations.

We always wanted to bring OSGi support back in Weld 2.1. However, we decided not to revive the weld-osgi framework nor align it to the new RFC-193 specification. Therefore, weld-osgi will not be merged into Weld 2.x code base. Instead, we decided to shift our focus towards Pax CDI and make sure it works well with Weld. This was done and Weld 2.1.0 is now one of the CDI runtimes supported by Pax CDI. You can play with the current Pax CDI SNAPSHOT or wait for the upcoming 0.5 release.

EDIT 2013-10-30: Pax CDI 0.5.0 was released. See the release announcement for more details.

Performance

The CDI specification requires the request, conversation and application contexts to be active during every HTTP request. Obviously, the CDI contexts are not necessary for every HTTP request. Fetching a static resource is an example of one such request.

In Weld 2.1.0 we optimized the component that handles context activation/deactivation and cut down the overhead. In addition, it is now possible to completely suppress CDI context activation on certain types of HTTP requests should this minimized overhead still be undesired. See Martin’s blog post or the reference documentation for more details.

Acknowledgement

We greatly appreciate your contributions to this release. Big thanks go to: Martin Kouba, Matúš Abaffy, Matej Briškár, Marko Lukša, Stuart Douglas, Marek Schmidt, Ron Šmeral, Tomáš Remeš, Max Pimm, Jesse McConnell, Harald Wellmann and Dirk Strauss.