Package guru.zoroark.tegral.di.environment
Environment classes and functions. Environments manage pools of inter-dependent and injectable components using different heuristics.
Types
A declaration within an environment that is being built. These declarations can be:
A map that maps identifiers to declarations.
The general contract is:
For any key-value pair, key == value.identifier
For any key-value pair, key: Identifier of T => value: Declaration of T
The empty qualifier object must be used when there is no qualifier being used.
Data objects that contain all of the information passed to InjectionEnvironment constructors to let them initialize their data.
An injection scope that delegates the injection to the given environment (for inject
) or its meta-environment (for meta
).
A qualifier specifically intended to be used for fully qualifying a type.
Identifies an injectable component via its type and optionally via other elements called qualifiers.
A module that can be injected in environments. At their core, injectable modules are just lists of declarations that get copied over when adding this module to environments.
An injection environment is, in a nutshell, a container for injectable components. These injectable components can be retrieved in two ways:
An environment kind is a facility for building InjectionEnvironment in a nicer way. This should be implemented by the companion object of an InjectionEnvironment class.
An injection scope provides an entrypoint for components to retrieve the dependencies they need.
An injection scope without meta-related operations. Because InjectionScope.meta
itself returns (in theory) an InjectionScope, people may do scope.meta.meta.meta.meta...
to infinity and beyond, which does not make sense. In order to prevent this, InjectionScope.meta
instead returns a MetalessInjectionScope.
An injection environment implementation with a mixed evaluation strategy.
A multi-qualifier represents multiple qualifiers grouped as a set. This is useful for combining qualifiers (e.g. a named qualifier and a type qualifier).
A qualifier that is based on a string. You can also use named to construct name qualifiers in a more DSL-ish approach.
Qualifiers are simple objects that can be used within Identifier objects to provide additional differentiators between two same-type objects or components.
A declaration that can be built into an IdentifierResolver.
An object that contains a scope. For use as a receiver in lambdas (e.g. ScopedSupplier)
A supplier of T that takes a ScopedContext as a receiver.
A declaration within an EnvironmentContext.
An injection scope that delegates the injection to the given environment, without any support for injecting from meta-environments.
Functions
Creates an injection scope based on the given environment. If the given environment supports meta-environments (i.e. if it is extensible), an ExtensibleEnvironmentBasedScope will be returned. Otherwise, a SimpleEnvironmentBasedScope is used.
Retrieves the declaration that corresponds to the given type parameter. This function does not check for the validity or coherence of the returned declaration.
Gets the component identified by the given type turned into an Identifier with an optional qualifier. Throws an exception if no component with this identifier exists.
Gets the component identified by the given type turned into an Identifier with an optional qualifier. Returns null if no component with this identifier exists.
Create an injector for the given identifier. See InjectionScope.inject for more information.
Create an injector for the given class, turned to an identifier, and an optional qualifier. See InjectionScope.inject for more information.
Creates a NameQualifier with the given name.
Create an injector for the given class and optional qualifier. If such an identifier cannot be found within the environment, returns null (unlike other functions which throw a ComponentNotFoundException).
Creates a ScopedContext
that contains the given scope as-is as a property.
Creates a full type qualifier with the given T as the type.
Creates a full type qualifier with the given KType as the type.