Interface InjectionPoint
Provides access to metadata about an injection point. May represent an injected field or a
parameter of a bean constructor, initializer method,
producer method, disposer method or observer method.
If the injection point does not belong to a bean or belongs to a synthetic bean, some methods may return null.
If the injection point is a dynamically obtained instance, then the required type and required qualifiers are
defined by the Instance and other metadata reflect the injection point of the Instance.
If the Instance is not injected, some methods may return null.
Occasionally, a bean with scope @Dependent needs to access metadata relating to the object to which it
belongs. The bean may inject an InjectionPoint representing the injection point into which the bean was injected.
For example, the following producer method creates injectable Loggers. The log category of a
Logger depends upon the class of the object into which it is injected.
@Produces
Logger createLogger(InjectionPoint injectionPoint) {
return Logger.getLogger(injectionPoint.getMember().getDeclaringClass().getName());
}
Only dependent objects may obtain information about the injection point to which they belong.
- Author:
- Gavin King, Pete Muir
-
Method Summary
Modifier and TypeMethodDescriptionReturns anAnnotatedFieldorAnnotatedParameter, depending on whether the injection point is a field or a constructor/method parameter.Bean<?>getBean()Returns theBeanthat defines the injection point.Returns theFieldin the case of field injection, theMethodin the case of method parameter injection, or theConstructorin the case of constructor parameter injection.Returns the required qualifiers of the injection point.getType()Returns the required type of injection point.booleanReturns whether the injection point is a decorator@Delegateinjection point.boolean
-
Method Details
-
getType
Type getType()Returns the required type of injection point.- Returns:
- the required type, never
null
-
getQualifiers
Set<Annotation> getQualifiers()Returns the required qualifiers of the injection point.- Returns:
- the required qualifiers, never
null
-
getBean
Bean<?> getBean()Returns theBeanthat defines the injection point.If the injection point belongs to a synthetic bean, may return
null. If the injection point does not belong to a bean or belongs to a dynamically obtained instance where theInstanceis not injected, returnsnull.- Returns:
- the bean that defines the injection point, may be
null
-
getMember
Member getMember()Returns theFieldin the case of field injection, theMethodin the case of method parameter injection, or theConstructorin the case of constructor parameter injection.If the injection point belongs to a synthetic bean, may return
null. If the injection point belongs to a dynamically obtained instance where theInstanceis not injected, returnsnull.- Returns:
- the member, may be
null
-
getAnnotated
Annotated getAnnotated()Returns anAnnotatedFieldorAnnotatedParameter, depending on whether the injection point is a field or a constructor/method parameter.If the injection point belongs to a synthetic bean, may return
null. If the injection point belongs to a dynamically obtained instance where theInstanceis not injected, returnsnull.May always return
nullwhen the container only supports CDI Lite.- Returns:
- the annotated member, may be
null
-
isDelegate
boolean isDelegate()Returns whether the injection point is a decorator@Delegateinjection point.- Returns:
trueif the injection point is a decorator delegate injection point, andfalseotherwise
-
isTransient
boolean isTransient()- Returns:
trueif the injection point is atransientfield, andfalseotherwise
-