javax.enterprise.inject.spi
Interface BeanManager


public interface BeanManager

The contract between the application and the manager. Also the contract between the manager and Bean, Context and Observer objects. The application should not normally need to call this interface.

Author:
Gavin King, Pete Muir, Clint Popetz

Method Summary
 void addBean(Bean<?> bean)
          Deprecated. 
 void addContext(Context context)
          Deprecated. 
 void addObserver(Observer<?> observer, java.lang.annotation.Annotation... bindings)
          Deprecated. 
<T> AnnotatedType<T>
createAnnotatedType(java.lang.Class<T> type)
          Get an AnnotatedType for the given class
<T> CreationalContext<T>
createCreationalContext(Contextual<T> contextual)
          Obtain an instance of a CreationalContext for the given contextual
<T> InjectionTarget<T>
createInjectionTarget(AnnotatedType<T> type)
          Returns an InjectionTarget to allow injection into custom beans or non-contextual instances by portable extensions.
 void fireEvent(java.lang.Object event, java.lang.annotation.Annotation... bindings)
          Fire an event
 java.util.Set<Bean<?>> getBeans(java.lang.String name)
          Returns the set of beans which match the given EL name and are accessible to the class into which the BeanManager was injected, according to the rules of EL name resolution.
 java.util.Set<Bean<?>> getBeans(java.lang.reflect.Type beanType, java.lang.annotation.Annotation... bindings)
          Returns the set of beans which match the given required type and bindings and are accessible to the class into which the BeanManager was injected, according to the rules of typesafe resolution.
 Context getContext(java.lang.Class<? extends java.lang.annotation.Annotation> scopeType)
          Obtain an active context instance for the given scope type.
 javax.el.ELResolver getELResolver()
          Returns the ELResolver for integration with the servlet engine and JSF implementation This resolver will return a contextual instance of a bean if the name for resolution resolves to exactly one bean
 java.util.List<java.lang.Class<? extends java.lang.annotation.Annotation>> getEnabledDeploymentTypes()
          Deprecated. 
 java.lang.Object getInjectableReference(InjectionPoint ij, CreationalContext<?> ctx)
          Obtains an instance of bean for a given injection point.
 java.util.Set<java.lang.annotation.Annotation> getInterceptorBindingTypeDefinition(java.lang.Class<? extends java.lang.annotation.Annotation> bindingType)
          Obtain the set of interceptor binding types meta-annotatinos for the given binding type annotation
<X> Bean<? extends X>
getMostSpecializedBean(Bean<X> bean)
          Returns the Bean object representing the most specialized enabled bean registered with the container that specializes the given bean,
 Bean<?> getPassivationCapableBean(java.lang.String id)
          Returns the PassivationCapableBean with the given identifier.
 java.lang.Object getReference(Bean<?> bean, java.lang.reflect.Type beanType, CreationalContext<?> ctx)
          Obtains a contextual reference for a given bean and a given bean type.
 ScopeType getScopeDefinition(java.lang.Class<? extends java.lang.annotation.Annotation> scopeType)
          Return a ScopeType definition type for a given annotation representing a scope type
 java.util.Set<java.lang.annotation.Annotation> getStereotypeDefinition(java.lang.Class<? extends java.lang.annotation.Annotation> stereotype)
          Obtain the set of binding types meta-annotations for the given stereotype annotation
 boolean isBindingType(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
          Determine if the given annotationType is a binding type
 boolean isInterceptorBindingType(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
          Determine if the given annotationType is an interceptor binding type
 boolean isScopeType(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
          Determine if the given annotationType is a scope type
 boolean isStereotype(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
          Determine if the given annotationType is a stereotype
 void removeObserver(Observer<?> observer)
          Deprecated. 
<X> Bean<? extends X>
resolve(java.util.Set<Bean<? extends X>> beans)
          Apply the ambiguous dependency resolution rules
 java.util.List<Decorator<?>> resolveDecorators(java.util.Set<java.lang.reflect.Type> types, java.lang.annotation.Annotation... bindings)
          Obtains an ordered list of enabled decorators for a set of bean types and a set of bindings
 java.util.List<Interceptor<?>> resolveInterceptors(InterceptionType type, java.lang.annotation.Annotation... interceptorBindings)
          Obtains an ordered list of enabled interceptors for a set interceptor bindings
<T> java.util.Set<ObserverMethod<T,?>>
resolveObserverMethods(T event, java.lang.annotation.Annotation... bindings)
          Obtains observers for an event by considering event type and bindings.
<T> java.util.Set<Observer<T>>
resolveObservers(T event, java.lang.annotation.Annotation... bindings)
          Deprecated. 
 void validate(InjectionPoint injectionPoint)
          Validates the dependency
 

Method Detail

getReference

java.lang.Object getReference(Bean<?> bean,
                              java.lang.reflect.Type beanType,
                              CreationalContext<?> ctx)
Obtains a contextual reference for a given bean and a given bean type.

Parameters:
bean - the Bean object representing the bean
beanType - a bean type that must be implemented by any proxy that is returned
Returns:
a contextual reference representing the bean
Throws:
java.lang.IllegalArgumentException - if the given type is not a bean type of the given bean

getInjectableReference

java.lang.Object getInjectableReference(InjectionPoint ij,
                                        CreationalContext<?> ctx)
Obtains an instance of bean for a given injection point. This method should not be called by an application.

Parameters:
ij - the injection point the instance is needed for
ctx - the context in which the injection is occurring
Returns:
an instance of the bean
Throws:
UnsatisfiedResolutionException - if no bean can be resolved for the given type and bindings
AmbiguousResolutionException - if more than one bean is resolved for the given type and bindings

createCreationalContext

<T> CreationalContext<T> createCreationalContext(Contextual<T> contextual)
Obtain an instance of a CreationalContext for the given contextual

Parameters:
contextual - the contextual to create a creational context for
Returns:
the CreationalContext instance

getBeans

java.util.Set<Bean<?>> getBeans(java.lang.reflect.Type beanType,
                                java.lang.annotation.Annotation... bindings)
Returns the set of beans which match the given required type and bindings and are accessible to the class into which the BeanManager was injected, according to the rules of typesafe resolution. Typesafe resolution usually occurs at container deployment time.

Parameters:
beanType - the type of the beans to be resolved
bindings - the bindings used to restrict the matched beans. If no bindings are passed to getBeans(), the default binding @Current is assumed.
Returns:
the matched beans
Throws:
java.lang.IllegalArgumentException - if the given type represents a type variable
java.lang.IllegalArgumentException - if two instances of the same binding type are
java.lang.IllegalArgumentException - if an instance of an annotation that is not a binding type is given

getBeans

java.util.Set<Bean<?>> getBeans(java.lang.String name)
Returns the set of beans which match the given EL name and are accessible to the class into which the BeanManager was injected, according to the rules of EL name resolution.

Parameters:
name - the name used to restrict the beans matched
Returns:
the matched beans

getMostSpecializedBean

<X> Bean<? extends X> getMostSpecializedBean(Bean<X> bean)
Returns the Bean object representing the most specialized enabled bean registered with the container that specializes the given bean,

Type Parameters:
X - The type of the bean
Parameters:
bean - The Bean representation of the bean.
Returns:
the most specialized enabled bean

getPassivationCapableBean

Bean<?> getPassivationCapableBean(java.lang.String id)
Returns the PassivationCapableBean with the given identifier.


resolve

<X> Bean<? extends X> resolve(java.util.Set<Bean<? extends X>> beans)
Apply the ambiguous dependency resolution rules

Type Parameters:
X - The type of the bean
Parameters:
beans - A set of beans of the given type
Throws:
AmbiguousResolutionException - if the ambiguous dependency resolution rules fail

validate

void validate(InjectionPoint injectionPoint)
Validates the dependency

Parameters:
injectionPoint - the injection point to validate
Throws:
an - InjectionException if there is a deployment problem (for example, an unsatisfied or unresolvable ambiguous dependency) associated with the injection point.

fireEvent

void fireEvent(java.lang.Object event,
               java.lang.annotation.Annotation... bindings)
Fire an event

Parameters:
event - the event object
bindings - the event bindings used to restrict the observers matched
Throws:
java.lang.IllegalArgumentException - if the runtime type of the event object contains a type variable
java.lang.IllegalArgumentException - if two instances of the same binding type are given
java.lang.IllegalArgumentException - if an instance of an annotation that is not a binding type is given,

resolveObservers

@Deprecated
<T> java.util.Set<Observer<T>> resolveObservers(T event,
                                                           java.lang.annotation.Annotation... bindings)
Deprecated. 

Obtains observers for an event by considering event type and bindings.

Type Parameters:
T - the type of the event to obtain
Parameters:
event - the event object
bindings - the bindings used to restrict the matched observers
Returns:
the resolved observers
Throws:
java.lang.IllegalArgumentException - if a parameterized type with a type parameter or a wildcard is passed
java.lang.IllegalArgumentException - if an annotation which is not a event binding type is passed
java.lang.IllegalArgumentException - if two instances of the same binding type are passed

resolveObserverMethods

<T> java.util.Set<ObserverMethod<T,?>> resolveObserverMethods(T event,
                                                              java.lang.annotation.Annotation... bindings)
Obtains observers for an event by considering event type and bindings.

Type Parameters:
T - the type of the event to obtain
Parameters:
event - the event object
bindings - the bindings used to restrict the matched observers
Returns:
the resolved observers
Throws:
java.lang.IllegalArgumentException - if a parameterized type with a type parameter or a wildcard is passed
java.lang.IllegalArgumentException - if an annotation which is not a event binding type is passed
java.lang.IllegalArgumentException - if two instances of the same binding type are passed

resolveDecorators

java.util.List<Decorator<?>> resolveDecorators(java.util.Set<java.lang.reflect.Type> types,
                                               java.lang.annotation.Annotation... bindings)
Obtains an ordered list of enabled decorators for a set of bean types and a set of bindings

Parameters:
types - the set of bean types of the decorated bean
bindings - the bindings declared by the decorated bean
Returns:
the resolved decorators
Throws:
java.lang.IllegalArgumentException - if the set of bean types is empty
java.lang.IllegalArgumentException - if an annotation which is not a binding type is passed
java.lang.IllegalArgumentException - if two instances of the same binding type are passed

resolveInterceptors

java.util.List<Interceptor<?>> resolveInterceptors(InterceptionType type,
                                                   java.lang.annotation.Annotation... interceptorBindings)
Obtains an ordered list of enabled interceptors for a set interceptor bindings

Parameters:
type - the type of the interception
bindings - the bindings used to restrict the matched interceptors
Returns:
the resolved interceptors
Throws:
java.lang.IllegalArgumentException - if no interceptor binding type is passed
java.lang.IllegalArgumentException - if an annotation which is not a interceptor binding type is passed
java.lang.IllegalArgumentException - if two instances of the same binding type are passed

isScopeType

boolean isScopeType(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Determine if the given annotationType is a scope type


isBindingType

boolean isBindingType(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Determine if the given annotationType is a binding type


isInterceptorBindingType

boolean isInterceptorBindingType(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Determine if the given annotationType is an interceptor binding type


isStereotype

boolean isStereotype(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Determine if the given annotationType is a stereotype


getScopeDefinition

ScopeType getScopeDefinition(java.lang.Class<? extends java.lang.annotation.Annotation> scopeType)
Return a ScopeType definition type for a given annotation representing a scope type


getInterceptorBindingTypeDefinition

java.util.Set<java.lang.annotation.Annotation> getInterceptorBindingTypeDefinition(java.lang.Class<? extends java.lang.annotation.Annotation> bindingType)
Obtain the set of interceptor binding types meta-annotatinos for the given binding type annotation


getStereotypeDefinition

java.util.Set<java.lang.annotation.Annotation> getStereotypeDefinition(java.lang.Class<? extends java.lang.annotation.Annotation> stereotype)
Obtain the set of binding types meta-annotations for the given stereotype annotation


getContext

Context getContext(java.lang.Class<? extends java.lang.annotation.Annotation> scopeType)
Obtain an active context instance for the given scope type.

Parameters:
scopeType - the scope to get the context instance for
Returns:
the context instance
Throws:
ContextNotActiveException - if no active contexts exist for the given scope type
java.lang.IllegalArgumentException - if more than one active context exists for the given scope type

getELResolver

javax.el.ELResolver getELResolver()
Returns the ELResolver for integration with the servlet engine and JSF implementation This resolver will return a contextual instance of a bean if the name for resolution resolves to exactly one bean


createAnnotatedType

<T> AnnotatedType<T> createAnnotatedType(java.lang.Class<T> type)
Get an AnnotatedType for the given class

Type Parameters:
T - the type
Parameters:
type - the type
Returns:
the AnnotatedType

createInjectionTarget

<T> InjectionTarget<T> createInjectionTarget(AnnotatedType<T> type)
Returns an InjectionTarget to allow injection into custom beans or non-contextual instances by portable extensions. The container ignores the annotations and types declared by the elements of the actual Java class and uses the metadata provided via the Annotated interface instead.

Type Parameters:
T - The type of the AnnotatedType to inspect
Parameters:
type - The AnnotatedType to inspect
Throws:
java.lang.IllegalArgumentException - if there is a definition error associated with any injection point of the type.

addBean

@Deprecated
void addBean(Bean<?> bean)
Deprecated. 

Allows a new bean to be registered. This fires a ProcessBean event and then registers a new bean with the container, thereby making it available for injection into other beans. This method may be called at any time in the applications lifecycle.

Parameters:
bean - the bean to register

addObserver

@Deprecated
void addObserver(Observer<?> observer,
                            java.lang.annotation.Annotation... bindings)
Deprecated. 

Register an observer with the container, allowing it to begin receiving event notifications. The observed event type is the actual type parameter of Observer declared by the class of the observer object. The observer is notified when an event object that is assignable to the observed event type is raised with the observed event bindings.

Parameters:
observer - the observer to register
bindings - event bindings to further restrict the events observed passed
Throws:
java.lang.IllegalArgumentException - if an annotation which is not a binding type is passed, or if two instances of the same binding type are passed, or if the runtime type of the observer object contains a type variable

removeObserver

@Deprecated
void removeObserver(Observer<?> observer)
Deprecated. 

Remove an observer registration

Parameters:
observer - the observer to register
Throws:
java.lang.IllegalArgumentException - if an annotation which is not a event binding type is passed or if two instances of the same binding type are passed

getEnabledDeploymentTypes

@Deprecated
java.util.List<java.lang.Class<? extends java.lang.annotation.Annotation>> getEnabledDeploymentTypes()
Deprecated. 

Exposes the list of enabled deployment types, in order of lower to higher precedence, This method may be used by portable extensions to discover information about the deployment.


addContext

@Deprecated
void addContext(Context context)
Deprecated. 

Associate a custom Context with a scope. This method may be called at any time in the applications lifecycle.

Parameters:
context - the context to register


Copyright © 2008-2009. All Rights Reserved.