org.jboss.weld.util
Class Beans

java.lang.Object
  extended by org.jboss.weld.util.Beans

public class Beans
extends Object

Helper class for bean inspection

Author:
Pete Muir, David Allen, Marius Bogoevici, Ales Justin, Marko Luksa

Constructor Summary
Beans()
           
 
Method Summary
static
<T> void
callInitializers(T instance, javax.enterprise.context.spi.CreationalContext<T> creationalContext, BeanManagerImpl manager, Iterable<? extends MethodInjectionPoint<?,?>> initializerMethods)
          Calls all initializers of the bean
static boolean containsAllInterceptionBindings(Set<Annotation> expectedBindings, Set<QualifierInstance> existingBindings, BeanManagerImpl manager)
           
static boolean containsAllQualifiers(Set<QualifierInstance> requiredQualifiers, Set<QualifierInstance> qualifiers, BeanManagerImpl beanManager)
          Checks that all the qualifiers in the set requiredQualifiers are in the set of qualifiers.
static boolean findInterceptorBindingConflicts(Set<InterceptorBindingType> flattenedBindings)
           
static
<T> ConstructorInjectionPoint<T>
getBeanConstructor(javax.enterprise.inject.spi.Bean<T> declaringBean, WeldClass<T> type)
           
static Type getDeclaredBeanType(Class<?> clazz)
          Gets the declared bean type
static javax.enterprise.inject.spi.InjectionPoint getDelegateInjectionPoint(javax.enterprise.inject.spi.Decorator<?> decorator)
           
static Set<WeldInjectionPoint<?,?>> getEjbInjectionPoints(javax.enterprise.inject.spi.Bean<?> declaringBean, WeldClass<?> type, BeanManagerImpl manager)
           
static Set<FieldInjectionPoint<?,?>> getFieldInjectionPoints(javax.enterprise.inject.spi.Bean<?> declaringBean, List<? extends Set<? extends FieldInjectionPoint<?,?>>> fieldInjectionPoints)
           
static List<Set<FieldInjectionPoint<?,?>>> getFieldInjectionPoints(javax.enterprise.inject.spi.Bean<?> declaringBean, WeldClass<?> weldClass)
           
static List<Set<MethodInjectionPoint<?,?>>> getInitializerMethods(javax.enterprise.inject.spi.Bean<?> declaringBean, WeldClass<?> type)
           
static List<WeldMethod<?,?>> getInterceptableMethods(WeldClass<?> type)
           
static
<T> List<WeldMethod<?,? super T>>
getObserverMethods(WeldClass<T> type)
           
static Set<ParameterInjectionPoint<?,?>> getParameterInjectionPoints(javax.enterprise.inject.spi.Bean<?> declaringBean, List<Set<MethodInjectionPoint<?,?>>> methodInjectionPoints)
           
static Set<ParameterInjectionPoint<?,?>> getParameterInjectionPoints(javax.enterprise.inject.spi.Bean<?> declaringBean, MethodInjectionPoint<?,?> method)
           
static Set<ParameterInjectionPoint<?,?>> getParameterInjectionPoints(javax.enterprise.inject.spi.Bean<?> declaringBean, WeldConstructor<?> constructor)
           
static Set<WeldInjectionPoint<?,?>> getPersistenceContextInjectionPoints(javax.enterprise.inject.spi.Bean<?> declaringBean, WeldClass<?> type, BeanManagerImpl manager)
           
static Set<WeldInjectionPoint<?,?>> getPersistenceUnitInjectionPoints(javax.enterprise.inject.spi.Bean<?> declaringBean, WeldClass<?> type, BeanManagerImpl manager)
           
static
<T> List<WeldMethod<?,? super T>>
getPostConstructMethods(WeldClass<T> type)
           
static
<T> List<WeldMethod<?,? super T>>
getPreDestroyMethods(WeldClass<T> type)
           
static Set<WeldInjectionPoint<?,?>> getResourceInjectionPoints(javax.enterprise.inject.spi.Bean<?> declaringBean, WeldClass<?> type, BeanManagerImpl manager)
           
static
<T> void
injectBoundFields(T instance, javax.enterprise.context.spi.CreationalContext<T> creationalContext, BeanManagerImpl manager, Iterable<? extends FieldInjectionPoint<?,?>> injectableFields)
          Injects bound fields
static
<T> void
injectEEFields(T beanInstance, BeanManagerImpl manager, Iterable<WeldInjectionPoint<?,?>> ejbInjectionPoints, Iterable<WeldInjectionPoint<?,?>> persistenceContextInjectionPoints, Iterable<WeldInjectionPoint<?,?>> persistenceUnitInjectionPoints, Iterable<WeldInjectionPoint<?,?>> resourceInjectionPoints)
          Injects EJBs and common fields
static
<T> void
injectFieldsAndInitializers(T instance, javax.enterprise.context.spi.CreationalContext<T> ctx, BeanManagerImpl beanManager, List<? extends Iterable<? extends FieldInjectionPoint<?,?>>> injectableFields, List<? extends Iterable<? extends MethodInjectionPoint<?,?>>> initializerMethods)
           
static boolean isAlternative(WeldAnnotated<?,?> annotated, MergedStereotypes<?,?> mergedStereotypes)
          Is alternative.
static boolean isAlternativePresent(Set<javax.enterprise.inject.spi.Bean<?>> beans)
          Check if any of the beans is an alternative
static boolean isBeanEnabled(javax.enterprise.inject.spi.Bean<?> bean, Enabled enabled)
           
static boolean isBeanProxyable(javax.enterprise.inject.spi.Bean<?> bean)
          Indicates if a bean is proxyable
static
<T> boolean
isDecorator(WeldClass<T> annotatedItem)
           
static
<T> boolean
isInterceptor(WeldClass<T> annotatedItem)
           
static boolean isPassivatingScope(javax.enterprise.inject.spi.Bean<?> bean, BeanManagerImpl manager)
          Indicates if a bean's scope type is passivating
static boolean isPassivationCapableBean(javax.enterprise.inject.spi.Bean<?> bean)
          Tests if a bean is capable of having its state temporarily stored to secondary storage
static boolean isPassivationCapableDependency(javax.enterprise.inject.spi.Bean<?> bean)
          Tests if a bean is capable of having its state temporarily stored to secondary storage
static
<T extends javax.enterprise.inject.spi.Bean<?>>
boolean
isSpecialized(T bean, BeanManagerImpl beanManager)
          Check if bean is specialized by any of beans
static
<T extends javax.enterprise.inject.spi.Bean<?>>
boolean
isSpecialized(T bean, Set<T> beans, BeanManagerImpl beanManager)
          Check if bean is specialized by any of beans
static boolean isSuppressedBySpecialization(javax.enterprise.inject.spi.Bean<?> bean, BeanManagerImpl manager)
          Check if the given producer/disposer method of producer field is defined on a specialized bean and is therefore disabled.
static Annotation[] mergeInQualifiers(Annotation[] qualifiers, Annotation[] newQualifiers)
           
static Set<Annotation> mergeInQualifiers(Collection<Annotation> qualifiers, Annotation[] newQualifiers)
           
static
<T extends javax.enterprise.inject.spi.Bean<?>>
Set<T>
removeDisabledAndSpecializedBeans(Set<T> beans, BeanManagerImpl beanManager)
          Retains only beans which have deployment type X.
static Object resolveEEResource(BeanManagerImpl manager, WeldInjectionPoint<?,?> injectionPoint)
          Inspect an injection point, and try to retrieve a EE resource for it
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Beans

public Beans()
Method Detail

isPassivatingScope

public static boolean isPassivatingScope(javax.enterprise.inject.spi.Bean<?> bean,
                                         BeanManagerImpl manager)
Indicates if a bean's scope type is passivating

Parameters:
bean - The bean to inspect
Returns:
True if the scope is passivating, false otherwise

isPassivationCapableBean

public static boolean isPassivationCapableBean(javax.enterprise.inject.spi.Bean<?> bean)
Tests if a bean is capable of having its state temporarily stored to secondary storage

Parameters:
bean - The bean to inspect
Returns:
True if the bean is passivation capable

isPassivationCapableDependency

public static boolean isPassivationCapableDependency(javax.enterprise.inject.spi.Bean<?> bean)
Tests if a bean is capable of having its state temporarily stored to secondary storage

Parameters:
bean - The bean to inspect
Returns:
True if the bean is passivation capable

isBeanProxyable

public static boolean isBeanProxyable(javax.enterprise.inject.spi.Bean<?> bean)
Indicates if a bean is proxyable

Parameters:
bean - The bean to test
Returns:
True if proxyable, false otherwise

getFieldInjectionPoints

public static List<Set<FieldInjectionPoint<?,?>>> getFieldInjectionPoints(javax.enterprise.inject.spi.Bean<?> declaringBean,
                                                                          WeldClass<?> weldClass)

getFieldInjectionPoints

public static Set<FieldInjectionPoint<?,?>> getFieldInjectionPoints(javax.enterprise.inject.spi.Bean<?> declaringBean,
                                                                    List<? extends Set<? extends FieldInjectionPoint<?,?>>> fieldInjectionPoints)

getPostConstructMethods

public static <T> List<WeldMethod<?,? super T>> getPostConstructMethods(WeldClass<T> type)

getObserverMethods

public static <T> List<WeldMethod<?,? super T>> getObserverMethods(WeldClass<T> type)

getPreDestroyMethods

public static <T> List<WeldMethod<?,? super T>> getPreDestroyMethods(WeldClass<T> type)

getInterceptableMethods

public static List<WeldMethod<?,?>> getInterceptableMethods(WeldClass<?> type)

getEjbInjectionPoints

public static Set<WeldInjectionPoint<?,?>> getEjbInjectionPoints(javax.enterprise.inject.spi.Bean<?> declaringBean,
                                                                 WeldClass<?> type,
                                                                 BeanManagerImpl manager)

getPersistenceContextInjectionPoints

public static Set<WeldInjectionPoint<?,?>> getPersistenceContextInjectionPoints(javax.enterprise.inject.spi.Bean<?> declaringBean,
                                                                                WeldClass<?> type,
                                                                                BeanManagerImpl manager)

getPersistenceUnitInjectionPoints

public static Set<WeldInjectionPoint<?,?>> getPersistenceUnitInjectionPoints(javax.enterprise.inject.spi.Bean<?> declaringBean,
                                                                             WeldClass<?> type,
                                                                             BeanManagerImpl manager)

getResourceInjectionPoints

public static Set<WeldInjectionPoint<?,?>> getResourceInjectionPoints(javax.enterprise.inject.spi.Bean<?> declaringBean,
                                                                      WeldClass<?> type,
                                                                      BeanManagerImpl manager)

getInitializerMethods

public static List<Set<MethodInjectionPoint<?,?>>> getInitializerMethods(javax.enterprise.inject.spi.Bean<?> declaringBean,
                                                                         WeldClass<?> type)

getParameterInjectionPoints

public static Set<ParameterInjectionPoint<?,?>> getParameterInjectionPoints(javax.enterprise.inject.spi.Bean<?> declaringBean,
                                                                            WeldConstructor<?> constructor)

getParameterInjectionPoints

public static Set<ParameterInjectionPoint<?,?>> getParameterInjectionPoints(javax.enterprise.inject.spi.Bean<?> declaringBean,
                                                                            MethodInjectionPoint<?,?> method)

getParameterInjectionPoints

public static Set<ParameterInjectionPoint<?,?>> getParameterInjectionPoints(javax.enterprise.inject.spi.Bean<?> declaringBean,
                                                                            List<Set<MethodInjectionPoint<?,?>>> methodInjectionPoints)

containsAllQualifiers

public static boolean containsAllQualifiers(Set<QualifierInstance> requiredQualifiers,
                                            Set<QualifierInstance> qualifiers,
                                            BeanManagerImpl beanManager)
Checks that all the qualifiers in the set requiredQualifiers are in the set of qualifiers. Qualifier equality rules for annotation members are followed.

Parameters:
requiredQualifiers - The required qualifiers
qualifiers - The set of qualifiers to check
Returns:
True if all matches, false otherwise

containsAllInterceptionBindings

public static boolean containsAllInterceptionBindings(Set<Annotation> expectedBindings,
                                                      Set<QualifierInstance> existingBindings,
                                                      BeanManagerImpl manager)

findInterceptorBindingConflicts

public static boolean findInterceptorBindingConflicts(Set<InterceptorBindingType> flattenedBindings)

removeDisabledAndSpecializedBeans

public static <T extends javax.enterprise.inject.spi.Bean<?>> Set<T> removeDisabledAndSpecializedBeans(Set<T> beans,
                                                                                                       BeanManagerImpl beanManager)
Retains only beans which have deployment type X.

The deployment type X is

Parameters:
beans - The beans to filter
beanManager - the bean manager
Returns:
The filtered beans

isBeanEnabled

public static boolean isBeanEnabled(javax.enterprise.inject.spi.Bean<?> bean,
                                    Enabled enabled)

isAlternativePresent

public static boolean isAlternativePresent(Set<javax.enterprise.inject.spi.Bean<?>> beans)
Check if any of the beans is an alternative

Parameters:
beans - the beans to check
Returns:
true if any bean is an alternative

isAlternative

public static boolean isAlternative(WeldAnnotated<?,?> annotated,
                                    MergedStereotypes<?,?> mergedStereotypes)
Is alternative.

Parameters:
annotated - the annotated
mergedStereotypes - merged stereotypes
Returns:
true if alternative, false otherwise

isSpecialized

public static <T extends javax.enterprise.inject.spi.Bean<?>> boolean isSpecialized(T bean,
                                                                                    BeanManagerImpl beanManager)
Check if bean is specialized by any of beans

Parameters:
bean - the bean to check
beanManager - bean manager
Returns:
true if bean is specialized by some bean in all beans

isSpecialized

public static <T extends javax.enterprise.inject.spi.Bean<?>> boolean isSpecialized(T bean,
                                                                                    Set<T> beans,
                                                                                    BeanManagerImpl beanManager)
Check if bean is specialized by any of beans

Parameters:
bean - the bean to check
beans - the possible specialized beans
beanManager - bean manager
Returns:
true if bean is specialized by some bean in beans

isSuppressedBySpecialization

public static boolean isSuppressedBySpecialization(javax.enterprise.inject.spi.Bean<?> bean,
                                                   BeanManagerImpl manager)
Check if the given producer/disposer method of producer field is defined on a specialized bean and is therefore disabled.


getBeanConstructor

public static <T> ConstructorInjectionPoint<T> getBeanConstructor(javax.enterprise.inject.spi.Bean<T> declaringBean,
                                                                  WeldClass<T> type)

injectEEFields

public static <T> void injectEEFields(T beanInstance,
                                      BeanManagerImpl manager,
                                      Iterable<WeldInjectionPoint<?,?>> ejbInjectionPoints,
                                      Iterable<WeldInjectionPoint<?,?>> persistenceContextInjectionPoints,
                                      Iterable<WeldInjectionPoint<?,?>> persistenceUnitInjectionPoints,
                                      Iterable<WeldInjectionPoint<?,?>> resourceInjectionPoints)
Injects EJBs and common fields


resolveEEResource

public static Object resolveEEResource(BeanManagerImpl manager,
                                       WeldInjectionPoint<?,?> injectionPoint)
Inspect an injection point, and try to retrieve a EE resource for it


getDeclaredBeanType

public static Type getDeclaredBeanType(Class<?> clazz)
Gets the declared bean type

Returns:
The bean type

injectBoundFields

public static <T> void injectBoundFields(T instance,
                                         javax.enterprise.context.spi.CreationalContext<T> creationalContext,
                                         BeanManagerImpl manager,
                                         Iterable<? extends FieldInjectionPoint<?,?>> injectableFields)
Injects bound fields

Parameters:
instance - The instance to inject into

injectFieldsAndInitializers

public static <T> void injectFieldsAndInitializers(T instance,
                                                   javax.enterprise.context.spi.CreationalContext<T> ctx,
                                                   BeanManagerImpl beanManager,
                                                   List<? extends Iterable<? extends FieldInjectionPoint<?,?>>> injectableFields,
                                                   List<? extends Iterable<? extends MethodInjectionPoint<?,?>>> initializerMethods)

callInitializers

public static <T> void callInitializers(T instance,
                                        javax.enterprise.context.spi.CreationalContext<T> creationalContext,
                                        BeanManagerImpl manager,
                                        Iterable<? extends MethodInjectionPoint<?,?>> initializerMethods)
Calls all initializers of the bean

Parameters:
instance - The bean instance

isInterceptor

public static <T> boolean isInterceptor(WeldClass<T> annotatedItem)

isDecorator

public static <T> boolean isDecorator(WeldClass<T> annotatedItem)

mergeInQualifiers

public static Annotation[] mergeInQualifiers(Annotation[] qualifiers,
                                             Annotation[] newQualifiers)

mergeInQualifiers

public static Set<Annotation> mergeInQualifiers(Collection<Annotation> qualifiers,
                                                Annotation[] newQualifiers)

getDelegateInjectionPoint

public static javax.enterprise.inject.spi.InjectionPoint getDelegateInjectionPoint(javax.enterprise.inject.spi.Decorator<?> decorator)


Copyright © 2013 Seam Framework. All Rights Reserved.