Dependency injection is certainly one of the most effective design patterns for writing clean, maintainable and testable code.

For these reasons it's been very popular over the past few years and a number of libraries/frameworks have been created to provide support for dependency injection. The most well known implementations are probably Google Guice, the Spring Framework and the OSGi Service Registry while Dagger is possibly the most recent yet significant addition to this group.

A standardization effort in dependency injection began in 2006 which resulted in JSR 299 first and then in JSR 330, now supported by Guice and Spring which changed their API to comply with the proposed specification.

So what is the best choice today for those who want to use dependency injection in their code? Well, in my humble opinion the answer is.... Eclipse Sisu!. The Sisu home page describes Sisu as
"a modular JSR330-based container that supports classpath scanning, auto-binding, and dynamic auto-wiring. Sisu uses Google-Guice to perform dependency injection and provide the core JSR330 support, but removes the need to write explicit bindings in Guice modules." 
The project is still in incubation phase, and the documentation is not yet complete, but after playing with Sisu for some time, I can state that it is an excellent product, one of those rare Java libraries that focus on doing just one thing but do that thing exceptionally well. The code itself is very well written and an interesting reading for every Java developer (apart from the unusual C-like formatting :-)).

Sisu is the type of middleware component you would normally expect to find at Apache.org, and the fact that its actually hosted at Eclipse foundation may be yet another indication that Apache is no more as succesful as it used to be.

Here are some great features of Sisu:
  • Sisu can be used in both a Java SE environment and in an OSGi environment, and dependency injection becomes as simple as annotating relevant classes and letting Sisu magically discover them via class file scanning, or providing an index file.
  • No knowledge of Google Guice is required, but usage of the Google Guice API is supported.
  • Not only OSGi support is first class, but the author has also set the goal of integrating Sisu with the Equinox Registry and the OSGi Service Registry. Once accomplished this will bring a single, unified programming model helping portability between JavaSE and OSGi. 
Download Sisu now and start experimenting with it, chances are you'll be really amazed!