Class AbstractModule

  • All Implemented Interfaces:
    Module
    Direct Known Subclasses:
    ActionModule, ClusterModule, GatewayModule, IndicesModule, RepositoriesModule

    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:
     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);
       }
     }