Top Description Methods
javax.enterprise.inject.spi

public Interface BeanManager

Imports
javax.el.ELResolver, .ExpressionFactory, javax.enterprise.context.ContextNotActiveException, javax.enterprise.context.spi.Context, .Contextual, .CreationalContext, javax.enterprise.event.Event, .ObserverException, javax.enterprise.inject.AmbiguousResolutionException, .InjectionException, .Instance, .UnsatisfiedResolutionException, javax.enterprise.util.Nonbinding, java.lang.annotation.Annotation, java.lang.reflect.Type, java.util.List, .Set

Allows a portable extension to interact directly with the container. Provides operations for obtaining contextual references for beans, along with many other operations of use to portable extensions.

Any bean may obtain an instance of BeanManager by injecting it:

@Inject
BeanManager manager;

Java EE components may obtain an instance of BeanManager from JNDI by looking up the name java:comp/BeanManager.

Most operations of BeanManager may be called at any time during the execution of the application.

However, the following operations must not be called before the AfterBeanDiscovery event is fired:

and the following operations must not be called before the AfterDeploymentValidation event is fired:

or the container will throw an Exception.

Authors
Gavin King, Pete Muir, Clint Popetz, David Allen, Antoine Sabot-Durand

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the two interceptor bindings are equivalent, otherwise false
areInterceptorBindingsEquivalent
(Annotation
an interceptor binding to check
interceptorBinding1
,
Annotation
an interceptor binding to check
interceptorBinding2
)

Determine if two interceptor bindings are considered equivalent for the purposes of typesafe resolution, taking into account any members annotated with Nonbinding.

public boolean

Returns:

true if the two qualifiers are equivalent, otherwise false
areQualifiersEquivalent
(Annotation
a qualifier to check
qualifier1
,
Annotation
a qualifier to check
qualifier2
)

Determine if two qualifiers are considered equivalent for the purposes of typesafe resolution, taking into account any members annotated with Nonbinding.

public <
the class or interface
T
>
AnnotatedType<T>

Returns:

the AnnotatedType
createAnnotatedType
(Class<T>
the java.lang.Class object
type
)

Obtain an AnnotatedType that may be used to read the annotations of the given class or interface.

public <
the type
T
>
Bean<T>

Returns:

a container provided implementation of Bean
createBean
(BeanAttributes<T>
a BeanAttributes which determines the bean types, qualifiers, scope, name and stereotypes of the returned Bean, and the return values of Bean#isAlternative() and Bean#isNullable()
attributes
,
Class<T>
a class, which determines the return value of Bean#getBeanClass()
beanClass
,
InjectionTargetFactory<T> injectionTargetFactory)

Obtains a Bean for the given BeanAttributes, bean class and InjectionTarget.

public <
the type
T
,
the type of the declaring bean
X
>
Bean<T>

Returns:

a container provided implementation of Bean
createBean
(BeanAttributes<T>
a BeanAttributes which determines the bean types, qualifiers, scope, name and stereotypes of the returned Bean, and the return values of Bean#isAlternative() and Bean#isNullable()
attributes
,
Class<X>
a class, which determines the return value of Bean.getClass()
beanClass
,
ProducerFactory<X>
a ProducerFactory, used to obtain a Producer
producerFactory
)

Obtains a Bean for the given BeanAttributes, bean class and Producer.

public <
the type
T
>
BeanAttributes<T>

Returns:

a container provided implementation of InjectionTarget
createBeanAttributes
(AnnotatedType<T> type)

Obtains a BeanAttributes for the given AnnotatedType.

public BeanAttributes<?>

Returns:

a container provided implementation of InjectionTarget
createBeanAttributes
(AnnotatedMember<?> type)

Obtains a BeanAttributes for the given AnnotatedType.

public <T> CreationalContext<T>
createCreationalContext(Contextual<T>
the javax.enterprise.context.spi.Contextual, or a null value in the case of a non-contextual object
contextual
)

Obtain an instance of a javax.enterprise.context.spi.CreationalContext for the given contextual type, or for a non-contextual object.

public InjectionPoint

Returns:

the container provided InjectionPoint
createInjectionPoint
(AnnotatedField<?>
the AnnotatedField defining the injection point
field
)

Obtains a container provided implementation of InjectionPoint for the given AnnotatedField.

public InjectionPoint

Returns:

the container provided InjectionPoint
createInjectionPoint
(AnnotatedParameter<?>
the AnnotatedParameter defining the injection point
parameter
)

Obtains a container provided implementation of InjectionPoint for the given AnnotatedParameter.

public <
the type
T
>
InjectionTarget<T>

Returns:

a container provided implementation of InjectionTarget
createInjectionTarget
(AnnotatedType<T> type)

Obtains an InjectionTarget for the given AnnotatedType.

public Instance<Object>

Returns:

an Instance object to request beans instances
createInstance
()

Obtains an Instance object to access to beans instances.

public <
type of the instance this factory will work on
T
>
InterceptionFactory<T>

Returns:

a new InterceptionFactory to add services on on instances of T
createInterceptionFactory
(CreationalContext<T> ctx, Class<T>
class of the instance this factory will work on
clazz
)

Create an InterceptionFactory for the given CreationalContext and type.

public void
fireEvent(Object
the event object
event
,
Annotation...
the event qualifiers
qualifiers
)

Fire an event and notify observers.

public Set<Bean<?>>

Returns:

the resulting set of beans
getBeans
(Type
the required bean type
beanType
,
Annotation...
the required qualifiers
qualifiers
)

Return the set of beans which have the given required type and qualifiers and are available for injection in the module or library containing the class into which the BeanManager was injected or the Java EE component from whose JNDI environment namespace the BeanManager was obtained, according to the rules of typesafe resolution.

public Set<Bean<?>>

Returns:

the resulting set of beans
getBeans
(String
the EL name
name
)

Return the set of beans which have the given EL name and are available for injection in the module or library containing the class into which the BeanManager was injected or the Java EE component from whose JNDI environment namespace the BeanManager was obtained, according to the rules of EL name resolution.

public Context

Returns:

the context object
getContext
(Class<? extends Annotation>
the scope
scopeType
)

Obtains an active context object for the given scope .

public ELResolver

Returns:

the javax.el.ELResolver
getELResolver
()

Returns a javax.el.ELResolver that resolves beans by EL name.

public Event<Object>

Returns:

a new Event object whose event type is Object and qualifier @Default
getEvent
()

Returns an instance of Event with specified type java.lang.Object and specified qualifier @Default It allows typesafe synchronous or asynchronous event firing without injection of Event built-in bean requirement.

public <
the type of the extension
T extends Extension
>
T

Returns:

the extension instance
getExtension
(Class<T>
the type of the extension class
extensionClass
)

Obtains the container's instance of an Extension class declared in META-INF/services.

public Object

Returns:

the injectable reference
getInjectableReference
(InjectionPoint
the target injection point
ij
,
CreationalContext<?>
a javax.enterprise.context.spi.CreationalContext that may be used to destroy any object with scope javax.enterprise.context.Dependent that is created
ctx
)

Obtains an injectable reference for a certain injection point.

public <T> InjectionTargetFactory<T>
getInjectionTargetFactory(AnnotatedType<T>
the annotated type to create the injection target factory for
annotatedType
)

An implementation of InjectionTargetFactory that provides container created InjectionTarget instances.

public Set<Annotation>

Returns:

the set of meta-annotations
getInterceptorBindingDefinition
(Class<? extends Annotation> bindingType)

Obtains the set of meta-annotations for a certain interceptor binding type .

public int

Returns:

the hashCode for the interceptor binding
getInterceptorBindingHashCode
(Annotation
the interceptor binding to consider
interceptorBinding
)

Determine the hash code of an interceptor binding, using the JDK algorithm for determining an annotation hash code, ignoring any members annotated with Nonbinding.

public Bean<?>

Returns:

a Bean that implements javax.enterprise.inject.spi.PassivationCapable and has the given identifier, or a null value if there is no such bean
getPassivationCapableBean
(String
the identifier
id
)

Returns the javax.enterprise.inject.spi.PassivationCapable bean with the given identifier.

public <X> ProducerFactory<X>

Returns:

the producer factory for the field
getProducerFactory
(AnnotatedField<? super X>
the field to create the producer factory for
field
,
Bean<X>
the bean declaring the producer. May be null if the producer is static or the declaring object is non-contextual
declaringBean
)

An implementation of ProducerFactory that provides container created Producer instances for the given field.

public <X> ProducerFactory<X>

Returns:

the producer factory for the method
getProducerFactory
(AnnotatedMethod<? super X>
the method to create the producer factory for
method
,
Bean<X>
the bean declaring the producer. May be null if the producer is static or the declaring object is non-contextual
declaringBean
)

An implementation of ProducerFactory that provides container created Producer instances for the given method.

public int

Returns:

the hashCode for the qualifier
getQualifierHashCode
(Annotation
the qualifier to consider
qualifier
)

Determine the hash code of a qualifier, using the JDK algorithm for determining an annotation hash code, ignoring any members annotated with Nonbinding.

public Object

Returns:

a contextual reference representing the bean
getReference
(Bean<?>
the Bean object representing the bean
bean
,
Type
a bean type that must be implemented by any client proxy that is returned
beanType
,
CreationalContext<?>
a javax.enterprise.context.spi.CreationalContext that may be used to destroy any object with scope javax.enterprise.context.Dependent that is created
ctx
)

Obtains a contextual reference for a certain bean and a certain bean type of the bean.

public Set<Annotation>

Returns:

the set of meta-annotations
getStereotypeDefinition
(Class<? extends Annotation> stereotype)

Obtains meta-annotations for a certain stereotype.

public boolean

Returns:

true if the annotation type is a interceptor binding type
isInterceptorBinding
(Class<? extends Annotation>
the annotation to test
annotationType
)

Test the given annotation type to determine if it is an interceptor binding type .

public boolean

Returns:

true if the annotation type is a normal scope type
isNormalScope
(Class<? extends Annotation>
the annotation type
annotationType
)

Test the given annotation type to determine if it is a normal scope type.

public boolean

Returns:

true if the annotation type is a passivating scope type
isPassivatingScope
(Class<? extends Annotation>
the annotation type
annotationType
)

Test the given annotation type to determine if it is a passivating scope type.

public boolean

Returns:

true if the annotation type is a qualifier type
isQualifier
(Class<? extends Annotation>
the annotation type
annotationType
)

Test the given annotation type to determine if it is a qualifier type.

public boolean

Returns:

true if the annotation type is a scope type
isScope
(Class<? extends Annotation>
the annotation type
annotationType
)

Test the given annotation type to determine if it is a scope type.

public boolean

Returns:

true if the annotation type is a stereotype
isStereotype
(Class<? extends Annotation>
the annotation type
annotationType
)

Test the given annotation type to determine if it is a stereotype.

public <
a common type of the beans
X
>
Bean<? extends X>

Returns:

the resolved bean, or null if null or an empty set is passed
resolve
(Set<Bean<? extends X>>
a set of beans of the given type
beans
)

Apply the ambiguous dependency resolution rules to a set of beans.

public List<Decorator<?>>

Returns:

the resulting set of decorators
resolveDecorators
(Set<Type>
the set of bean types of the decorated bean
types
,
Annotation...
the qualifiers declared by the decorated bean
qualifiers
)

Return an ordered list of decorators for a set of bean types and a set of qualifiers and which are enabled in the module or library containing the class into which the BeanManager was injected or the Java EE component from whose JNDI environment namespace the BeanManager was obtained.

public List<Interceptor<?>>

Returns:

the resulting set of interceptors
resolveInterceptors
(InterceptionType
the type of the interception
type
,
Annotation...
the interceptor bindings
interceptorBindings
)

Return an ordered list of enabled interceptors for a set of interceptor bindings and a type of interception and which are enabled in the module or library containing the class into which the BeanManager was injected or the Java EE component from whose JNDI environment namespace the BeanManager was obtained.

public <
the type of the event
T
>
Set<ObserverMethod<? super T>>

Returns:

the resulting set of observer methods
resolveObserverMethods
(T
the event object
event
,
Annotation...
the event qualifiers
qualifiers
)

Return an ordered set of observer methods for an event.

public void
validate(InjectionPoint
the injection point to validate
injectionPoint
)

Validate a certain injection point.

public ExpressionFactory