Package org.jboss.weld.util
Class Beans
- java.lang.Object
-
- org.jboss.weld.util.Beans
-
public class Beans extends Object
Helper class for bean inspection- Author:
- Pete Muir, David Allen, Marius Bogoevici, Ales Justin, Jozef Hartinger
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> voidcallInitializers(T instance, javax.enterprise.context.spi.CreationalContext<T> creationalContext, BeanManagerImpl manager, Iterable<? extends MethodInjectionPoint<?,?>> initializerMethods)Calls all initializers of the beanstatic <T,S,X extends EnhancedAnnotated<T,S>>
XcheckEnhancedAnnotatedAvailable(X enhancedAnnotated)static booleancontainsAllInterceptionBindings(Set<Annotation> expectedBindings, Set<QualifierInstance> existingBindings, BeanManagerImpl manager)static booleancontainsAllQualifiers(Set<QualifierInstance> requiredQualifiers, Set<QualifierInstance> qualifiers)Checks that all the qualifiers in the set requiredQualifiers are in the set of qualifiers.static StringcreateBeanAttributesId(javax.enterprise.inject.spi.BeanAttributes<?> attributes)Generates a unique signature forBeanAttributes.static StringcreateTypeCollectionId(Collection<? extends Type> types)Generates a unique signature of a collection of types.static booleanfindInterceptorBindingConflicts(BeanManagerImpl manager, Set<Annotation> bindings)static <T> EnhancedAnnotatedConstructor<T>getBeanConstructor(EnhancedAnnotatedType<T> type)static <T> EnhancedAnnotatedConstructor<T>getBeanConstructorStrict(EnhancedAnnotatedType<T> type)static Class<? extends Annotation>getBeanDefiningAnnotationScope(javax.enterprise.inject.spi.AnnotatedType<?> annotatedType)static TypegetDeclaredBeanType(Class<?> clazz)Gets the declared bean typestatic <T> EnhancedAnnotatedType<T>getEjbImplementationClass(SessionBean<T> bean)ReturnsEnhancedAnnotatedTypefor the EJB implementation class.static <T> EnhancedAnnotatedType<T>getEjbImplementationClass(InternalEjbDescriptor<T> ejbDescriptor, BeanManagerImpl manager, EnhancedAnnotatedType<T> componentType)static org.jboss.weld.serialization.spi.BeanIdentifiergetIdentifier(javax.enterprise.context.spi.Contextual<?> contextual, org.jboss.weld.bootstrap.api.ServiceRegistry serviceRegistry)static org.jboss.weld.serialization.spi.BeanIdentifiergetIdentifier(javax.enterprise.context.spi.Contextual<?> contextual, org.jboss.weld.serialization.spi.ContextualStore contextualStore)static List<javax.enterprise.inject.spi.AnnotatedMethod<?>>getInterceptableMethods(javax.enterprise.inject.spi.AnnotatedType<?> type)static Set<Type>getTypedTypes(Map<Class<?>,Type> typeClosure, Class<?> rawType, javax.enterprise.inject.Typed typed)Bean types of a bean that uses theTypedannotation.static Set<Type>getTypes(EnhancedAnnotated<?,?> annotated)Illegal bean types are ignored except fo array and primitive types and unlessTypedis used.static <T> Set<Type>getTypes(EnhancedAnnotated<T,?> annotated, org.jboss.weld.ejb.spi.EjbDescriptor<T> ejbDescriptor)Bean types of a session bean.static booleanhasBuiltinScope(javax.enterprise.inject.spi.Bean<?> bean)static booleanhasSimpleCdiConstructor(javax.enterprise.inject.spi.AnnotatedType<?> type)static <T> voidinjectBoundFields(T instance, javax.enterprise.context.spi.CreationalContext<T> creationalContext, BeanManagerImpl manager, Iterable<? extends FieldInjectionPoint<?,?>> injectableFields)Injects bound fieldsstatic <T> voidinjectEEFields(Iterable<Set<ResourceInjection<?>>> resourceInjectionsHierarchy, T beanInstance, javax.enterprise.context.spi.CreationalContext<T> ctx)Injects EJBs and other EE resources.static <T> voidinjectFieldsAndInitializers(T instance, javax.enterprise.context.spi.CreationalContext<T> ctx, BeanManagerImpl beanManager, List<? extends Iterable<? extends FieldInjectionPoint<?,?>>> injectableFields, List<? extends Iterable<? extends MethodInjectionPoint<?,?>>> initializerMethods)static booleanisAlternative(EnhancedAnnotated<?,?> annotated, MergedStereotypes<?,?> mergedStereotypes)Is alternative.static booleanisBeanEnabled(javax.enterprise.inject.spi.Bean<?> bean, ModuleEnablement enabled)static booleanisBeanProxyable(javax.enterprise.inject.spi.Bean<?> bean, BeanManagerImpl manager)Indicates if a bean is proxyablestatic <T> booleanisDecorator(EnhancedAnnotatedType<T> annotatedItem)static booleanisDecoratorDeclaringInAppropriateConstructor(javax.enterprise.inject.spi.AnnotatedType<?> annotatedType)static booleanisDecoratorDeclaringInAppropriateConstructor(org.jboss.weld.resources.spi.ClassFileInfo classFileInfo)static <T> booleanisInterceptor(javax.enterprise.inject.spi.AnnotatedType<T> annotatedItem)static booleanisPassivatingScope(javax.enterprise.inject.spi.Bean<?> bean, BeanManagerImpl manager)Indicates if a bean's scope type is passivatingstatic booleanisPassivationCapableBean(javax.enterprise.inject.spi.Bean<?> bean)Tests if a bean is capable of having its state temporarily stored to secondary storagestatic booleanisPassivationCapableDependency(javax.enterprise.inject.spi.Bean<?> bean)Tests if a bean is capable of having its state temporarily stored to secondary storagestatic booleanisTypeManagedBeanOrDecoratorOrInterceptor(javax.enterprise.inject.spi.AnnotatedType<?> annotatedType)Indicates if the type is a simple Web Beanstatic booleanisTypeManagedBeanOrDecoratorOrInterceptor(org.jboss.weld.resources.spi.ClassFileInfo classFileInfo)static booleanisVetoed(Class<?> javaClass)Determines if this Java class should be vetoed as a result of presence ofVetoannotations.static booleanisVetoed(javax.enterprise.inject.spi.AnnotatedType<?> type)static Set<Annotation>mergeInQualifiers(BeanManagerImpl manager, Collection<Annotation> qualifiers, Annotation[] newQualifiers)static <T extends javax.enterprise.inject.spi.Bean<?>>
Set<T>removeDisabledBeans(Set<T> beans, BeanManagerImpl beanManager, SpecializationAndEnablementRegistry registry)Retains only beans which are enabled.
-
-
-
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, BeanManagerImpl manager)Indicates if a bean is proxyable- Parameters:
bean- The bean to test- Returns:
- True if proxyable, false otherwise
-
getInterceptableMethods
public static List<javax.enterprise.inject.spi.AnnotatedMethod<?>> getInterceptableMethods(javax.enterprise.inject.spi.AnnotatedType<?> type)
-
containsAllQualifiers
public static boolean containsAllQualifiers(Set<QualifierInstance> requiredQualifiers, Set<QualifierInstance> qualifiers)
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 qualifiersqualifiers- 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(BeanManagerImpl manager, Set<Annotation> bindings)
-
removeDisabledBeans
public static <T extends javax.enterprise.inject.spi.Bean<?>> Set<T> removeDisabledBeans(Set<T> beans, BeanManagerImpl beanManager, SpecializationAndEnablementRegistry registry)
Retains only beans which are enabled.- Parameters:
beans- The beans to filterbeanManager- The bean managerregistry-- Returns:
- An immutable set of enabled beans
-
isBeanEnabled
public static boolean isBeanEnabled(javax.enterprise.inject.spi.Bean<?> bean, ModuleEnablement enabled)
-
isAlternative
public static boolean isAlternative(EnhancedAnnotated<?,?> annotated, MergedStereotypes<?,?> mergedStereotypes)
Is alternative.- Parameters:
annotated- the annotatedmergedStereotypes- merged stereotypes- Returns:
- true if alternative, false otherwise
-
getBeanConstructorStrict
public static <T> EnhancedAnnotatedConstructor<T> getBeanConstructorStrict(EnhancedAnnotatedType<T> type)
-
getBeanConstructor
public static <T> EnhancedAnnotatedConstructor<T> getBeanConstructor(EnhancedAnnotatedType<T> type)
-
injectEEFields
public static <T> void injectEEFields(Iterable<Set<ResourceInjection<?>>> resourceInjectionsHierarchy, T beanInstance, javax.enterprise.context.spi.CreationalContext<T> ctx)
Injects EJBs and other EE resources.- Parameters:
resourceInjectionsHierarchy-beanInstance-ctx-
-
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(javax.enterprise.inject.spi.AnnotatedType<T> annotatedItem)
-
isDecorator
public static <T> boolean isDecorator(EnhancedAnnotatedType<T> annotatedItem)
-
mergeInQualifiers
public static Set<Annotation> mergeInQualifiers(BeanManagerImpl manager, Collection<Annotation> qualifiers, Annotation[] newQualifiers)
-
getTypes
public static Set<Type> getTypes(EnhancedAnnotated<?,?> annotated)
Illegal bean types are ignored except fo array and primitive types and unlessTypedis used.- Returns:
- the set of bean types from an annotated element
-
getTypes
public static <T> Set<Type> getTypes(EnhancedAnnotated<T,?> annotated, org.jboss.weld.ejb.spi.EjbDescriptor<T> ejbDescriptor)
Bean types of a session bean.
-
getTypedTypes
public static Set<Type> getTypedTypes(Map<Class<?>,Type> typeClosure, Class<?> rawType, javax.enterprise.inject.Typed typed)
Bean types of a bean that uses theTypedannotation.
-
isTypeManagedBeanOrDecoratorOrInterceptor
public static boolean isTypeManagedBeanOrDecoratorOrInterceptor(javax.enterprise.inject.spi.AnnotatedType<?> annotatedType)
Indicates if the type is a simple Web Bean- Parameters:
clazz- The type to inspect- Returns:
- True if simple Web Bean, false otherwise
-
isTypeManagedBeanOrDecoratorOrInterceptor
public static boolean isTypeManagedBeanOrDecoratorOrInterceptor(org.jboss.weld.resources.spi.ClassFileInfo classFileInfo)
-
isDecoratorDeclaringInAppropriateConstructor
public static boolean isDecoratorDeclaringInAppropriateConstructor(org.jboss.weld.resources.spi.ClassFileInfo classFileInfo)
-
isDecoratorDeclaringInAppropriateConstructor
public static boolean isDecoratorDeclaringInAppropriateConstructor(javax.enterprise.inject.spi.AnnotatedType<?> annotatedType)
-
hasSimpleCdiConstructor
public static boolean hasSimpleCdiConstructor(javax.enterprise.inject.spi.AnnotatedType<?> type)
-
isVetoed
public static boolean isVetoed(Class<?> javaClass)
Determines if this Java class should be vetoed as a result of presence ofVetoannotations.
-
isVetoed
public static boolean isVetoed(javax.enterprise.inject.spi.AnnotatedType<?> type)
-
createBeanAttributesId
public static String createBeanAttributesId(javax.enterprise.inject.spi.BeanAttributes<?> attributes)
Generates a unique signature forBeanAttributes.
-
createTypeCollectionId
public static String createTypeCollectionId(Collection<? extends Type> types)
Generates a unique signature of a collection of types.
-
checkEnhancedAnnotatedAvailable
public static <T,S,X extends EnhancedAnnotated<T,S>> X checkEnhancedAnnotatedAvailable(X enhancedAnnotated)
-
hasBuiltinScope
public static boolean hasBuiltinScope(javax.enterprise.inject.spi.Bean<?> bean)
-
getBeanDefiningAnnotationScope
public static Class<? extends Annotation> getBeanDefiningAnnotationScope(javax.enterprise.inject.spi.AnnotatedType<?> annotatedType)
-
getEjbImplementationClass
public static <T> EnhancedAnnotatedType<T> getEjbImplementationClass(SessionBean<T> bean)
ReturnsEnhancedAnnotatedTypefor the EJB implementation class. ThrowsIllegalStateExceptionif called after bootstrap.- Parameters:
bean-- Returns:
EnhancedAnnotatedTyperepresentation of this EJB's implementation class- Throws:
IllegalStateException- if called after bootstrap
-
getEjbImplementationClass
public static <T> EnhancedAnnotatedType<T> getEjbImplementationClass(InternalEjbDescriptor<T> ejbDescriptor, BeanManagerImpl manager, EnhancedAnnotatedType<T> componentType)
-
getIdentifier
public static org.jboss.weld.serialization.spi.BeanIdentifier getIdentifier(javax.enterprise.context.spi.Contextual<?> contextual, org.jboss.weld.serialization.spi.ContextualStore contextualStore)- Parameters:
contextual-contextualStore-- Returns:
- the identifier for the given contextual
- See Also:
getIdentifier(Contextual, ContextualStore, ServiceRegistry)
-
getIdentifier
public static org.jboss.weld.serialization.spi.BeanIdentifier getIdentifier(javax.enterprise.context.spi.Contextual<?> contextual, org.jboss.weld.bootstrap.api.ServiceRegistry serviceRegistry)- Parameters:
contextual-serviceRegistry-- Returns:
- the identifier for the given contextual
- See Also:
getIdentifier(Contextual, ContextualStore, ServiceRegistry)
-
-