BT

Dependency Injection for Java

by Craig Wickesser on May 21, 2009 |

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.

 

 

Hello stranger!

You need to Register an InfoQ account or 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

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

A critical note on this from Rickard Öberg (Blog-Link) by Georg Ragaller

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

1 Discuss

Educational Content

General Feedback
Bugs
Advertising
Editorial
InfoQ.com and all content copyright © 2006-2013 C4Media Inc. InfoQ.com hosted at Contegix, the best ISP we've ever worked with.
Privacy policy
BT