trait Injectable extends Wire
Provides injection DSL. You can extend it in your classes in order to use inject methods.
The only responsibility of this trait is to provide you with inject function (so it just provides nice syntax for injecting dependencies).
In order to actually find and inject dependencies, inject
method always
takes an implicit parameter of type Injector
.
Example:
Application (implicit inj: Injector) extends Injectable { protected val db = inject [Database] // database can now be used as an instance of Database class` }
- Alphabetic
- By Inheritance
- Injectable
- Wire
- 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
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
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
-
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
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
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
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
-
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
-
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
-
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
-
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
-
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
-
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
-
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
-
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
-
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
-
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
-
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
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
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()