Class AbstractModule

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

public abstract class AbstractModule extends Object implements Module
AbstractModule is a helper class used to add bindings to the Guice injector.

Simply extend this class, then you can add bindings by either defining @Provides methods (see https://github.com/google/guice/wiki/ProvidesMethods) or implementing configure(), and calling the inherited methods which mirror those found in Binder. For example:

 public class MyModule extends AbstractModule {
   protected void configure() {
     bind(Service.class).to(ServiceImpl.class).in(Singleton.class);
     bind(CreditCardPaymentService.class);
     bind(PaymentService.class).to(CreditCardPaymentService.class);
     bindConstant().annotatedWith(Names.named("port")).to(8080);
   }
 }
 
Author:
crazybob@google.com (Bob Lee)