public interface BeanManager
The interface BeanManager
is the central point for dealing with CDI.
The BeanManager provides operations for resolving CDI Bean
s,
obtaining the Contextual References of them, etc. There are operations
related with;
CreationalContext
sModifier and Type | Method and Description |
---|---|
boolean |
areInterceptorBindingsEquivalent(Annotation interceptorBinding1,
Annotation interceptorBinding2)
Check whether the 2 given Interceptor Binding annotations are the same.
|
boolean |
areQualifiersEquivalent(Annotation qualifier1,
Annotation qualifier2)
Check whether the 2 given qualifiers are the same.
|
<T> AnnotatedType<T> |
createAnnotatedType(Class<T> type)
Returns a
AnnotatedType instance for the given
class. |
<T> Bean<T> |
createBean(BeanAttributes<T> attributes,
Class<T> beanClass,
InjectionTargetFactory<T> injectionTargetFactory)
Create a
Bean from the given bean attributes. |
<T,X> Bean<T> |
createBean(BeanAttributes<T> attributes,
Class<X> beanClass,
ProducerFactory<X> producerFactory)
Create a
Bean from the given bean attributes. |
BeanAttributes<?> |
createBeanAttributes(AnnotatedMember<?> member)
This method creates bean meta information from a given
AnnotatedMember . |
<T> BeanAttributes<T> |
createBeanAttributes(AnnotatedType<T> type)
This method creates bean meta information from a given
AnnotatedType . |
<T> CreationalContext<T> |
createCreationalContext(Contextual<T> contextual)
Returns a new creational context implementation.
|
InjectionPoint |
createInjectionPoint(AnnotatedField<?> field)
Create an
InjectionPoint for an annotated field. |
InjectionPoint |
createInjectionPoint(AnnotatedParameter<?> parameter)
Create an
InjectionPoint for an annotated parameter. |
<T> InjectionTarget<T> |
createInjectionTarget(AnnotatedType<T> type)
Creates a new instance of injection target Bean.
|
void |
fireEvent(Object event,
Annotation... qualifiers)
Fires an event with given even object and qualifiers.
|
Set<Bean<?>> |
getBeans(String name)
Returns set of beans with given Expression Language name.
|
Set<Bean<?>> |
getBeans(Type beanType,
Annotation... qualifiers)
Returns set of beans that their api types contain
given bean type and given qualifiers.
|
Context |
getContext(Class<? extends Annotation> scope)
Returns a context with given scope type.
|
javax.el.ELResolver |
getELResolver()
Returns CDI container Expression Language resolver.
|
<T extends Extension> |
getExtension(Class<T> extensionClass)
Resolves the Extension instance which gets used by this very BeanManager.
|
Object |
getInjectableReference(InjectionPoint injectionPoint,
CreationalContext<?> ctx)
Gets injection point bean reference.
|
<T> InjectionTargetFactory<T> |
getInjectionTargetFactory(AnnotatedType<T> type) |
Set<Annotation> |
getInterceptorBindingDefinition(Class<? extends Annotation> qualifier)
Returns a set of meta-annotations that are defined on the binding
|
int |
getInterceptorBindingHashCode(Annotation interceptorBinding) |
Bean<?> |
getPassivationCapableBean(String id)
Returns passivation capable bean given id.
|
<X> ProducerFactory<X> |
getProducerFactory(AnnotatedField<? super X> field,
Bean<X> declaringBean) |
<X> ProducerFactory<X> |
getProducerFactory(AnnotatedMethod<? super X> method,
Bean<X> declaringBean) |
int |
getQualifierHashCode(Annotation qualifier) |
Object |
getReference(Bean<?> bean,
Type beanType,
CreationalContext<?> ctx)
Returns a bean instance reference for the given bean.
|
Set<Annotation> |
getStereotypeDefinition(Class<? extends Annotation> stereotype)
Returns a set of meta-annotations that are defined on the stereotype type.
|
boolean |
isInterceptorBinding(Class<? extends Annotation> annotationType)
Returns true if given type is a interceptor binding, false otherwise.
|
boolean |
isNormalScope(Class<? extends Annotation> annotationType)
Returns true if given type is a normal scope type, false otherwise.
|
boolean |
isPassivatingScope(Class<? extends Annotation> annotationType)
Returns true if given type is a passivating scope type, false otherwise.
|
boolean |
isQualifier(Class<? extends Annotation> annotationType)
Returns true if given type is a qualifier, false otherwise.
|
boolean |
isScope(Class<? extends Annotation> annotationType)
Returns true if given type is a scope type, false otherwise.
|
boolean |
isStereotype(Class<? extends Annotation> annotationType)
Returns true if given type is a stereotype type, false otherwise.
|
<X> Bean<? extends X> |
resolve(Set<Bean<? extends X>> beans)
Returns a bean object that is resolved according to the type safe resolution rules.
|
List<Decorator<?>> |
resolveDecorators(Set<Type> types,
Annotation... qualifiers)
Returns a list of decorator.
|
List<Interceptor<?>> |
resolveInterceptors(InterceptionType type,
Annotation... interceptorBindings)
Returns a list of interceptor.
|
<T> Set<ObserverMethod<? super T>> |
resolveObserverMethods(T event,
Annotation... qualifiers)
Returns set of observer methods.
|
void |
validate(InjectionPoint injectionPoint)
Validates injection point.
|
javax.el.ExpressionFactory |
wrapExpressionFactory(javax.el.ExpressionFactory expressionFactory)
Wrapped around given expression factory and add CDI functionality.
|
Object getReference(Bean<?> bean, Type beanType, CreationalContext<?> ctx)
bean
- bean that its reference is gettingbeanType
- bean api type that is implemented by the proxyctx
- creational context is used to destroy any object with scope @Dependent
IllegalArgumentException
- if given bean type is not api type of the given bean objectIllegalStateException
- if this method gets called before the AfterDeploymentValidation event is fired.Object getInjectableReference(InjectionPoint injectionPoint, CreationalContext<?> ctx)
injectionPoint
- injection point definitionctx
- creational context that is passed to the Contextual.create(CreationalContext)
methodUnsatisfiedResolutionException
- if no bean found for the given injection pointAmbiguousResolutionException
- if more than one bean foundIllegalStateException
- if this method gets called before the AfterDeploymentValidation event is fired.<T> CreationalContext<T> createCreationalContext(Contextual<T> contextual)
Set<Bean<?>> getBeans(Type beanType, Annotation... qualifiers)
If no qualifier is given, @Current
is assumed.
beanType
- required bean typequalifiers
- required qualifiersIllegalArgumentException
- given bean type is a TypeVariable
IllegalArgumentException
- given qualifier annotation is not a qualifierIllegalArgumentException
- same qualifier is givenIllegalStateException
- if this method gets called before the AfterBeanDiscovery event is fired.Set<Bean<?>> getBeans(String name)
name
- name of the beanIllegalStateException
- if this method gets called before the AfterBeanDiscovery event is fired.Bean<?> getPassivationCapableBean(String id)
id
- bean idIllegalStateException
- if this method gets called before the AfterBeanDiscovery event is fired.<X> Bean<? extends X> resolve(Set<Bean<? extends X>> beans)
X
- bean class infobeans
- set of beansAmbiguousResolutionException
- if ambigious existsIllegalStateException
- if this method gets called before the AfterBeanDiscovery event is fired.void fireEvent(Object event, Annotation... qualifiers)
event
- observer event objectqualifiers
- event qualifiersIllegalArgumentException
- event object contains a TypeVariable
IllegalArgumentException
- given qualifier annotation is not a qualifierIllegalArgumentException
- same qualifier is given<T> Set<ObserverMethod<? super T>> resolveObserverMethods(T event, Annotation... qualifiers)
T
- event typeevent
- even objectqualifiers
- event qualifiersIllegalStateException
- if this method gets called before the AfterBeanDiscovery event is fired.List<Decorator<?>> resolveDecorators(Set<Type> types, Annotation... qualifiers)
types
- bean types of the decorated beanqualifiers
- decorated bean qualifiersIllegalArgumentException
- given qualifier annotation is not a qualifierIllegalArgumentException
- same qualifier is givenIllegalArgumentException
- if types is empty setIllegalStateException
- if this method gets called before the AfterBeanDiscovery event is fired.List<Interceptor<?>> resolveInterceptors(InterceptionType type, Annotation... interceptorBindings)
type
- interception typeinterceptorBindings
- interceptor bindingsIllegalArgumentException
- given binding annotation is not a bindingIllegalArgumentException
- same binding is givenIllegalArgumentException
- binding is not an interceptor bindingIllegalStateException
- if this method gets called before the AfterBeanDiscovery event is fired.void validate(InjectionPoint injectionPoint)
injectionPoint
- injection pointInjectionException
- if problem existIllegalStateException
- if this method gets called before the AfterBeanDiscovery event is fired.boolean isScope(Class<? extends Annotation> annotationType)
annotationType
- annotation typeboolean isNormalScope(Class<? extends Annotation> annotationType)
annotationType
- annotation typeboolean isPassivatingScope(Class<? extends Annotation> annotationType)
annotationType
- annotation typeboolean isQualifier(Class<? extends Annotation> annotationType)
annotationType
- annotation typeboolean areQualifiersEquivalent(Annotation qualifier1, Annotation qualifier2)
Nonbinding
into account by ignoring
those properties.qualifier1
- qualifier2
- true
if all non-nonbinding attributes are equals, false
otherwiseint getQualifierHashCode(Annotation qualifier)
qualifier
- Nonbinding
fields get ignoredboolean isInterceptorBinding(Class<? extends Annotation> annotationType)
annotationType
- annotation typeboolean areInterceptorBindingsEquivalent(Annotation interceptorBinding1, Annotation interceptorBinding2)
Nonbinding
into account by ignoring
those properties.interceptorBinding1
- interceptorBinding2
- true
if all non-nonbinding attributes are equals, false
otherwiseint getInterceptorBindingHashCode(Annotation interceptorBinding)
interceptorBinding
- Nonbinding
fields get ignoredboolean isStereotype(Class<? extends Annotation> annotationType)
annotationType
- annotation typeSet<Annotation> getInterceptorBindingDefinition(Class<? extends Annotation> qualifier)
qualifier
- binding classSet<Annotation> getStereotypeDefinition(Class<? extends Annotation> stereotype)
stereotype
- stereotype type classContext getContext(Class<? extends Annotation> scope)
scope
- scope type class typejavax.el.ELResolver getELResolver()
<T> AnnotatedType<T> createAnnotatedType(Class<T> type)
AnnotatedType
instance for the given
class.T
- class typetype
- classAnnotatedType
instance<T> InjectionTarget<T> createInjectionTarget(AnnotatedType<T> type)
T
- bean typetype
- annotated typeInjectionPoint createInjectionPoint(AnnotatedField<?> field)
InjectionPoint
for an annotated field.field
- IllegalArgumentException
- if there is a definition error on the given fieldInjectionPoint createInjectionPoint(AnnotatedParameter<?> parameter)
InjectionPoint
for an annotated parameter.parameter
- IllegalArgumentException
- if there is a definition error on the given parameter<T> InjectionTargetFactory<T> getInjectionTargetFactory(AnnotatedType<T> type)
T
- type
- InjectionTarget
s for the given AnnotatedType.<X> ProducerFactory<X> getProducerFactory(AnnotatedField<? super X> field, Bean<X> declaringBean)
X
- field
- declaringBean
- Producer
s for the given AnnotatedField.<X> ProducerFactory<X> getProducerFactory(AnnotatedMethod<? super X> method, Bean<X> declaringBean)
X
- method
- declaringBean
- Producer
s for the given AnnotatedMethod.<T> BeanAttributes<T> createBeanAttributes(AnnotatedType<T> type)
AnnotatedType
.
The created BeanAttributes can later be used to create a Bean
via createBean(BeanAttributes, Class, InjectionTargetFactory)
or
createBean(BeanAttributes, Class, ProducerFactory)
T
- type
- BeanAttributes<?> createBeanAttributes(AnnotatedMember<?> member)
AnnotatedMember
.
The created BeanAttributes can later be used to create a Bean
via createBean(BeanAttributes, Class, InjectionTargetFactory)
or
createBean(BeanAttributes, Class, ProducerFactory)
.member
- <T> Bean<T> createBean(BeanAttributes<T> attributes, Class<T> beanClass, InjectionTargetFactory<T> injectionTargetFactory)
Bean
from the given bean attributes.
This version of the method uses a given InjectionTargetFactory
.T
- attributes
- beanClass
- injectionTargetFactory
- <T,X> Bean<T> createBean(BeanAttributes<T> attributes, Class<X> beanClass, ProducerFactory<X> producerFactory)
Bean
from the given bean attributes.
This version of the method uses a given ProducerFactory
.T
- attributes
- beanClass
- producerFactory
- <T extends Extension> T getExtension(Class<T> extensionClass)
extensionClass
must be the effective class registered
into META-INF/services and not some base class.T
- extensionClass
- javax.el.ExpressionFactory wrapExpressionFactory(javax.el.ExpressionFactory expressionFactory)
expressionFactory
- expression factoryCopyright © 2018. All rights reserved.