BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Dependency Injection for Java

Dependency Injection for Java

Leia em Português

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.

 

 

Rate this Article

Adoption
Style

BT