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 java.lang.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:

 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);
     bind("port").to(8080);
   }
 }
 

Author:
crazybob@google.com (Bob Lee)

Constructor Summary
AbstractModule()
           
 
Method Summary
protected
<T> ContainerBuilder.BindingBuilder<T>
bind(java.lang.Class<T> clazz)
           
protected
<T> ContainerBuilder.BindingBuilder<T>
bind(Key<T> key)
           
protected  ContainerBuilder.ConstantBindingBuilder bind(java.lang.String name)
           
protected
<T> ContainerBuilder.BindingBuilder<T>
bind(TypeLiteral<T> typeLiteral)
           
protected  void bindProperties(java.util.Map<java.lang.String,java.lang.String> properties)
           
protected  void bindProperties(java.util.Properties properties)
           
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(java.lang.Class<?>... types)
           
protected  void scope(java.lang.String name, 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(java.lang.String name,
                     Scope scope)
See Also:
ContainerBuilder.scope(String, 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(java.lang.Class<T> clazz)
See Also:
ContainerBuilder.bind(Class)

link

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

bind

protected ContainerBuilder.ConstantBindingBuilder bind(java.lang.String name)
See Also:
ContainerBuilder.bind(String)

bindProperties

protected void bindProperties(java.util.Map<java.lang.String,java.lang.String> properties)
See Also:
ContainerBuilder.bindProperties(java.util.Map)

bindProperties

protected void bindProperties(java.util.Properties properties)
See Also:
ContainerBuilder.bindProperties(java.util.Properties)

requestStaticInjection

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

install

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