java.lang.Object
org.elasticsearch.injection.Injector
The main object for dependency injection.
Allows the user to specify the requirements, then call inject(java.util.Collection<? extends java.lang.Class<?>>) to create an object plus all its dependencies.
Implementation note: this class itself contains logic for specifying the injection requirements;
the actual injection operations are performed in other classes like Planner and PlanInterpreter,
-
Method Summary
Modifier and TypeMethodDescriptionInstructs the injector to instantiateclassToProcessin accordance with whatever annotations may be present on that class.addClasses(Collection<Class<?>> classesToProcess) Equivalent to multiple chained calls toaddClass(java.lang.Class<?>).<T> InjectoraddInstance(Class<? super T> type, T object) Indicates thatobjectis to be injected for parameters of typetype.<T> InjectoraddInstance(Object object) Equivalent toaddInstance(object.getClass(), object).addInstances(Collection<?> objects) Equivalent to multiple calls toaddInstance(Object).static Injectorcreate()inject(Collection<? extends Class<?>> resultTypes) Main entry point.
-
Method Details
-
create
-
addClass
Instructs the injector to instantiateclassToProcessin accordance with whatever annotations may be present on that class.There are only three ways the injector can find out that it must instantiate some class:
- This method
-
The parameter passed to
inject(java.util.Collection<? extends java.lang.Class<?>>) - A constructor parameter of some other class being instantiated, having exactly the right class (not a supertype)
- Returns:
this
-
addClasses
Equivalent to multiple chained calls toaddClass(java.lang.Class<?>). -
addInstance
Equivalent toaddInstance(object.getClass(), object). -
addInstances
Equivalent to multiple calls toaddInstance(Object). -
addInstance
Indicates thatobjectis to be injected for parameters of typetype. The given object is treated as though it had been instantiated by the injector. -
inject
Main entry point. Causes objects to be constructed.- Returns:
Mapwhose keys are all the requestedresultTypesand whose values are all the instances of those types.
-