CDI 2.0 is the next version of Contexts and Dependency Injection for the Java EE Platform, and a candidate for inclusion in Java EE 8. It’s been a work in progress since September 2014, and things are moving pretty rapidly.

Major goals for CDI 2.0

  • Alignment with Java SE 8 (of course!).
  • Support for Java SE – Standardizing a Dependency Injection API for Java SE. Individual CDI implementations (Weld, etc.) do have support for Java SE, but one needs to resort to vendor specific ways in order to work with these. This would hopefully be resolved and we will have a standard API for working with CDI on Java SE and EE.
  • CDI Modularity – splitting up CDI into easily manageable modules to make things easier both from a maintenance as well as an adoption/implementation perspective.
  • Enhanced Events – one of the major enhancements is the introduction of Asynchronous Events, which was not there up until now (CDI 1.2).
  • Other features – AOP (interceptor & decorators) and SPI related enhancements.

It’s still very early days and nothing is set in stone as of yet. Things are evolving and will continue to do so. All the latest updates can be accessed on the official CDI spec page.

Open and structured working style

I have to say that, from a Java EE observer standpoint, I am particularly impressed by the way the CDI spec team is going about their work – in a very structured yet open fashion.

  • All the spec related work has been split up into high level topics (mentioned above).
  • There is a workshop corresponding to each one of them.
  • Each workshop (or work item) has a draft document which describes the related ideas, proposals and related details. The best part is that it’s out there for the community to read, respond and collaborate!

More details about the work mantra of the CDI spec team are available here, and the latest details of the individual work streams are available on CDI Spec home page (scroll down to the bottom of the page).

Note: Some discussions which are specific to the Asynchronous Events capability can be accessed here.

Cutting edge stuff – JBoss Weld 3 Alpha 3 release is here already

As many of you might already be aware, JBoss Weld is the Reference Implementation of the CDI spec. The great news is that Weld 3 Alpha 3 is already out there, and includes some of the features proposed in CDI 2.0.

Some of the CDI 2.0 related features supported in Weld 3 are:

  • Support for Asynchronous Events – now you can use  fireAsync(yourPayloadObject) and the call returns immediately.
  • Leveraging Java SE 8 features – you can now use repeatable annotations on qualifiers and interceptor bindings.
  • Prioritization of observer methods using @Priority.

For further details, check out this excellent write-up.

You can take Weld 3 for a spin on Wildfly 8.2. Just follow these instructions posted by Arun Gupta on his blog

Have fun living on the bleeding edge!

What’s New with Contexts and Dependency Injection 2.0?

| Server Side Java| 2,141 views | 0 Comments
About The Author
- • Consultant - Identity & Access Management • Java language and platform fanatic

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>