Class

com.twitter.inject

TwitterModule

Related Doc: package inject

Permalink

abstract class TwitterModule extends AbstractModule with TwitterBaseModule with Logging

A support class for Module implementations which exposes a DSL for binding via type parameters. Extend this class, override the configure method and call the bind methods, or define custom @Provides annotated methods. This class also provides an integration with com.twitter.app.Flag types which allows for passing external configuration to aid in the creation of bound types. Lastly, it is also possible to define a list of other TwitterModule instances which this TwitterModule "depends" on by setting the TwitterBaseModule.modules (or TwitterBaseModule.javaModules) to a non-empty list. This will ensure that when only this TwitterModule instance is used to compose an Injector the "dependent" list of modules will also be installed.

Example:
  1. object MyModule extends TwitterModule {
     flag[String](name = "card.gateway", help = "The processing gateway to use for credit cards.")
     override protected def configure(): Unit = {
       bind[Service].to[ServiceImpl].in[Singleton]
       bind[CreditCardPaymentService]
       bind[Bar[Foo]].to[FooBarImpl]
       bind[PaymentService].to[CreditCardPaymentService]
     }
     @Singleton
     @Provides
     def provideCreditCardServiceProcessor(
       @Flag("card.gateway") gateway: String
     ): CreditCardProcessor = {
       new CreditCardProcessor(gateway)
     }
    }
Note

Attempting to bind the same type multiple times with no discriminating com.google.inject.BindingAnnotation will result in an exception during injector construction.

See also

Writing Modules in Finatra

com.google.inject.AbstractModule

Linear Supertypes
TwitterBaseModule, TwitterModuleLifecycle, Logging, util.logging.Logging, TwitterModuleFlags, AbstractModule, Module, AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. TwitterModule
  2. TwitterBaseModule
  3. TwitterModuleLifecycle
  4. Logging
  5. Logging
  6. TwitterModuleFlags
  7. AbstractModule
  8. Module
  9. AnyRef
  10. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new TwitterModule()

    Permalink

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. def addError(arg0: Message): Unit

    Permalink
    Attributes
    protected[com.google.inject]
    Definition Classes
    AbstractModule
  5. def addError(arg0: Throwable): Unit

    Permalink
    Attributes
    protected[com.google.inject]
    Definition Classes
    AbstractModule
  6. def addError(arg0: String, arg1: <repeated...>[AnyRef]): Unit

    Permalink
    Attributes
    protected[com.google.inject]
    Definition Classes
    AbstractModule
  7. def addTypeConverter[T](converter: TypeConverter)(implicit arg0: Manifest[T]): Unit

    Permalink

    Binds a type converter.

    Binds a type converter. The injector will use the given converter to convert string constants to matching types as needed.

    T

    type to match that the converter can handle

    converter

    converts values

    Attributes
    protected
  8. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  9. def bind[T](annotation: Annotation)(implicit arg0: Manifest[T]): ScalaAnnotatedBindingBuilder[T]

    Permalink

    Returns a new com.google.inject.Binder of type T with no com.google.inject.Scope that is bound with a binding annotation.

    Returns a new com.google.inject.Binder of type T with no com.google.inject.Scope that is bound with a binding annotation.

    Attributes
    protected
    See also

    No Scope

  10. def bind[T, A <: Annotation](implicit arg0: Manifest[T], arg1: Manifest[A]): ScalaAnnotatedBindingBuilder[T]

    Permalink

    Returns a new com.google.inject.Binder of type T with no com.google.inject.Scope that is bound with a binding annotation A.

    Returns a new com.google.inject.Binder of type T with no com.google.inject.Scope that is bound with a binding annotation A.

    Attributes
    protected
    See also

    No Scope

  11. def bind[T](implicit arg0: Manifest[T]): ScalaAnnotatedBindingBuilder[T]

    Permalink

    Returns a new com.google.inject.Binder of type T with no com.google.inject.Scope that is bound with no binding annotation.

    Returns a new com.google.inject.Binder of type T with no com.google.inject.Scope that is bound with no binding annotation.

    Attributes
    protected
    See also

    No Scope

  12. def bind[T](arg0: Class[T]): AnnotatedBindingBuilder[T]

    Permalink
    Attributes
    protected[com.google.inject]
    Definition Classes
    AbstractModule
  13. def bind[T](arg0: TypeLiteral[T]): AnnotatedBindingBuilder[T]

    Permalink
    Attributes
    protected[com.google.inject]
    Definition Classes
    AbstractModule
  14. def bind[T](arg0: Key[T]): LinkedBindingBuilder[T]

    Permalink
    Attributes
    protected[com.google.inject]
    Definition Classes
    AbstractModule
  15. def bindAssistedFactory[T]()(implicit arg0: Manifest[T]): Unit

    Permalink

    Provides for installing and building a factory that combines the caller's arguments with injector-supplied values to construct objects.

    Provides for installing and building a factory that combines the caller's arguments with injector-supplied values to construct objects. This is preferable to calling install on the TwitterModule which provides the factory as install is not supported for TwitterModule types.

    T

    type of the assisted injection factory

    Attributes
    protected
    See also

    Assisted Injection

    com.google.inject.assistedinject.FactoryModuleBuilder

    com.google.inject.assistedinject.AssitedInject

  16. def bindConstant(): AnnotatedConstantBindingBuilder

    Permalink
    Attributes
    protected[com.google.inject]
    Definition Classes
    AbstractModule
  17. def bindInterceptor(arg0: Matcher[_ >: Class[_]], arg1: Matcher[_ >: Method], arg2: <repeated...>[MethodInterceptor]): Unit

    Permalink
    Attributes
    protected[com.google.inject]
    Definition Classes
    AbstractModule
  18. def bindListener(arg0: Matcher[_ >: Binding[_]], arg1: <repeated...>[ProvisionListener]): Unit

    Permalink
    Attributes
    protected[com.google.inject]
    Definition Classes
    AbstractModule
  19. def bindListener(arg0: Matcher[_ >: TypeLiteral[_]], arg1: TypeListener): Unit

    Permalink
    Attributes
    protected[com.google.inject]
    Definition Classes
    AbstractModule
  20. def bindMultiple[T](annotation: Annotation)(implicit arg0: Manifest[T]): ScalaMultibinder[T]

    Permalink

    Returns a new com.google.inject.multibindings.Multibinder that collects instances of type T in a scala.collection.immutable.Set that is itself bound with a binding annotation.

    Returns a new com.google.inject.multibindings.Multibinder that collects instances of type T in a scala.collection.immutable.Set that is itself bound with a binding annotation.

    An API to bind multiple values separately, only to later inject them as a complete collection. "Multibinding" is intended for use in your application's module:

    class SnacksModule extends TwitterModule {
      override protected def configure(): Unit = {
        bindMultiple[Snack].addBinding.toInstance(new Twix())
        bindMultiple[Snack].addBinding.toProvider[SnickersProvider]
        bindMultiple[Snack].addBinding.to[Skittles]
      }
    }

    With this binding, a Set[Snack] can now be injected:

    class SnackMachine @Inject()(Set[Snack] snacks)

    Contributing multibindings from different modules is also supported. For example, it is okay for both CandyModule and ChipsModule to create their own Multibinder[Snack], and to each contribute bindings to the set of snacks. When that set is injected, it will contain elements from both modules.

    The set's iteration order is consistent with the binding order. This is convenient when multiple elements are contributed by the same module because that module can order its bindings appropriately. Avoid relying on the iteration order of elements contributed by different modules, since there is no equivalent mechanism to order modules.

    The set is unmodifiable. Elements can only be added to the set by configuring the multibinder. Elements can never be removed from the set.

    Elements are resolved at set injection time. If an element is bound to a provider, that provider's get method will be called each time the set is injected (unless the binding is also scoped).

    Annotations can be used to create different sets of the same element type. Each distinct annotation gets its own independent collection of elements.

    Elements MUST be distinct. If multiple bound elements have the same value, set injection will fail.

    Elements MUST be non-null. If any set element is null, set injection will fail.

    Attributes
    protected
    See also

    com.google.inject.multibindings.Multibinder

  21. def bindMultiple[T, A <: Annotation](implicit arg0: Manifest[T], arg1: Manifest[A]): ScalaMultibinder[T]

    Permalink

    Returns a new com.google.inject.multibindings.Multibinder that collects instances of type T in a scala.collection.immutable.Set that is itself bound with a binding annotation A.

    Returns a new com.google.inject.multibindings.Multibinder that collects instances of type T in a scala.collection.immutable.Set that is itself bound with a binding annotation A.

    An API to bind multiple values separately, only to later inject them as a complete collection. "Multibinding" is intended for use in your application's module:

    class SnacksModule extends TwitterModule {
      override protected def configure(): Unit = {
        bindMultiple[Snack].addBinding.toInstance(new Twix())
        bindMultiple[Snack].addBinding.toProvider[SnickersProvider]
        bindMultiple[Snack].addBinding.to[Skittles]
      }
    }

    With this binding, a Set[Snack] can now be injected:

    class SnackMachine @Inject()(Set[Snack] snacks)

    Contributing multibindings from different modules is also supported. For example, it is okay for both CandyModule and ChipsModule to create their own Multibinder[Snack], and to each contribute bindings to the set of snacks. When that set is injected, it will contain elements from both modules.

    The set's iteration order is consistent with the binding order. This is convenient when multiple elements are contributed by the same module because that module can order its bindings appropriately. Avoid relying on the iteration order of elements contributed by different modules, since there is no equivalent mechanism to order modules.

    The set is unmodifiable. Elements can only be added to the set by configuring the multibinder. Elements can never be removed from the set.

    Elements are resolved at set injection time. If an element is bound to a provider, that provider's get method will be called each time the set is injected (unless the binding is also scoped).

    Annotations can be used to create different sets of the same element type. Each distinct annotation gets its own independent collection of elements.

    Elements MUST be distinct. If multiple bound elements have the same value, set injection will fail.

    Elements MUST be non-null. If any set element is null, set injection will fail.

    Attributes
    protected
    See also

    com.google.inject.multibindings.Multibinder

  22. def bindMultiple[T](implicit arg0: Manifest[T]): ScalaMultibinder[T]

    Permalink

    Returns a new com.google.inject.multibindings.Multibinder that collects instances of type T in a scala.collection.immutable.Set that is itself bound with no binding annotation.

    Returns a new com.google.inject.multibindings.Multibinder that collects instances of type T in a scala.collection.immutable.Set that is itself bound with no binding annotation.

    An API to bind multiple values separately, only to later inject them as a complete collection. "Multibinding" is intended for use in your application's module:

    class SnacksModule extends TwitterModule {
      override protected def configure(): Unit = {
        bindMultiple[Snack].addBinding.toInstance(new Twix())
        bindMultiple[Snack].addBinding.toProvider[SnickersProvider]
        bindMultiple[Snack].addBinding.to[Skittles]
      }
    }

    With this binding, a Set[Snack] can now be injected:

    class SnackMachine @Inject()(Set[Snack] snacks)

    Contributing multibindings from different modules is also supported. For example, it is okay for both CandyModule and ChipsModule to create their own Multibinder[Snack], and to each contribute bindings to the set of snacks. When that set is injected, it will contain elements from both modules.

    The set's iteration order is consistent with the binding order. This is convenient when multiple elements are contributed by the same module because that module can order its bindings appropriately. Avoid relying on the iteration order of elements contributed by different modules, since there is no equivalent mechanism to order modules.

    The set is unmodifiable. Elements can only be added to the set by configuring the multibinder. Elements can never be removed from the set.

    Elements are resolved at set injection time. If an element is bound to a provider, that provider's get method will be called each time the set is injected (unless the binding is also scoped).

    Annotations can be used to create different sets of the same element type. Each distinct annotation gets its own independent collection of elements.

    Elements MUST be distinct. If multiple bound elements have the same value, set injection will fail.

    Elements MUST be non-null. If any set element is null, set injection will fail.

    Attributes
    protected
    See also

    com.google.inject.multibindings.Multibinder

  23. def bindOption[T](annotation: Annotation)(implicit arg0: Manifest[T]): ScalaOptionBinder[T]

    Permalink

    Returns a new com.google.inject.multibindings.OptionalBinder that binds an instance of T in a scala.Option that is itself bound with a binding annotation.

    Returns a new com.google.inject.multibindings.OptionalBinder that binds an instance of T in a scala.Option that is itself bound with a binding annotation.

    Calling this method will always supply the bindings: Option[T] and Option[Provider[T]]. If setBinding or setDefault are called, it will also bind T.

    setDefault is intended for use by frameworks that need a default value. User code can call setBinding to override the default.

    Warning: even if setBinding is called, the default binding will still exist in the object graph. If it is a singleton, it will be instantiated in Stage.PRODUCTION.

    If setDefault or setBinding are linked to Providers, the Provider may return null. If it does, the Option bindings will be a None. Binding setBinding to a Provider that returns null will not cause OptionalBinder to fall back to the setDefault binding.

    If neither setDefault nor setBinding are called, it will try to link to a user-supplied binding of the same type. If no binding exists, the options will be absent. Otherwise, if a user-supplied binding of that type exists, or if setBinding or setDefault are called, the options will return Some(T) if they are bound to a non-null value, otherwise None.

    Values are resolved at injection time. If a value is bound to a provider, that provider's get method will be called each time the option is injected (unless the binding is also scoped, or an option of provider is injected).

    Annotations are used to create different options of the same key/value type. Each distinct annotation gets its own independent binding. For example:

    class FrameworkModule extends TwitterModule {
      override protected def configure(): Unit = {
        bindOption[Renamer]
      }
    }

    With this module, an Option[Renamer] can now be injected. With no other bindings, the option will be None. Users can specify bindings in one of two ways:

    Option 1:

    class UserRenamerModule extends TwitterModule {
      override protected def configure(): Unit = {
        bind[Renamer].to[ReplacingRenamer]
      }
    }

    or Option 2:

    class UserRenamerModule extends TwitterModule {
      override protected def configure(): Unit = {
        bindOption[Renamer].setBinding.to[ReplacingRenamer]
      }
    }

    With both options, the Option[Renamer] will be present and supply the ReplacingRenamer.

    Default values can be supplied using:

     class FrameworkModule extends TwitterModule {
      override protected def configure(): Unit = {
        bindOption[String, LookupUrl].setDefault.toInstance(DefaultLookupUrl)
      }
    }

    With the above module, code can inject an @LookupUrl-annotated String and it will supply the DefaultLookupUrl. A user can change this value by binding:

    class UserLookupModule extends TwitterModule {
      override protected def configure(): Unit = {
        bindOption[String, LookupUrl].setBinding.toInstance(CustomLookupUrl)
      }
    }

    which will override the default value.

    If one module uses setDefault the only way to override the default is to use setBinding. It is an error for a user to specify the binding without using com.google.inject.multibindings.OptionalBinder if setDefault or setBinding are called. For example:

     class FrameworkModule extends TwitterModule {
      override protected def configure(): Unit = {
        bindOption[String, LookupUrl].setDefault.toInstance(DefaultLookupUrl)
      }
    }
    class UserLookupModule extends TwitterModule {
      override protected def configure(): Unit = {
        bind[String, LookupUrl].toInstance(CustomLookupUrl);
      }
    }

    would generate an error, because both the framework and the user are trying to bind @LookupUrl String.

    Attributes
    protected
    See also

    com.google.inject.multibindings.OptionalBinder

  24. def bindOption[T, A <: Annotation](implicit arg0: Manifest[T], arg1: Manifest[A]): ScalaOptionBinder[T]

    Permalink

    Returns a new com.google.inject.multibindings.OptionalBinder that binds an instance of T in a scala.Option that is itself bound with a binding annotation A.

    Returns a new com.google.inject.multibindings.OptionalBinder that binds an instance of T in a scala.Option that is itself bound with a binding annotation A.

    Calling this method will always supply the bindings: Option[T] and Option[Provider[T]]. If setBinding or setDefault are called, it will also bind T.

    setDefault is intended for use by frameworks that need a default value. User code can call setBinding to override the default.

    Warning: even if setBinding is called, the default binding will still exist in the object graph. If it is a singleton, it will be instantiated in Stage.PRODUCTION.

    If setDefault or setBinding are linked to Providers, the Provider may return null. If it does, the Option bindings will be a None. Binding setBinding to a Provider that returns null will not cause OptionalBinder to fall back to the setDefault binding.

    If neither setDefault nor setBinding are called, it will try to link to a user-supplied binding of the same type. If no binding exists, the options will be absent. Otherwise, if a user-supplied binding of that type exists, or if setBinding or setDefault are called, the options will return Some(T) if they are bound to a non-null value, otherwise None.

    Values are resolved at injection time. If a value is bound to a provider, that provider's get method will be called each time the option is injected (unless the binding is also scoped, or an option of provider is injected).

    Annotations are used to create different options of the same key/value type. Each distinct annotation gets its own independent binding. For example:

    class FrameworkModule extends TwitterModule {
      override protected def configure(): Unit = {
        bindOption[Renamer]
      }
    }

    With this module, an Option[Renamer] can now be injected. With no other bindings, the option will be None. Users can specify bindings in one of two ways:

    Option 1:

    class UserRenamerModule extends TwitterModule {
      override protected def configure(): Unit = {
        bind[Renamer].to[ReplacingRenamer]
      }
    }

    or Option 2:

    class UserRenamerModule extends TwitterModule {
      override protected def configure(): Unit = {
        bindOption[Renamer].setBinding.to[ReplacingRenamer]
      }
    }

    With both options, the Option[Renamer] will be present and supply the ReplacingRenamer.

    Default values can be supplied using:

     class FrameworkModule extends TwitterModule {
      override protected def configure(): Unit = {
        bindOption[String, LookupUrl].setDefault.toInstance(DefaultLookupUrl)
      }
    }

    With the above module, code can inject an @LookupUrl-annotated String and it will supply the DefaultLookupUrl. A user can change this value by binding:

    class UserLookupModule extends TwitterModule {
      override protected def configure(): Unit = {
        bindOption[String, LookupUrl].setBinding.toInstance(CustomLookupUrl)
      }
    }

    which will override the default value.

    If one module uses setDefault the only way to override the default is to use setBinding. It is an error for a user to specify the binding without using com.google.inject.multibindings.OptionalBinder if setDefault or setBinding are called. For example:

     class FrameworkModule extends TwitterModule {
      override protected def configure(): Unit = {
        bindOption[String, LookupUrl].setDefault.toInstance(DefaultLookupUrl)
      }
    }
    class UserLookupModule extends TwitterModule {
      override protected def configure(): Unit = {
        bind[String, LookupUrl].toInstance(CustomLookupUrl);
      }
    }

    would generate an error, because both the framework and the user are trying to bind @LookupUrl String.

    Attributes
    protected
    See also

    com.google.inject.multibindings.OptionalBinder

  25. def bindOption[T](implicit arg0: Manifest[T]): ScalaOptionBinder[T]

    Permalink

    Returns a new com.google.inject.multibindings.OptionalBinder that binds an instance of T in a scala.Option.

    Returns a new com.google.inject.multibindings.OptionalBinder that binds an instance of T in a scala.Option.

    Calling this method will always supply the bindings: Option[T] and Option[Provider[T]]. If setBinding or setDefault are called, it will also bind T.

    setDefault is intended for use by frameworks that need a default value. User code can call setBinding to override the default.

    Warning: even if setBinding is called, the default binding will still exist in the object graph. If it is a singleton, it will be instantiated in Stage.PRODUCTION.

    If setDefault or setBinding are linked to Providers, the Provider may return null. If it does, the Option bindings will be a None. Binding setBinding to a Provider that returns null will not cause OptionalBinder to fall back to the setDefault binding.

    If neither setDefault nor setBinding are called, it will try to link to a user-supplied binding of the same type. If no binding exists, the options will be absent. Otherwise, if a user-supplied binding of that type exists, or if setBinding or setDefault are called, the options will return Some(T) if they are bound to a non-null value, otherwise None.

    Values are resolved at injection time. If a value is bound to a provider, that provider's get method will be called each time the option is injected (unless the binding is also scoped, or an option of provider is injected).

    Annotations are used to create different options of the same key/value type. Each distinct annotation gets its own independent binding. For example:

    class FrameworkModule extends TwitterModule {
      override protected def configure(): Unit = {
        bindOption[Renamer]
      }
    }

    With this module, an Option[Renamer] can now be injected. With no other bindings, the option will be None. Users can specify bindings in one of two ways:

    Option 1:

    class UserRenamerModule extends TwitterModule {
      override protected def configure(): Unit = {
        bind[Renamer].to[ReplacingRenamer]
      }
    }

    or Option 2:

    class UserRenamerModule extends TwitterModule {
      override protected def configure(): Unit = {
        bindOption[Renamer].setBinding.to[ReplacingRenamer]
      }
    }

    With both options, the Option[Renamer] will be present and supply the ReplacingRenamer.

    Default values can be supplied using:

     class FrameworkModule extends TwitterModule {
      override protected def configure(): Unit = {
        bindOption[String, LookupUrl].setDefault.toInstance(DefaultLookupUrl)
      }
    }

    With the above module, code can inject an @LookupUrl-annotated String and it will supply the DefaultLookupUrl. A user can change this value by binding:

    class UserLookupModule extends TwitterModule {
      override protected def configure(): Unit = {
        bindOption[String, LookupUrl].setBinding.toInstance(CustomLookupUrl)
      }
    }

    which will override the default value.

    If one module uses setDefault the only way to override the default is to use setBinding. It is an error for a user to specify the binding without using com.google.inject.multibindings.OptionalBinder if setDefault or setBinding are called. For example:

     class FrameworkModule extends TwitterModule {
      override protected def configure(): Unit = {
        bindOption[String, LookupUrl].setDefault.toInstance(DefaultLookupUrl)
      }
    }
    class UserLookupModule extends TwitterModule {
      override protected def configure(): Unit = {
        bind[String, LookupUrl].toInstance(CustomLookupUrl);
      }
    }

    would generate an error, because both the framework and the user are trying to bind @LookupUrl String.

    Attributes
    protected
    See also

    com.google.inject.multibindings.OptionalBinder

  26. def bindScope[T <: Annotation](scope: Scope)(implicit arg0: Manifest[T]): Unit

    Permalink

    Binds a com.google.inject.Scope to an annotation.

    Binds a com.google.inject.Scope to an annotation.

    Attributes
    protected[this]
  27. def bindScope(arg0: Class[_ <: Annotation], arg1: Scope): Unit

    Permalink
    Attributes
    protected[com.google.inject]
    Definition Classes
    AbstractModule
  28. def bindSingleton[T](annotation: Annotation)(implicit arg0: Manifest[T]): ScalaAnnotatedBindingBuilder[T]

    Permalink

    Returns a new com.google.inject.Binder of type T singleton-scoped that is bound with a binding annotation.

    Returns a new com.google.inject.Binder of type T singleton-scoped that is bound with a binding annotation.

    Attributes
    protected
    See also

    Singleton Scope

  29. def bindSingleton[T, A <: Annotation](implicit arg0: Manifest[T], arg1: Manifest[A]): ScalaAnnotatedBindingBuilder[T]

    Permalink

    Returns a new com.google.inject.Binder of type T singleton-scoped that is bound with a binding annotation A.

    Returns a new com.google.inject.Binder of type T singleton-scoped that is bound with a binding annotation A.

    Attributes
    protected
    See also

    Singleton Scope

  30. def bindSingleton[T](implicit arg0: Manifest[T]): ScalaAnnotatedBindingBuilder[T]

    Permalink

    Returns a new com.google.inject.Binder of type T singleton-scoped that is bound with no binding annotation.

    Returns a new com.google.inject.Binder of type T singleton-scoped that is bound with no binding annotation.

    Attributes
    protected
    See also

    Singleton Scope

  31. def binder(): Binder

    Permalink
    Attributes
    protected[com.google.inject]
    Definition Classes
    AbstractModule
  32. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  33. def closeOnExit(f: ⇒ Unit): Unit

    Permalink

    Collects functions over a com.twitter.util.Closables.

    Collects functions over a com.twitter.util.Closables. These functions will be passed to the application onExit function to be executed on graceful shutdown of the application.

    f

    A Function0 which returns Unit. It is expected that this function encapsulates awaiting on a com.twitter.util.Closable that the application would like to ensure is closed upon graceful shutdown.

    closeOnExit {
      val closable = ...
      Await.result(
        closable.close(after: Duration), timeout: Duration)
      }
    Attributes
    protected
    Definition Classes
    TwitterModuleLifecycle
    Note

    It is expected that the passed function is a function over a com.twitter.util.Closable.

    See also

    com.twitter.util.Closable

    com.twitter.util.Awaitable

    => Unit)

  34. def configure(): Unit

    Permalink

    Configures a com.google.inject.Binder via the exposed methods.

    Configures a com.google.inject.Binder via the exposed methods. A default implementation is provided such that extensions using only @Provides-annotated methods do not need to implement an empty TwitterModule.configure() method.

    Attributes
    protected
    Definition Classes
    TwitterModule → AbstractModule
    See also

    com.google.inject.AbstractModule#configure()

  35. final def configure(arg0: Binder): Unit

    Permalink
    Definition Classes
    AbstractModule → Module
  36. def convertToTypes(arg0: Matcher[_ >: TypeLiteral[_]], arg1: TypeConverter): Unit

    Permalink
    Attributes
    protected[com.google.inject]
    Definition Classes
    AbstractModule
  37. def createFlag[T](name: String, default: T, help: String, flaggable: Flaggable[T]): Flag[T]

    Permalink

    A Java-friendly method for creating a named Flag.

    A Java-friendly method for creating a named Flag.

    name

    the name of the Flag.

    default

    a default value for the Flag when no value is given as an application argument.

    help

    the help text explaining the purpose of the Flag.

    returns

    the created Flag.

    Attributes
    protected
    Definition Classes
    TwitterModuleFlags
  38. def createMandatoryFlag[T](name: String, help: String, usage: String, flaggable: Flaggable[T]): Flag[T]

    Permalink

    A Java-friendly way to create a "mandatory" Flag.

    A Java-friendly way to create a "mandatory" Flag. "Mandatory" flags MUST have a value provided as an application argument (as they have no default value to be used).

    name

    the name of the Flag.

    help

    the help text explaining the purpose of the Flag.

    usage

    a string describing the type of the Flag, i.e.: Integer.

    returns

    the created Flag.

    Definition Classes
    TwitterModuleFlags
  39. def currentStage(): Stage

    Permalink
    Attributes
    protected[com.google.inject]
    Definition Classes
    AbstractModule
  40. def debug(marker: Marker, message: ⇒ Any, cause: Throwable): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  41. def debug(message: ⇒ Any, cause: Throwable): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  42. def debug(marker: Marker, message: ⇒ Any): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  43. def debug(message: ⇒ Any): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  44. def debugFutureResult[T](msg: String)(func: ⇒ Future[T]): Future[T]

    Permalink
    Attributes
    protected
    Definition Classes
    Logging
  45. def debugResult[T](message: ⇒ String)(fn: ⇒ T): T

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  46. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  47. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  48. def error(marker: Marker, message: ⇒ Any, cause: Throwable): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  49. def error(message: ⇒ Any, cause: Throwable): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  50. def error(marker: Marker, message: ⇒ Any): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  51. def error(message: ⇒ Any): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  52. def errorResult[T](message: ⇒ String)(fn: ⇒ T): T

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  53. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  54. def flag[T](name: String, help: String)(implicit arg0: Flaggable[T], arg1: Manifest[T]): Flag[T]

    Permalink

    Create a "mandatory" flag and add it to this Module's flags list."Mandatory" flags MUST have a value provided as an application argument (as they have no default value to be used).

    Create a "mandatory" flag and add it to this Module's flags list."Mandatory" flags MUST have a value provided as an application argument (as they have no default value to be used).

    T

    must be a Flaggable type.

    name

    the name of the Flag.

    help

    the help text explaining the purpose of the Flag.

    returns

    the created Flag.

    Attributes
    protected
    Definition Classes
    TwitterModuleFlags
    Note

    Java users: see the more Java-friendly createFlag or createMandatoryFlag.

  55. def flag[T](name: String, default: T, help: String)(implicit arg0: Flaggable[T]): Flag[T]

    Permalink

    Create a Flag and add it to this Module's flags list.

    Create a Flag and add it to this Module's flags list.

    T

    must be a Flaggable type.

    name

    the name of the Flag.

    default

    a default value for the Flag when no value is given as an application argument.

    help

    the help text explaining the purpose of the Flag.

    returns

    the created Flag.

    Attributes
    protected
    Definition Classes
    TwitterModuleFlags
    Note

    Java users: see the more Java-friendly createFlag or createMandatoryFlag.

  56. val flags: ArrayBuffer[Flag[_]]

    Permalink
    Attributes
    protected[com.twitter.inject]
    Definition Classes
    TwitterModuleFlags
  57. def frameworkModules: Seq[Module]

    Permalink

    Additional framework modules to be composed into this module.

    Additional framework modules to be composed into this module.

    Attributes
    protected[com.twitter.inject]
    Definition Classes
    TwitterBaseModule
  58. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  59. def getMembersInjector[T](implicit arg0: Manifest[T]): MembersInjector[T]

    Permalink

    Returns the members injector used to inject dependencies into methods and fields on instances of the given type T.

    Returns the members injector used to inject dependencies into methods and fields on instances of the given type T. The returned members injector will not be valid until the main Injector has been created. The members injector will throw an IllegalStateException if you try to use it beforehand.

    T

    type to get members injector for

    returns

    a com.google.inject.MembersInjector of type T

    Attributes
    protected[this]
    Annotations
    @throws( ... )
  60. def getMembersInjector[T](arg0: TypeLiteral[T]): MembersInjector[T]

    Permalink
    Attributes
    protected[com.google.inject]
    Definition Classes
    AbstractModule
  61. def getMembersInjector[T](arg0: Class[T]): MembersInjector[T]

    Permalink
    Attributes
    protected[com.google.inject]
    Definition Classes
    AbstractModule
  62. def getProvider[T](implicit arg0: Manifest[T]): Provider[T]

    Permalink

    Returns the provider used to obtain instances for the given injection type T.

    Returns the provider used to obtain instances for the given injection type T. The returned provider will not be valid until the Injector has been created. The provider will throw an IllegalStateException if you try to use it beforehand.

    T

    the type for the provider to find.

    returns

    the com.google.inject.Provider of type T

    Attributes
    protected[this]
    Annotations
    @throws( ... )
  63. def getProvider[T](arg0: Class[T]): Provider[T]

    Permalink
    Attributes
    protected[com.google.inject]
    Definition Classes
    AbstractModule
  64. def getProvider[T](arg0: Key[T]): Provider[T]

    Permalink
    Attributes
    protected[com.google.inject]
    Definition Classes
    AbstractModule
  65. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  66. def info(marker: Marker, message: ⇒ Any, cause: Throwable): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  67. def info(message: ⇒ Any, cause: Throwable): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  68. def info(marker: Marker, message: ⇒ Any): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  69. def info(message: ⇒ Any): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  70. def infoResult[T](message: ⇒ String)(fn: ⇒ T): T

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  71. def install(module: Module): Unit

    Permalink

    Uses the given com.google.inject.Module to configure more bindings.

    Uses the given com.google.inject.Module to configure more bindings. This is not supported for instances of type TwitterModule and will throw an UnsupportedOperationException if attempted on an instance of TwitterModule. This is to properly support the TwitterModuleLifecycle for TwitterModule instances.

    Attributes
    protected
    Definition Classes
    TwitterModule → AbstractModule
    Annotations
    @throws( ... )
    Note

    Module) can still be used for non-TwitterModule instances, and is sometimes preferred due to install being deferred until after flag parsing occurs.

  72. def isDebugEnabled(marker: Marker): Boolean

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  73. def isDebugEnabled: Boolean

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  74. def isErrorEnabled(marker: Marker): Boolean

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  75. def isErrorEnabled: Boolean

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  76. def isInfoEnabled(marker: Marker): Boolean

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  77. def isInfoEnabled: Boolean

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  78. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  79. def isTraceEnabled(marker: Marker): Boolean

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  80. def isTraceEnabled: Boolean

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  81. def isWarnEnabled(marker: Marker): Boolean

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  82. def isWarnEnabled: Boolean

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  83. def javaModules: Collection[Module]

    Permalink

    Additional modules to be composed into this module from Java

    Additional modules to be composed into this module from Java

    Attributes
    protected[com.twitter.inject]
    Definition Classes
    TwitterBaseModule
  84. final def logger: Logger

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  85. final def loggerName: String

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  86. def modules: Seq[Module]

    Permalink

    Additional modules to be composed into this module.

    Additional modules to be composed into this module. This list of modules is generally used instead of the TwitterModule.install method to properly support the TwitterModuleLifecycle for TwitterModule instances.

    Attributes
    protected[com.twitter.inject]
    Definition Classes
    TwitterBaseModule
    Note

    Java users should prefer javaModules.

    ,

    Module) can still be used for non-TwitterModule 1 instances, and is sometimes preferred due to install being deferred until after flag parsing occurs.

  87. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  88. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  89. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  90. def requestInjection(arg0: Any): Unit

    Permalink
    Attributes
    protected[com.google.inject]
    Definition Classes
    AbstractModule
  91. def requestStaticInjection[T]()(implicit arg0: Manifest[T]): Unit

    Permalink

    Upon successful creation, the Injector will inject static fields and methods in the given classes.

    Upon successful creation, the Injector will inject static fields and methods in the given classes.

    T

    type for which static members will be injected

    Attributes
    protected[this]
  92. def requestStaticInjection(arg0: <repeated...>[Class[_]]): Unit

    Permalink
    Attributes
    protected[com.google.inject]
    Definition Classes
    AbstractModule
  93. def requireBinding(arg0: Class[_]): Unit

    Permalink
    Attributes
    protected[com.google.inject]
    Definition Classes
    AbstractModule
  94. def requireBinding(arg0: Key[_]): Unit

    Permalink
    Attributes
    protected[com.google.inject]
    Definition Classes
    AbstractModule
  95. def singletonPostWarmupComplete(injector: Injector): Unit

    Permalink

    Invoke after external ports are bound and any clients are resolved

    Invoke after external ports are bound and any clients are resolved

    This method should only get singleton instances from the injector.

    Attributes
    protected[com.twitter.inject]
    Definition Classes
    TwitterModuleLifecycle
  96. def singletonShutdown(injector: Injector): Unit

    Permalink

    Invoked on graceful shutdown of the application.

    Invoked on graceful shutdown of the application.

    This method should only get singleton instances from the injector.

    Attributes
    protected[com.twitter.inject]
    Definition Classes
    TwitterModuleLifecycle
  97. def singletonStartup(injector: Injector): Unit

    Permalink

    Invoked after the injector is started.

    Invoked after the injector is started.

    This method should only get singleton instances from the injector.

    Attributes
    protected[com.twitter.inject]
    Definition Classes
    TwitterModuleLifecycle
  98. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  99. def time[T](formatStr: String)(func: ⇒ T): T

    Permalink
    Attributes
    protected
    Definition Classes
    Logging
  100. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  101. def trace(marker: Marker, message: ⇒ Any, cause: Throwable): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  102. def trace(message: ⇒ Any, cause: Throwable): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  103. def trace(marker: Marker, message: ⇒ Any): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  104. def trace(message: ⇒ Any): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  105. def traceResult[T](message: ⇒ String)(fn: ⇒ T): T

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  106. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  107. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  108. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  109. def warn(marker: Marker, message: ⇒ Any, cause: Throwable): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  110. def warn(message: ⇒ Any, cause: Throwable): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  111. def warn(marker: Marker, message: ⇒ Any): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  112. def warn(message: ⇒ Any): Unit

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging
  113. def warnResult[T](message: ⇒ String)(fn: ⇒ T): T

    Permalink
    Attributes
    protected[this]
    Definition Classes
    Logging

Deprecated Value Members

  1. def createMultiBinder[MultiBindType](implicit arg0: Manifest[MultiBindType]): ScalaMultibinder[MultiBindType]

    Permalink
    Attributes
    protected
    Annotations
    @deprecated
    Deprecated

    (Since version 2019-10-16) Use bindMultiple[T]

Inherited from TwitterBaseModule

Inherited from TwitterModuleLifecycle

Inherited from Logging

Inherited from util.logging.Logging

Inherited from TwitterModuleFlags

Inherited from AbstractModule

Inherited from Module

Inherited from AnyRef

Inherited from Any

Ungrouped