Package org.int4.dirk.spi.instantiation
Interface InjectionTargetExtension<T,E>
-
- Type Parameters:
T- the type handledE- the element type required
public interface InjectionTargetExtension<T,E>An interface to allow for custom handling of injection targets of typeT. The target class must be an interface with at least one type variable.Whenever an injection target of type
Tneeds injection this extension will be called to provide the actual value.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.reflect.TypegetElementType(java.lang.reflect.Type type)Returns the element type of the given type by unwrapping the given type.TgetInstance(InstantiationContext<E> context)Creates an instance of typeTusing the givenInstantiationContext.java.lang.Class<?>getTargetClass()Returns the target class extended by this extension.java.util.Set<TypeTrait>getTypeTraits()Returns theTypeTraits of this extension.
-
-
-
Method Detail
-
getTargetClass
java.lang.Class<?> getTargetClass()
Returns the target class extended by this extension.- Returns:
- a
Class, nevernull
-
getElementType
java.lang.reflect.Type getElementType(java.lang.reflect.Type type)
Returns the element type of the given type by unwrapping the given type. Returningnullor the same type is not allowed.- Parameters:
type- aTypeto unwrap, cannot benull- Returns:
- the element type of the given type by unwrapping the given type, never
null
-
getTypeTraits
java.util.Set<TypeTrait> getTypeTraits()
Returns theTypeTraits of this extension.- Returns:
- a set of
TypeTrait, nevernullor containsnull, but can be empty
-
getInstance
T getInstance(InstantiationContext<E> context) throws CreationException, AmbiguousResolutionException, UnsatisfiedResolutionException, ScopeNotActiveException
Creates an instance of typeTusing the givenInstantiationContext. Returningnullis allowed to indicate the absence of a value. Depending on the destination where the value is used this can meannullis injected (methods and constructors), that the value is not injected (fields) or that anUnsatisfiedResolutionExceptionis thrown (direct instance resolver call).- Parameters:
context- anInstantiationContext, cannot benull- Returns:
- an instance of type
T, can benull - Throws:
CreationException- when the instance could not be createdAmbiguousResolutionException- when multiple instances matched but at most one was requiredUnsatisfiedResolutionException- when no instance matched but at least one was requiredScopeNotActiveException- when the scope for the produced type is not active
-
-