Package jakarta.enterprise.inject.spi
Interface AfterBeanDiscovery
public interface AfterBeanDiscovery
The event type of the second event fired by the container when it has fully completed the bean discovery process, validated
that there are no definition errors relating to the discovered beans, and registered Bean
and ObserverMethod objects for the discovered beans, but before detecting deployment
problems.
A portable extension may take advantage of this event to register beans, interceptors, decorators, observer methods and custom context objects with the container.
void afterBeanDiscovery(@Observes AfterBeanDiscovery event, BeanManager manager) { ... }
If any observer method of the AfterBeanDiscovery event throws an exception, the exception is treated as a definition
error by the container.
-
Method Summary
Modifier and TypeMethodDescription<T> BeanConfigurator<T>addBean()Obtains a newBeanConfiguratorto configure a newBeanand add it at the end of the observer invocation.voidFires an event of typeProcessBeancontaining the givenBeanand then registers theBeanwith the container, thereby making a bean which is not an interceptor nor a decorator available for injection into other beans.voidaddContext(Context context) Registers a customContextobject with the container.voidRegisters a definition error with the container, causing the container to abort deployment after all observers have been notified.<T> ObserverMethodConfigurator<T>obtains a newObserverMethodConfiguratorto configure a newObserverMethodand add it at the end of the observer invocation.voidaddObserverMethod(ObserverMethod<?> observerMethod) Fires an event of typeProcessObserverMethodcontaining the givenObserverMethodand then registers theObserverMethodwith the container, thereby making it available for event notifications.<T> AnnotatedType<T>getAnnotatedType(Class<T> type, String id) Obtain theAnnotatedTypethat may be used to read the annotations of the given class or interface as defined during container initialization.<T> Iterable<AnnotatedType<T>>getAnnotatedTypes(Class<T> type) Obtain theAnnotatedTypes that may be used to read the annotations of the given class or interface as defined during container initialization.
-
Method Details
-
addDefinitionError
Registers a definition error with the container, causing the container to abort deployment after all observers have been notified.- Parameters:
t- The definition error as aThrowable- Throws:
IllegalStateException- if called outside of the observer method invocation
-
addBean
Fires an event of typeProcessBeancontaining the givenBeanand then registers theBeanwith the container, thereby making a bean which is not an interceptor nor a decorator available for injection into other beans. The givenBeanmay implementInterceptororDecorator.- Parameters:
bean- The bean to add to the deployment- Throws:
IllegalStateException- if called outside of the observer method invocation
-
addBean
Obtains a newBeanConfiguratorto configure a newBeanand add it at the end of the observer invocation. It will then fire an event of typeProcessBeancontaining the builtBeanfrom this configuration and then register it with the container, thereby making it available for injection into other beans. Each call returns a new BeanConfigurator.- Type Parameters:
T- type of bean- Returns:
- a non reusable
BeanConfiguratorto configure the bean to add - Throws:
IllegalStateException- if called outside of the observer method invocation- Since:
- 2.0
-
addObserverMethod
Fires an event of typeProcessObserverMethodcontaining the givenObserverMethodand then registers theObserverMethodwith the container, thereby making it available for event notifications.- Parameters:
observerMethod- The custom observer method to add to the deployment- Throws:
IllegalStateException- if called outside of the observer method invocation
-
addObserverMethod
obtains a newObserverMethodConfiguratorto configure a newObserverMethodand add it at the end of the observer invocation. It will then fire an event of typeProcessObserverMethodcontaining the builtObserverMethodfrom this configuration and then registers theObserverMethodwith the container, thereby making it available for event notifications. Each call returns a new ObserverMethodConfigurator.- Type Parameters:
T- type of the event the configured ObserverMethod will observe- Returns:
- a non reusable
ObserverMethodConfiguratorinstance - Throws:
IllegalStateException- if called outside of the observer method invocation- Since:
- 2.0
-
addContext
Registers a customContextobject with the container.- Parameters:
context- The custom context to add to the deployment- Throws:
IllegalStateException- if called outside of the observer method invocation
-
getAnnotatedType
Obtain theAnnotatedTypethat may be used to read the annotations of the given class or interface as defined during container initialization.- Type Parameters:
T- the class or interface- Parameters:
type- theClassobjectid- the type identifier. If null, the fully qualifier class name of type is used- Returns:
- the
AnnotatedType - Throws:
IllegalStateException- if called outside of the observer method invocation- Since:
- 1.1
-
getAnnotatedTypes
Obtain theAnnotatedTypes that may be used to read the annotations of the given class or interface as defined during container initialization.- Type Parameters:
T- the class or interface- Parameters:
type- theClassobject- Returns:
- the
AnnotatedTypes - Throws:
IllegalStateException- if called outside of the observer method invocation- Since:
- 1.1
-