public class StandardInjectionProvider extends DirectInstantiationProvider
Resolution objects that roughly follows the documentation as given in Inject.
The following is a summary of the instantiation's behavior and its deviations.
If available, the constructor with @Inject is used. Multiple @Inject constructors results in
an exception being thrown. Otherwise, if there is only one constructor, of public visibility taking no arguments,
it is taken. For private classes (inner classes), a sole no-args constructor is also considered.
Finally, the no-args constructor of any visibility is taken if it belongs to a class that has @Inject
fields. In this case, the no-args constructor is not required to be the only constructor of the class.
Fields with @Inject are injected. They may be static (not recommended). If a final field is annotated
with @Inject, an exception is thrown.
Method injection is not supported. Consequently, if a method with @Inject is found on the class or
any of its parents, an exception is thrown.
NoMethodScan and NoFieldScan are respected.
| Constructor and Description |
|---|
StandardInjectionProvider() |
| Modifier and Type | Method and Description |
|---|---|
protected List<Field> |
getFieldsToInject(Class<?> clazz)
Returns the fields in the class and its parents that should be injected.
|
protected <T> Constructor<T> |
getInjectionConstructor(Class<T> clazz)
Returns the constructor to be used for injection.
|
<T> Resolution<T> |
safeGet(Class<T> clazz)
Gets the instantiation for the class or null if unavailable.
|
protected void |
validateInjection(Class<?> clazz,
Constructor<?> constructor,
List<Field> fields)
Assures that the class and the members relevant for the instantiation form a valid combination.
|
resolveclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitonAnnotation, onProvider, onProviderClass, postProcesspublic <T> Resolution<T> safeGet(Class<T> clazz)
DirectInstantiationProvidersafeGet in class DirectInstantiationProviderT - the class' typeclazz - the class to process@Nullable protected <T> Constructor<T> getInjectionConstructor(Class<T> clazz)
@Inject constructors.T - the class' typeclazz - the class to processnull if there is no constructor suitable for injectionprotected List<Field> getFieldsToInject(Class<?> clazz)
clazz - the class to processprotected void validateInjection(Class<?> clazz, Constructor<?> constructor, List<Field> fields)
clazz - the class to instantiateconstructor - the constructor to instantiate withfields - the fields to injectCopyright © 2017. All rights reserved.