winter / io.jentz.winter / WinterInjection

WinterInjection

open class WinterInjection

Abstraction to create, get and dispose a dependency graph from a class that can't make use of constructor injection.

For applications it is recommended to use the object version Injection directly and for libraries it is recommended to create a object version from WinterInjection instead.

See Also

Injection

Types

Adapter

interface Adapter

Adapter interface to provide application specific graph creation and retrieval strategy.

Constructors

<init>

WinterInjection()

Abstraction to create, get and dispose a dependency graph from a class that can't make use of constructor injection.

Properties

adapter

var adapter: WinterInjection.Adapter

Set the application specific adapter.

Functions

createGraph

fun createGraph(instance: Any, block: ComponentBuilderBlock? = null): Graph

Create and return dependency graph for instance.

createGraphAndInject

fun createGraphAndInject(instance: Any, injector: Injector, block: ComponentBuilderBlock? = null): Graph

Create and return dependency graph for instance and also pass the graph to the given injector.

fun <T : Any> createGraphAndInject(instance: T, injectSuperClasses: Boolean = false, block: ComponentBuilderBlock? = null): Graph

Create and return dependency graph for instance and inject all members into instance.

disposeGraph

fun disposeGraph(instance: Any): Unit

Dispose the dependency graph of the given instance.

getGraph

fun getGraph(instance: Any): Graph

Get dependency graph for instance.

inject

fun inject(instance: Any, injector: Injector): Unit

Get dependency graph for given instance and inject dependencies into injector.

fun <T : Any> inject(instance: T, injectSuperClasses: Boolean = false): Unit

Inject into instance by using the dependency graph of the instance. This uses MembersInjector and is useful in conjunction with Winters JSR330 annotation processor.

Extension Functions

useApplicationGraphOnlyAdapter

fun WinterInjection.useApplicationGraphOnlyAdapter(tree: WinterTree = GraphRegistry): Unit
fun WinterInjection.useApplicationGraphOnlyAdapter(application: WinterApplication): Unit

Register an ApplicationGraphOnlyAdapter on this WinterInjection instance.

Inheritors

Injection

object Injection : WinterInjection

Abstraction to create, get and dispose a dependency graph from a class that can't make use of constructor injection. This takes the burden off of the class to know how exactly a graph or parent graph is stored and how to create and store a new graph.