javax.enterprise.inject.spi
Interface BeanManager


public interface BeanManager

The interface Manager provides operations for obtaining the contextual instance of the webbeans. There are operations related with;

There is always one root manager in the system. You can set the current activity via call to the BeanManager#setCurrent(Class) method.

Version:
$Rev$ $Date$

Method Summary
<T> AnnotatedType<T>
createAnnotatedType(Class<T> type)
          Returns a AnnotatedType instance for the given class.
<T> CreationalContext<T>
createCreationalContext(Contextual<T> contextual)
          Returns a new creational context implementation.
<T> InjectionTarget<T>
createInjectionTarget(AnnotatedType<T> type)
          Creates a new instance of injection target.
 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 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 el resolver.
 Object getInjectableReference(InjectionPoint injectionPoint, CreationalContext<?> ctx)
          Gets injection point bean reference.
 Set<Annotation> getInterceptorBindingDefinition(Class<? extends Annotation> qualifier)
          Returns a set of meta-annotations that are defined on the binding
 Bean<?> getPassivationCapableBean(String id)
          Returns passivation capable bean given id.
 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.
 

Method Detail

getReference

Object getReference(Bean<?> bean,
                    Type beanType,
                    CreationalContext<?> ctx)
Returns a bean instance reference for the given bean.

Parameters:
bean - bean that its reference is getting
beanType - bean api type that is implemented by the proxy
ctx - creational context is used to destroy any object with scope @Dependent
Returns:
bean reference
Throws:
IllegalArgumentException - if given bean type is not api type of the given bean object

getInjectableReference

Object getInjectableReference(InjectionPoint injectionPoint,
                              CreationalContext<?> ctx)
Gets injection point bean reference.

Parameters:
injectionPoint - injection point definition
ctx - creational context that is passed to the Contextual.create(CreationalContext) method
Returns:
bean reference
Throws:
UnsatisfiedResolutionException - if no bean found for the given injection point
AmbiguousResolutionException - if more than one bean found

createCreationalContext

<T> CreationalContext<T> createCreationalContext(Contextual<T> contextual)
Returns a new creational context implementation.

Returns:
new creational context

getBeans

Set<Bean<?>> getBeans(Type beanType,
                      Annotation... qualifiers)
Returns set of beans that their api types contain given bean type and given qualifiers.

If no qualifier is given, @Current is assumed.

Parameters:
beanType - required bean type
qualifiers - required qualifiers
Returns:
set of beans
Throws:
IllegalArgumentException - given bean type is a TypeVariable
IllegalArgumentException - given qualifier annotation is not a qualifier
IllegalArgumentException - same qualifier is given

getBeans

Set<Bean<?>> getBeans(String name)
Returns set of beans with given name.

Parameters:
name - name of the bean
Returns:
set of beans with given name

getPassivationCapableBean

Bean<?> getPassivationCapableBean(String id)
Returns passivation capable bean given id.

Parameters:
id - bean id
Returns:
passivation capable bean given id

resolve

<X> Bean<? extends X> resolve(Set<Bean<? extends X>> beans)
Returns a bean object that is resolved according to the type safe resolution rules.

Type Parameters:
X - bean class info
Parameters:
beans - set of beans
Returns:
bean that is resolved according to the type safe resolution rules
Throws:
AmbiguousResolutionException - if ambigious exists

fireEvent

void fireEvent(Object event,
               Annotation... qualifiers)
Fires an event with given even object and qualifiers.

Parameters:
event - observer event object
qualifiers - event qualifiers
Throws:
IllegalArgumentException - event object contains a TypeVariable
IllegalArgumentException - given qualifier annotation is not a qualifier
IllegalArgumentException - same qualifier is given

resolveObserverMethods

<T> Set<ObserverMethod<? super T>> resolveObserverMethods(T event,
                                                          Annotation... qualifiers)
Returns set of observer methods.

Type Parameters:
T - event type
Parameters:
event - even object
qualifiers - event qualifiers
Returns:
set of observer methods

resolveDecorators

List<Decorator<?>> resolveDecorators(Set<Type> types,
                                     Annotation... qualifiers)
Returns a list of decorator.

Parameters:
types - bean types of the decorated bean
qualifiers - decorated bean qualifiers
Returns:
list of decorator
Throws:
IllegalArgumentException - given qualifier annotation is not a qualifier
IllegalArgumentException - same qualifier is given
IllegalArgumentException - if types is empty set

resolveInterceptors

List<Interceptor<?>> resolveInterceptors(InterceptionType type,
                                         Annotation... interceptorBindings)
Returns a list of interceptor.

Parameters:
type - interception type
interceptorBindings - interceptor bindings
Returns:
list of interceptor
Throws:
IllegalArgumentException - given binding annotation is not a binding
IllegalArgumentException - same binding is given
IllegalArgumentException - binding is not an interceptor binding

validate

void validate(InjectionPoint injectionPoint)
Validates injection point.

Parameters:
injectionPoint - injection point
Throws:
InjectionException - if problem exist

isScope

boolean isScope(Class<? extends Annotation> annotationType)
Returns true if given type is a scope type, false otherwise.

Parameters:
annotationType - annotation type
Returns:
true if given type is a scope type, false otherwise

isNormalScope

boolean isNormalScope(Class<? extends Annotation> annotationType)
Returns true if given type is a normal scope type, false otherwise.

Parameters:
annotationType - annotation type
Returns:
true if given type is a scope type, false otherwise

isPassivatingScope

boolean isPassivatingScope(Class<? extends Annotation> annotationType)
Returns true if given type is a passivating scope type, false otherwise.

Parameters:
annotationType - annotation type
Returns:
true if given type is a scope type, false otherwise

isQualifier

boolean isQualifier(Class<? extends Annotation> annotationType)
Returns true if given type is a qualifier, false otherwise.

Parameters:
annotationType - annotation type
Returns:
true if given type is a qualifier, false otherwise

isInterceptorBinding

boolean isInterceptorBinding(Class<? extends Annotation> annotationType)
Returns true if given type is a interceptor binding, false otherwise.

Parameters:
annotationType - annotation type
Returns:
true if given type is a interceptor binding, false otherwise

isStereotype

boolean isStereotype(Class<? extends Annotation> annotationType)
Returns true if given type is a stereotype type, false otherwise.

Parameters:
annotationType - annotation type
Returns:
true if given type is a stereotype, false otherwise

getInterceptorBindingDefinition

Set<Annotation> getInterceptorBindingDefinition(Class<? extends Annotation> qualifier)
Returns a set of meta-annotations that are defined on the binding

Parameters:
qualifier - binding class
Returns:
a set of meta-annotations that are defined on the binding

getStereotypeDefinition

Set<Annotation> getStereotypeDefinition(Class<? extends Annotation> stereotype)
Returns a set of meta-annotations that are defined on the stereotype type.

Parameters:
stereotype - stereotype type class
Returns:
a set of meta-annotations that are defined on the stereotype type

getContext

Context getContext(Class<? extends Annotation> scope)
Returns a context with given scope type.

Parameters:
scope - scope type class type
Returns:
a context with given scope type

getELResolver

javax.el.ELResolver getELResolver()
Returns el resolver.

Returns:
el resolver

createAnnotatedType

<T> AnnotatedType<T> createAnnotatedType(Class<T> type)
Returns a AnnotatedType instance for the given class.

Type Parameters:
T - class type
Parameters:
type - class
Returns:
a AnnotatedType instance

createInjectionTarget

<T> InjectionTarget<T> createInjectionTarget(AnnotatedType<T> type)
Creates a new instance of injection target.

Type Parameters:
T - bean type
Parameters:
type - annotated type
Returns:
injection target

wrapExpressionFactory

javax.el.ExpressionFactory wrapExpressionFactory(javax.el.ExpressionFactory expressionFactory)
Wrapped around given expression factory.

Parameters:
expressionFactory - expression factory
Returns:
wrapped expression factory


Copyright © 2003-2012 The Apache Software Foundation. All Rights Reserved.