Skip to content

DependencyInjection

Michal Durdina edited this page Jan 20, 2015 · 1 revision

Dependency injection containers

The aim of this article is to provide overview of capabilities and also differences between various dependency injection containers. To save space there will be no introduction to neither dependency injection not to any of the containers discussed. So let's start.

Configuration style

All of the containers nowadays use Java based configuration. This style benefits from type checking and lot of expressivity that allows less boilerplate.

Typical Java Based configuration in Guice:

public class SomeModule extends AbstractModule {

    public void configure() {
        bind(SomeInterface.class).to(SomeImplementation.class).in(Scopes.SINGLETON);
    }

    @Provides
    SomeOtherInterface myFactory() {
        return new SomeOtherImplementation();
    };

}

Clone this wiki locally