Module jakarta.cdi

Interface InjectionPoint


public 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 is a dynamically selected reference obtained then the metadata obtain reflects the injection point of the Instance, with the required type and any additional required qualifiers defined by Instance.select().

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 Logger s. 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.