Class/Object

com.escalatesoft.subcut.inject

NewBindingModule

Related Docs: object NewBindingModule | package inject

Permalink

class NewBindingModule extends BindingModule with Serializable

A class to create a new, immutable, binding module. In order to work, the constructor of this class takes a function to evaluate, and passes this on to a bindings method which can be used to resolve the bindingModule using the function on demand. The binding module loaned to the passed in function is mutable, allowing the convenient DSL to be used, then the bindings are copied to an immutable class upon exit of the bindings evaluation.

To use this class:

class ProductionBindings extends NewBindingModule(module => {
   import module._   // for convenience
   bind [DBLookup] to moduleInstanceOf [MySQLLookup]
   bind [WebService] to newInstanceOf [RealWebService]
   bind [Int] identifiedBy 'maxPoolSize toSingle 10   // could also use idBy instead of identifiedBy
   bind [QueryService] toProvider { implicit module => new SlowInitQueryService }
})
Annotations
@SerialVersionUID()
Linear Supertypes
Serializable, Serializable, BindingModule, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. NewBindingModule
  2. Serializable
  3. Serializable
  4. BindingModule
  5. AnyRef
  6. Any
  1. Hide All
  2. Show all
Visibility
  1. Public
  2. All

Instance Constructors

  1. new NewBindingModule(fn: (MutableBindingModule) ⇒ Unit)

    Permalink

    fn

    a function that takes a mutable binding module and initializes it with whatever bindings you want. The module will be frozen after creation of the bindings, but is mutable for the time you are defining it with the DSL.

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 andThen(other: BindingModule): BindingModule

    Permalink

    Merge this module with another.

    Merge this module with another. The resulting module will include all bindings from both modules, with this module winning if there are common bindings (binding override). If you prefer symbolic operators, ~ is an alias for this.

    other

    another BindingModule to cons with this one. Any duplicates will favor the bindings from this rather than other.

    Definition Classes
    BindingModule
  5. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  6. lazy val bindings: Map[BindingKey[_], Any]

    Permalink

    Abstract binding map definition

    Abstract binding map definition

    Definition Classes
    NewBindingModuleBindingModule
  7. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. final def eq(arg0: AnyRef): Boolean

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

    Permalink
    Definition Classes
    AnyRef → Any
  10. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  11. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  12. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  13. def inject[T](name: Option[String])(implicit arg0: Manifest[T]): T

    Permalink

    Inject for a given class with optional name.

    Inject for a given class with optional name. Whatever is bound to the class will be provided. If the name is given, only a matching class/name pair will be used, and it will not fall back to just providing an implementation based only on the class.

    name

    an optional name to use for the binding match

    returns

    the instance the binding was configured to return

    Definition Classes
    BindingModule
  14. def injectOptional[T](key: BindingKey[T]): Option[T]

    Permalink

    Retrieve an optional binding for class T with the given BindingKey, if no binding is available for the binding key, a None will be returned, otherwise the binding will be evaluated and an instance of a subclass of T will be returned.

    Retrieve an optional binding for class T with the given BindingKey, if no binding is available for the binding key, a None will be returned, otherwise the binding will be evaluated and an instance of a subclass of T will be returned.

    key

    a BindingKey to use for the lookup

    returns

    Option[T] containing either an instance subtype of T, or None if no matching binding is found.

    Definition Classes
    BindingModule
  15. def injectOptional[T](name: Option[String])(implicit arg0: Manifest[T]): Option[T]

    Permalink

    Retrieve an optional binding for class T with the optional name provided.

    Retrieve an optional binding for class T with the optional name provided. If no binding is available with the given class and optional name, a None will be returned, otherwise the binding will be evaluated and an instance of a subclass of T will be returned.

    name

    Option[String] name, if present will be matched, if None only class will be used for lookup (note, this also means any named bindings of the same type will not be matched)

    returns

    Option[T] containing either an instance subtype of T, or None if no matching binding is found.

    Definition Classes
    BindingModule
  16. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  17. def listBindings: Iterable[String]

    Permalink

    A convenient way to obtain a string representation of the current bindings in this module.

    A convenient way to obtain a string representation of the current bindings in this module. Useful for debugging.

    Definition Classes
    BindingModule
  18. def modifyBindings[A](fn: (MutableBindingModule) ⇒ A): A

    Permalink

    Provide a mutable copy of these bindings to a passed in function so that it can override the bindings for just the scope of that function.

    Provide a mutable copy of these bindings to a passed in function so that it can override the bindings for just the scope of that function. Useful for testing.

    fn

    a function that takes the new mutable binding copy and may use it within scope. Can return any type, and the any return from the function will be returned from this function.

    returns

    the value returned from the provided function.

    Definition Classes
    BindingModule
  19. final def ne(arg0: AnyRef): Boolean

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

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

    Permalink
    Definition Classes
    AnyRef
  22. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  23. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  24. final def wait(): Unit

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  27. def ~(other: BindingModule): BindingModule

    Permalink

    Merge this module with another.

    Merge this module with another. The resulting module will include all bindings from both modules, with this module winning if there are common bindings (binding override). If you prefer non-symbolic methods, "andThen" is an alias for this.

    other

    another BindingModule to cons with this one. Any duplicates will favor the bindings from this rather than other.

    Definition Classes
    BindingModule
    Annotations
    @inline()

Inherited from Serializable

Inherited from Serializable

Inherited from BindingModule

Inherited from AnyRef

Inherited from Any

Ungrouped