-
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
andObserverMethod
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.CDI Lite implementations are not required to provide support for Portable Extensions.
- Author:
- David Allen, Antoine Sabot-Durand
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T> BeanConfigurator<T>
addBean()
Obtains a newBeanConfigurator
to configure a newBean
and add it at the end of the observer invocation.void
addBean(Bean<?> bean)
Fires an event of typeProcessBean
containing the givenBean
and then registers theBean
with the container, thereby making a bean which is not an interceptor nor a decorator available for injection into other beans.void
addContext(Context context)
Registers a customContext
object with the container.void
addDefinitionError(java.lang.Throwable t)
Registers a definition error with the container, causing the container to abort deployment after all observers have been notified.<T> ObserverMethodConfigurator<T>
addObserverMethod()
obtains a newObserverMethodConfigurator
to configure a newObserverMethod
and add it at the end of the observer invocation.void
addObserverMethod(ObserverMethod<?> observerMethod)
Fires an event of typeProcessObserverMethod
containing the givenObserverMethod
and then registers theObserverMethod
with the container, thereby making it available for event notifications.<T> AnnotatedType<T>
getAnnotatedType(java.lang.Class<T> type, java.lang.String id)
Obtain theAnnotatedType
that may be used to read the annotations of the given class or interface as defined during container initialization.<T> java.lang.Iterable<AnnotatedType<T>>
getAnnotatedTypes(java.lang.Class<T> type)
Obtain theAnnotatedType
s that may be used to read the annotations of the given class or interface as defined during container initialization.
-
-
-
Method Detail
-
addDefinitionError
void addDefinitionError(java.lang.Throwable t)
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:
java.lang.IllegalStateException
- if called outside of the observer method invocation
-
addBean
void addBean(Bean<?> bean)
Fires an event of typeProcessBean
containing the givenBean
and then registers theBean
with the container, thereby making a bean which is not an interceptor nor a decorator available for injection into other beans. The givenBean
may implementInterceptor
orDecorator
.- Parameters:
bean
- The bean to add to the deployment- Throws:
java.lang.IllegalStateException
- if called outside of the observer method invocation
-
addBean
<T> BeanConfigurator<T> addBean()
Obtains a newBeanConfigurator
to configure a newBean
and add it at the end of the observer invocation. It will then fire an event of typeProcessBean
containing the builtBean
from 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
BeanConfigurator
to configure the bean to add - Throws:
java.lang.IllegalStateException
- if called outside of the observer method invocation- Since:
- 2.0
-
addObserverMethod
void addObserverMethod(ObserverMethod<?> observerMethod)
Fires an event of typeProcessObserverMethod
containing the givenObserverMethod
and then registers theObserverMethod
with the container, thereby making it available for event notifications.- Parameters:
observerMethod
- The custom observer method to add to the deployment- Throws:
java.lang.IllegalStateException
- if called outside of the observer method invocation
-
addObserverMethod
<T> ObserverMethodConfigurator<T> addObserverMethod()
obtains a newObserverMethodConfigurator
to configure a newObserverMethod
and add it at the end of the observer invocation. It will then fire an event of typeProcessObserverMethod
containing the builtObserverMethod
from this configuration and then registers theObserverMethod
with 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
ObserverMethodConfigurator
instance - Throws:
java.lang.IllegalStateException
- if called outside of the observer method invocation- Since:
- 2.0
-
addContext
void addContext(Context context)
Registers a customContext
object with the container.- Parameters:
context
- The custom context to add to the deployment- Throws:
java.lang.IllegalStateException
- if called outside of the observer method invocation
-
getAnnotatedType
<T> AnnotatedType<T> getAnnotatedType(java.lang.Class<T> type, java.lang.String id)
Obtain theAnnotatedType
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
- theClass
objectid
- the type identifier. If null, the fully qualifier class name of type is used- Returns:
- the
AnnotatedType
- Throws:
java.lang.IllegalStateException
- if called outside of the observer method invocation- Since:
- 1.1
-
getAnnotatedTypes
<T> java.lang.Iterable<AnnotatedType<T>> getAnnotatedTypes(java.lang.Class<T> type)
Obtain theAnnotatedType
s 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
- theClass
object- Returns:
- the
AnnotatedType
s - Throws:
java.lang.IllegalStateException
- if called outside of the observer method invocation- Since:
- 1.1
-
-