There is lots of useful metadata information that is present on an injection point, which is represented in the javax.enterprise.inject.spi.InjectionPoint
interface. Weld provides an implementation of InjectionPoint
with @Dependent
scope and @Default
qualifier for us to retrieve the metadata.
The injection point provides the following functions:
getBean(): This returns the
Bean
object of the bean defined on the injection pointgetType(): This returns the bean type of the injection point
getQualifiers(): This returns all the qualifiers of the injection point
getMember(): This returns a different instance depending on whether the injection point utilizes field injection (
Field
), method parameter injection (Method
), or constructor parameter injection (Constructor
)getAnnotated(): This returns
AnnotatedField
for field injection orAnnotatedParameter
for method and constructor parameter injection
When we have an @Dependent
scoped bean, there are occasions when it needs...