Java Reference
In-Depth Information
Similarly, the javax.enterprise.inject.spi.BeanManager interface provides operations for obtaining
contextual references for beans, along with many operations that can be used with portable extensions. For instance,
the BeanManager can be used to obtain a reference to a bean by calling its getReference method, as demonstrated in
the following lines of code:
BeanManager beanManager;
beanManager.getReference(bean, beanType, creationalContext);
Most recently, with the release of CDI 1.1, the BeanManager can be used to obtain programmatic access to a
Producer , InjectionTarget , and AnnotatedType . To do so, the BeanManager must be obtained and then invoke the
method corresponding to the object that needs to be obtained. Table 7-2 lists the different methods that can be called
against the BeanManager in order to obtain access to these three types. By no means is the table an exhaustive list of all
methods available via the BeanManager , but it lists the new BeanManager methods.
Table 7-2. BeanManager Methods
Returns an AnnotatedType that may be used to read the annotations of the given
Java class or interface
Returns the AnnotatedType (s) discovered or added during container initialization
Returns a container-provided implementation of InjectionTarget for a given
AnnotatedType or throws an IllegalArgumentException if there is a definition error
associated with any injection point of the type
Returns the container's instance of an Extension class that is declared in the
META-INF/services file or throws an IllegalArgumentException if the container
does not contain an instance of the specified class
Returns a container provided implementation of Producer for a given
AnnotatedMethod or AnnotatedField or throws an IllegalArgumentException if
there is a definition error associated with the producer method or field
please see the online documentation for comprehensive details regarding the BeanManager interface:
Container Life-Cycle Events
The application server container fires a series of events that allow portable extensions to integrate with the container
initialization process. This series of events is known as the container life-cycle events . For instance, before the
container begins the bean discovery process, it must fire a BeforeBeanDiscovery event. After the bean discovery
process has completed, the AfterBeanDiscovery event is fired.
Search WWH ::

Custom Search