Google/SpringSource: Joint "Dependency Injection for Java" proposal
Google and SpringSource have jointly proposed "Dependency Injection for Java" as a Java Specification Request, JSR 330 for the Java Specification Process (JCP). The difference between JSR 330 and JSR 299, Java Contexts and Dependency Injection, which is about to be released in its final version, is that JSR 299 focusses on Java EE (Enterprise Edition) while JSR 330 is aimed at Java SE (Standard Edition). Voting for acceptance of JSR 330 into the JCP process is due to close on June 8th.
JSR 299 is aimed at unifying the Enterprise Java Beans component model and is a complex specification designed to handle integration with the different tiers of an enterprise application. JSR 330, on the other hand, focusses on just the process of dependency injection, using a small number of annotations to allow all developers to make use of dependency injection in desktop applications. Both Google and SpringSource already have their own Java-based "Dependency Injection" frameworks; Google's Guice and SpringSource's Spring framework.
Dependency Injection (DI) is a pattern that deals with the problem of having too many direct dependencies between objects in large applications. A developer can, instead of hard wiring in a object that a class needs, add an
@inject annotation saying that the code depends on another object. The mechanism then works out what will fulfil that dependency and injects the result into the code at runtime.
The spec lead for JSR 299, Gavin King of Red Hat, has raised a number of issues about JSR 330, suggesting that it duplicates work done in JSR 299 and is incomplete as it doesn't handle "external dependencies". A heated discussion has ensued between King and Bob Lee, founder of Google's Guice project over this subject and it is likely that there will be further controversy within the Java developer community over the progress of JSR 330.