com.google.inject
Class AbstractModule

java.lang.Object
  extended by com.google.inject.AbstractModule
All Implemented Interfaces:
Module

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 extend this class, implement configure(), and call the inherited methods which mirror those found in Binder. 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.SINGLETON);
     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  void addError(java.lang.String message, java.lang.Object... arguments)
           
protected  void addError(java.lang.Throwable t)
           
protected
<T> AnnotatedBindingBuilder<T>
bind(java.lang.Class<T> clazz)
           
protected
<T> LinkedBindingBuilder<T>
bind(Key<T> key)
           
protected
<T> AnnotatedBindingBuilder<T>
bind(TypeLiteral<T> typeLiteral)
           
protected  AnnotatedConstantBindingBuilder bindConstant()
           
protected  Binder binder()
          Gets direct access to the underlying Binder.
protected  void bindInterceptor(Matcher<? super java.lang.Class<?>> classMatcher, Matcher<? super java.lang.reflect.Method> methodMatcher, org.aopalliance.intercept.MethodInterceptor... interceptors)
           
protected  void bindScope(java.lang.Class<? extends java.lang.annotation.Annotation> scopeAnnotation, Scope scope)
           
protected abstract  void configure()
          Configures a Binder via the exposed methods.
 void configure(Binder builder)
          Contributes bindings and other configurations to a Binder.
protected  void install(Module module)
           
protected  void requestStaticInjection(java.lang.Class<?>... types)
           
 
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(Binder builder)
Description copied from interface: Module
Contributes bindings and other configurations to a Binder.

Specified by:
configure in interface Module

configure

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


binder

protected Binder binder()
Gets direct access to the underlying Binder.


bindScope

protected void bindScope(java.lang.Class<? extends java.lang.annotation.Annotation> scopeAnnotation,
                         Scope scope)
See Also:
Binder.bindScope(Class, Scope)

bind

protected <T> LinkedBindingBuilder<T> bind(Key<T> key)
See Also:
Binder.bind(Key)

bind

protected <T> AnnotatedBindingBuilder<T> bind(TypeLiteral<T> typeLiteral)
See Also:
Binder.bind(TypeLiteral)

bind

protected <T> AnnotatedBindingBuilder<T> bind(java.lang.Class<T> clazz)
See Also:
Binder.bind(Class)

bindConstant

protected AnnotatedConstantBindingBuilder bindConstant()
See Also:
Binder.bindConstant()

install

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

addError

protected void addError(java.lang.String message,
                        java.lang.Object... arguments)
See Also:
Binder.addError(String, Object[])

addError

protected void addError(java.lang.Throwable t)
See Also:
Binder.addError(Throwable)

requestStaticInjection

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

bindInterceptor

protected void bindInterceptor(Matcher<? super java.lang.Class<?>> classMatcher,
                               Matcher<? super java.lang.reflect.Method> methodMatcher,
                               org.aopalliance.intercept.MethodInterceptor... interceptors)
See Also:
Binder.bindInterceptor(com.google.inject.matcher.Matcher, com.google.inject.matcher.Matcher, org.aopalliance.intercept.MethodInterceptor[])


Copyright © {inceptionYear}-2008 null. All Rights Reserved.