com.google.inject
Class AbstractModule

java.lang.Object
  extended by com.google.inject.AbstractModule
All Implemented Interfaces:
Module
Direct Known Subclasses:
ServletModule

public abstract class AbstractModule
extends Object
implements Module

A support class for Modules which reduces repetition and results in a more readable configuration. Simply extends this class, implement configure(), and call the inherited methods which mirror those found in ContainerBuilder. For example:

 import static com.google.inject.Names.named;

 public class MyModule extends AbstractModule {
   protected void configure() {
     bind(Foo.class).to(FooImpl.class).in(Scopes.CONTAINER);
     bind(BarImpl.class);
     link(Bar.class).to(BarImpl.class);
     bindConstant(named("port")).to(8080);
   }
 }
 

Author:
crazybob@google.com (Bob Lee)

Constructor Summary
AbstractModule()
           
 
Method Summary
protected
<T> ContainerBuilder.BindingBuilder<T>
bind(Class<T> clazz)
           
protected
<T> ContainerBuilder.BindingBuilder<T>
bind(Key<T> key)
           
protected
<T> ContainerBuilder.BindingBuilder<T>
bind(TypeLiteral<T> typeLiteral)
           
protected  ContainerBuilder.ConstantBindingBuilder bindConstant(Annotation annotation)
           
protected  ContainerBuilder.ConstantBindingBuilder bindConstant(Class<? extends Annotation> annotationType)
           
protected  ContainerBuilder builder()
          Gets the builder.
protected abstract  void configure()
          Configures a ContainerBuilder via the exposed methods.
 void configure(ContainerBuilder builder)
          Contributes bindings and other configurations to a container builder, so that the resulting Container will include this module properly set up.
protected  void install(Module module)
           
protected
<T> ContainerBuilder.LinkedBindingBuilder<T>
link(Key<T> key)
           
protected  void requestStaticInjection(Class<?>... types)
           
protected  void scope(Class<? extends Annotation> scopeAnnotation, Scope scope)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractModule

public AbstractModule()
Method Detail

configure

public final void configure(ContainerBuilder builder)
Description copied from interface: Module
Contributes bindings and other configurations to a container builder, so that the resulting Container will include this module properly set up.

Specified by:
configure in interface Module

configure

protected abstract void configure()
Configures a ContainerBuilder via the exposed methods.


builder

protected ContainerBuilder builder()
Gets the builder.


scope

protected void scope(Class<? extends Annotation> scopeAnnotation,
                     Scope scope)
See Also:
ContainerBuilder.scope(Class, Scope)

bind

protected <T> ContainerBuilder.BindingBuilder<T> bind(Key<T> key)
See Also:
ContainerBuilder.bind(Key)

bind

protected <T> ContainerBuilder.BindingBuilder<T> bind(TypeLiteral<T> typeLiteral)
See Also:
ContainerBuilder.bind(TypeLiteral)

bind

protected <T> ContainerBuilder.BindingBuilder<T> bind(Class<T> clazz)
See Also:
ContainerBuilder.bind(Class)

link

protected <T> ContainerBuilder.LinkedBindingBuilder<T> link(Key<T> key)
See Also:
ContainerBuilder.link(Key)

bindConstant

protected ContainerBuilder.ConstantBindingBuilder bindConstant(Class<? extends Annotation> annotationType)
See Also:
ContainerBuilder.bindConstant(Class)

bindConstant

protected ContainerBuilder.ConstantBindingBuilder bindConstant(Annotation annotation)
See Also:
ContainerBuilder.bindConstant(java.lang.annotation.Annotation)

install

protected void install(Module module)
See Also:
ContainerBuilder.install(Module)

requestStaticInjection

protected void requestStaticInjection(Class<?>... types)
See Also:
ContainerBuilder.requestStaticInjection(Class[])