Updates on CDI 2.0
Updates on CDI 2.0
Join the DZone community and get the full member experience.Join For Free
Distribute microservices between the private and public clusters, yet maintain bi-directional connectivity. Content provided by IBM Developer.
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.
Have fun living on the bleeding edge!
Published at DZone with permission of Abhishek Gupta , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.