trait Module extends WordBinder with InjectorWithLifecycle[Module] with Injectable with MutableInjectorUser with ShutdownHookLifecycleManager
Module is a place where you declare your bindings. It's also the most common injector that you can use in most cases. It's a mutable injector so it can have a lifecycle and it also provides nice DSL for the bindings.
Module is an Injectable instance thanks to that you can inject other dependencies in module's bindings.
- Alphabetic
- By Inheritance
- Module
- ShutdownHookLifecycleManager
- LifecycleManager
- MutableInjectorUser
- Injectable
- Wire
- InjectorWithLifecycle
- MutableInjector
- Initializeable
- Freezable
- Injector
- WordBinder
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
def
++[I <: Injector, R <: Injector](other: I)(implicit comp: CanCompose[Module.this.type, I, R]): R
Composes two injectors.
Composes two injectors. Polymorphic, needs CanCompose trait implementation available in the scope
- I
injector's type to be composed with
- R
resulting injector's type
- other
other injector to be composed with
- comp
CanCompose implementation that will handle the composition of the two injectors
- returns
composed injector, depends on CanCompose trait's implementation
- Definition Classes
- Injector
-
def
::[I <: Injector, R <: Injector](other: I)(implicit comp: CanCompose[I, Module.this.type, R]): R
Composes two injectors.
Composes two injectors. Note that the operands are inverted because the method starts with ":" Polymorphic, needs CanCompose trait implementation available in the scope
- I
injector's type to be composed with
- R
resulting injector's type
- other
other injector to be composed with
- comp
CanCompose implementation that will handle the composition of the two injectors
- returns
composed injector, depends on CanCompose trait's implementation
- Definition Classes
- Injector
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
val
IgnoringErrorHandler: (Throwable) ⇒ Boolean
- Definition Classes
- LifecycleManager
-
def
addDestroyable(fn: () ⇒ Unit): Unit
- Definition Classes
- ShutdownHookLifecycleManager → LifecycleManager
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
bind[T](implicit arg0: scala.reflect.api.JavaUniverse.TypeTag[T]): BindHelper[T]
- Definition Classes
- WordBinder
-
def
binding: BindHelper[Any]
- Definition Classes
- WordBinder
-
val
by: ByWord
Convenience field to make the injection look more readable when used with default values for the injection.
Convenience field to make the injection look more readable when used with default values for the injection.
Example:
inject [Database] (by default defaultDb)
- Attributes
- protected
- Definition Classes
- Injectable
-
implicit
def
canBeIdentifiedToConstraints[T](target: T)(implicit arg0: CanBeIdentifier[T]): InjectConstraints[Nothing]
Implicit cast of classes that can be identifiers to an
InjectConstraints
with the identified as a first element.Implicit cast of classes that can be identifiers to an
InjectConstraints
with the identified as a first element.Often used when a list of identifiers should be passed (for example for
inject(constraint)
method).This lets us to put the identifier in a first place to make the parameters look readable.
- T
type that qualifies as an identifier
- target
Instance of a class that qualifies as an identifier
- returns
InjectConstraints
- Attributes
- protected
- Definition Classes
- Injectable
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
destroy(errorHandler: (Throwable) ⇒ Boolean = IgnoringErrorHandler): Unit
- Definition Classes
- ShutdownHookLifecycleManager → LifecycleManager
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getBinding(identifiers: List[Identifier]): Option[Binding]
Single binding lookup
Single binding lookup
- identifiers
binding's identifiers
- returns
option with binding (
None
if not found)
- Definition Classes
- InjectorWithLifecycle → Injector
-
def
getBindingInternal(identifiers: List[Identifier]): Option[BindingWithLifecycle]
Binding lookup logic
Binding lookup logic
- identifiers
list of identifiers identifying a dependency
- returns
a binding identified by identifiers
- Definition Classes
- Module → InjectorWithLifecycle
-
final
def
getBindings(identifiers: List[Identifier]): List[Binding]
List of bindings lookup
List of bindings lookup
- identifiers
bindings identifiers
- returns
list of found bindings
- Definition Classes
- InjectorWithLifecycle → Injector
-
def
getBindingsInternal(identifiers: List[Identifier]): List[BindingWithLifecycle]
Bindings lookup logic
Bindings lookup logic
- identifiers
list of identifiers identifying dependencies
- returns
a list of bindings identified by identifiers
- Definition Classes
- Module → InjectorWithLifecycle
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
val
identified: IdentifiedWord[Nothing]
Convenience field to make the injection look more readable when used with identifiers.
Convenience field to make the injection look more readable when used with identifiers.
Example:
inject [Database] (identified by 'local)
- Attributes
- protected
- Definition Classes
- Injectable
-
def
init(lifecycleManager: LifecycleManager): () ⇒ Unit
Initializes bindings that are not Lazy
Initializes bindings that are not Lazy
- lifecycleManager
entity that will manage the lifecycle of the eager bindings
- Attributes
- protected
- Definition Classes
- Module → Initializeable
-
def
initEagerWordBindings(lifecycleManager: LifecycleManager): () ⇒ Unit
- Attributes
- protected
- Definition Classes
- WordBinder
-
def
initNonLazy(): Module
Initializes binding that are not lazy
Initializes binding that are not lazy
- returns
initializeable injector
- Definition Classes
- Initializeable
-
def
inject[T](constraints: ⇒ InjectConstraints[T])(implicit injector: Injector, tt: scala.reflect.api.JavaUniverse.TypeTag[T], nn: NotNothing[T]): T
Injects a dependency defined by a constraint.
Injects a dependency defined by a constraint.
Usually used when there are more than one injections for a defined type
T
Example:
binding identifiedBy 'host to "hostName" val host = inject[String]('host) // equals to "hostName" val db = inject (by default defaultDb) // notice that type `T` is optional in inferred in this case
- T
type of the injected dependency
- constraints
constraints helping to define what dependency of the type
T
to inject (typically an identifier, string or a default value)- injector
implicit Injector, should be defined in the scope. It's used to lookup bindings
- tt
ensures that meta-information if type
T
is available at the runtime- nn
ensures, that type
T
is not inferred asNothing
by scala compiler, since inject needs to know the actual type at the runtime- returns
instance of injected dependency
- Attributes
- protected
- Definition Classes
- Injectable
-
def
inject[T](implicit injector: Injector, tt: scala.reflect.api.JavaUniverse.TypeTag[T], nn: NotNothing[T]): T
Injects a dependency that was previously defined in a module
Injects a dependency that was previously defined in a module
Example:
val database = inject [Database] // database can now be used as an instance of Database class
- T
type of the injected dependency
- injector
implicit Injector, should be defined in the scope. It's used to lookup bindings
- tt
ensures that meta-information if type T is available at the runtime
- nn
ensures, that type T is not inferred as
Nothing
by scala compiler, since inject needs to know the actual type at the runtime- returns
instance of injected dependency
- Attributes
- protected
- Definition Classes
- Injectable
-
def
injectAll(identifiers: Identifier*)(implicit injector: Injector): List[Any]
Injects all dependencies that are defined by identifiers.
Injects all dependencies that are defined by identifiers.
- identifiers
identifiers that were defined in module for requested injections
- injector
implicit Injector, should be defined in the scope. It's used to lookup bindings
- returns
a list of injected instances defined by identifiers
- Attributes
- protected
- Definition Classes
- Injectable
-
def
injectAllOfType[T](identifiers: Identifier*)(implicit injector: Injector, tt: scala.reflect.api.JavaUniverse.TypeTag[T], nn: NotNothing[T]): List[T]
Inject all dependencies of type
T
that were defined in a module and that are defined by supplied identifiers.Inject all dependencies of type
T
that were defined in a module and that are defined by supplied identifiers.- T
type of the injected dependency
- identifiers
identifiers that were defined in module for requested injections
- injector
implicit Injector, should be defined in the scope. It's used to lookup bindings
- tt
ensures that meta-information if type
T
is available at the runtime- nn
ensures, that type
T
is not inferred asNothing
by scala compiler, since inject needs to know the actual type at the runtime- returns
a list of injected instances satisfying the type
T
constraint and identifiers
- Attributes
- protected
- Definition Classes
- Injectable
-
def
injectAllOfType[T](implicit injector: Injector, tt: scala.reflect.api.JavaUniverse.TypeTag[T], nn: NotNothing[T]): List[T]
Inject all dependencies of type
T
that were defined in a module.Inject all dependencies of type
T
that were defined in a module.- T
type of the injected dependency
- injector
implicit Injector, should be defined in the scope. It's used to lookup bindings
- tt
ensures that meta-information if type
T
is available at the runtime- nn
ensures, that type
T
is not inferred asNothing
by scala compiler, since inject needs to know the actual type at the runtime- returns
a list of injected instances satisfying the type
T
constraint
- Attributes
- protected
- Definition Classes
- Injectable
-
def
injectProvider[T](constraints: ⇒ InjectConstraints[T])(implicit injector: Injector, tt: scala.reflect.api.JavaUniverse.TypeTag[T], nn: NotNothing[T]): () ⇒ T
Injects a dependency (defined by a constraint) that was previously defined as a provider in a module.
Injects a dependency (defined by a constraint) that was previously defined as a provider in a module.
Usually used when there are more than one provider for a defined type
T
.- T
type of the injected dependency
- constraints
constraints helping to define what dependency of type
T
to inject (typically an identifier, string or a default value)- injector
implicit Injector, should be defined in the scope. It's used to lookup bindings
- tt
ensures that meta-information if type
T
is available at the runtime- nn
ensures, that type
T
is not inferred asNothing
by scala compiler, since inject needs to know the actual type at the runtime- returns
a new instance of injected dependency
- Attributes
- protected
- Definition Classes
- Injectable
-
def
injectProvider[T](implicit injector: Injector, tt: scala.reflect.api.JavaUniverse.TypeTag[T], nn: NotNothing[T]): () ⇒ T
Injects a dependency that was previously defined as a provider in a module
Injects a dependency that was previously defined as a provider in a module
- T
type of the injected dependency
- injector
implicit Injector, should be defined in the scope. It's used to lookup bindings
- tt
ensures that meta-information if type
T
is available at the runtime- nn
ensures, that type
T
is not inferred asNothing
by scala compiler, since inject needs to know the actual type at the runtime- returns
a new instance of injected dependency
- Attributes
- protected
- Definition Classes
- Injectable
-
def
injectWithConstructorDefault[T, C](paramName: String)(implicit injector: Injector, tt: scala.reflect.api.JavaUniverse.TypeTag[T], ct: scala.reflect.api.JavaUniverse.TypeTag[C]): T
Injects a dependency defined by type
T
.Injects a dependency defined by type
T
. If dependency is not found, initializes it with the default value from the constructor of typeT
.This implies, that constructor must have one constructor with parameter
paramName
which has a default value. Method is part ofinjected
macro implementation and not intended to be used outside of it.Uses reflection.
- T
type of the injected dependency
- C
class of constructor in case dependency cannot be found by
T
identifier- paramName
name of the constructor argument with a default value
- injector
implicit Injector, should be defined in the scope. It's used to lookup bindings
- tt
ensures that meta-information if type
T
is available at the runtime- ct
ensures that meta-information if type
C
is available at the runtime- returns
instance of injected dependency. If not found by, initializes one using constructor
C
- Attributes
- protected
- Definition Classes
- Injectable
-
def
injectWithDefault[T](injector: Injector, default: ⇒ T)(identifiers: List[Identifier]): T
Setup an injection that returns default value if an injection with supplied identifiers is not found.
Setup an injection that returns default value if an injection with supplied identifiers is not found.
- T
type of the injected dependency
- injector
current Injector, used to lookup bindings
- default
default value to return in case injection is not found
- identifiers
identifiers that define requested injection
- returns
injection defined by identifiers or default value if injection is not found
- Attributes
- protected
- Definition Classes
- Injectable
-
macro
def
injected[T](overrides: Tuple2[String, _]*): T
- Definition Classes
- Wire
-
macro
def
injected[T](overrides: Tuple2[Symbol, _]*): T
- Definition Classes
- Wire
-
macro
def
injected[T]: T
- Definition Classes
- Wire
-
implicit
def
injector: Injector
- Definition Classes
- MutableInjectorUser
-
implicit
val
injectorFn: () ⇒ Injector
- Definition Classes
- MutableInjectorUser
-
def
injector_=(newParentInjector: Injector): Unit
Mutates current injector replacing it with the one in the parameters.
Mutates current injector replacing it with the one in the parameters. Works only if current injector is not frozen
- newParentInjector
the replacement for current injector
- Definition Classes
- MutableInjectorUser
-
def
isFrozen: Boolean
Determines if the injector is frozen
Determines if the injector is frozen
- returns
true if injector may no longer be modified, false otherwise
- Attributes
- protected
- Definition Classes
- Initializeable → Freezable
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
noBindingFound(identifiers: List[Identifier]): Nothing
Helper method for throwing a readable exception when a binding could not be found.
Helper method for throwing a readable exception when a binding could not be found.
- identifiers
a list of identifiers
- Attributes
- protected
- Definition Classes
- Injectable
-
def
notRequired(identifier: Identifier): Identifier
- Definition Classes
- WordBinder
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
partialInit(lifecycleManager: LifecycleManager): Option[() ⇒ Unit]
Composes function for initialization
Composes function for initialization
- lifecycleManager
where to look for initializations
- returns
initialization function
- Definition Classes
- Initializeable
-
def
required(identifier: Identifier): Identifier
- Definition Classes
- WordBinder
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
when(condition: ⇒ Condition)(fn: ⇒ Unit): Unit
- Definition Classes
- WordBinder
-
lazy val
wordBindings: List[BindingWithLifecycle]
- Definition Classes
- WordBinder