My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
Bindings  
Overview of bindings in Guice
Updated Oct 16, 2011 by sberlin

Bindings

The injector's job is to assemble graphs of objects. You request an instance of a given type, and it figures out what to build, resolves dependencies, and wires everything together. To specify how dependencies are resolved, configure your injector with bindings.

Creating Bindings

To create bindings, extend AbstractModule and override its configure method. In the method body, call bind() to specify each binding. These methods are type checked so the compiler can report errors if you use the wrong types. Once you've created your modules, pass them as arguments to Guice.createInjector() to build an injector.

Use modules to create linked bindings, instance bindings, @Provides methods, provider bindings, constructor bindings and untargetted bindings.

More Bindings

In addition to the bindings you specify the injector includes built-in bindings. When a dependency is requested but not found it attempts to create a just-in-time binding. The injector also includes bindings for the providers of its other bindings.

Comment by gzanu...@b-vision.com, Mar 15, 2012

Really is very good framework, is simple to use and powerful at the same time


Sign in to add a comment
Powered by Google Project Hosting