com.google.inject

Class AbstractModule

  • All Implemented Interfaces:
    Module


    public abstract class AbstractModule
    extends 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);
       }
     }
     
    Author:
    crazybob@google.com (Bob Lee)

Copyright © 2006-2014 Google, Inc.. All Rights Reserved.