Dependency Injection for Java
For several years both Google and SpringSource have provided dependency injection capabilities via their open source projects named Google Guice and the Spring Framework, respectively for several years. However, until recently there has been no standard, vendor-neutral way for developers to swap between these frameworks, or others, without having to update their source files. But, if things go according to plan some core dependency injection annotations and interfaces will make their way into the Java SDK.
Just a few weeks ago Google announced their partnership with SpringSource to,
standardize a proven, non-controversial set of annotations that make injectable classes portable across frameworks.
Earlier this week an official proposal, JSR 330: Dependency Injection for Java, was submitted to the JCP (Java Community Process). The proposal does indicate that the JSR targets the Java SE platform, minimally version 5, but aims to lay a foundation that will be useful for dependency injection in Java EE as well. The initial set of proposed annotations include:
-
@Inject – Identifies injectable constructors, methods, and fields.
-
@Qualifier - Identifies qualifier annotations
-
@Scope - Identifies scope annotations
-
@Named - String-based qualifier
-
@Singleton - Identifies a type that the injector only instantiates once
The entire process, from initial annotations to the submission of the JSR and beyond are said to be open to the public allowing for community feedback throughout. In fact, the community has voiced a lot of opinions on several blogs about the partnership, proposal and even the usefulness of the whole thing.
Included below is a poll to help gauge what the InfoQ community is thinking, so go ahead and vote, the results could be quite interesting.
Educational Content
Intro to CLP with core.logic
Ryan Senior Jun 18, 2013
Spock: A Highly Logical Way To Test
Howard Lewis Ship Jun 18, 2013
Java Garbage Collection Distilled
Martin Thompson Jun 17, 2013
C++11 The Future is Here
Bjarne Stroustrup Jun 16, 2013
The Big Data Revolution
Claudia Perlich Jun 16, 2013




Hello stranger!
You need to Register an InfoQ account or Login to post comments. But there's so much more behind being registered.Get the most out of the InfoQ experience.
Tell us what you think