Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Updates on CDI 2.0

DZone's Guide to

Updates on CDI 2.0

· Java Zone ·
Free Resource

Get the Edge with a Professional Java IDE. 30-day free trial.

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 is being worked upon since September 2014 and 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 adoption/implementation perspective
  • Enhanced Events – one of the major enhancements is introduction of Asynchronous Events which was not there up until now (CDI 1.2).
  • Other features – AOP (interceptor & decorators) and SPI related enhancements

It is 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

Have to say that from a Java EE observer standpoint, I am particularly impressed by the way the CDI spec team is going about its 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 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 be already aware of, JBoss Weld is the Reference Implementation of the CDI spec. Great news is that Weld 3 Alpha3 is already out there and includes some of the features proposed in CDI 2.0 !

All in all, 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 byArun Gupta on his blog

Have fun living on the bleeding edge!
Cheers :-)

Get the Java IDE that understands code & makes developing enjoyable. Level up your code with IntelliJ IDEA. Download the free trial.

Topics:

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}