Class Beans


  • public class Beans
    extends Object
    Helper class for bean inspection
    Author:
    Pete Muir, David Allen, Marius Bogoevici, Ales Justin, Jozef Hartinger
    • Method Detail

      • isPassivatingScope

        public static boolean isPassivatingScope​(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​(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​(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​(Bean<?> bean,
                                              BeanManagerImpl manager)
        Indicates if a bean is proxyable
        Parameters:
        bean - The bean to test
        Returns:
        True if proxyable, false otherwise
      • 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 qualifiers
        qualifiers - The set of qualifiers to check
        Returns:
        True if all matches, false otherwise
      • removeDisabledBeans

        public static <T extends Bean<?>> Set<T> removeDisabledBeans​(Set<T> beans,
                                                                     BeanManagerImpl beanManager)
        Retains only beans which are enabled.
        Parameters:
        beans - The mutable set of beans to filter
        beanManager - The bean manager
        Returns:
        a mutable set of enabled beans
      • isAlternative

        public static boolean isAlternative​(EnhancedAnnotated<?,​?> annotated,
                                            MergedStereotypes<?,​?> mergedStereotypes)
        Is alternative.
        Parameters:
        annotated - the annotated
        mergedStereotypes - merged stereotypes
        Returns:
        true if alternative, false otherwise
      • injectEEFields

        public static <T> void injectEEFields​(Iterable<Set<ResourceInjection<?>>> resourceInjectionsHierarchy,
                                              T beanInstance,
                                              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
      • isInterceptor

        public static <T> boolean isInterceptor​(AnnotatedType<T> annotatedItem)
      • getTypes

        public static Set<Type> getTypes​(EnhancedAnnotated<?,​?> annotated)
        Illegal bean types are ignored except for array and primitive types and unless Typed is used.
        Returns:
        the set of bean types from an annotated element
      • getTypedTypes

        public static Set<Type> getTypedTypes​(Map<Class<?>,​Type> typeClosure,
                                              Class<?> rawType,
                                              Typed typed)
        Bean types of a bean that uses the Typed annotation.
      • isTypeManagedBeanOrDecoratorOrInterceptor

        public static boolean isTypeManagedBeanOrDecoratorOrInterceptor​(AnnotatedType<?> annotatedType)
        Indicates if the type is a simple Web Bean
        Parameters:
        annotatedType - The type to inspect
        Returns:
        True if simple Web Bean, false otherwise
      • isTypeManagedBeanOrDecoratorOrInterceptor

        public static boolean isTypeManagedBeanOrDecoratorOrInterceptor​(org.jboss.weld.resources.spi.ClassFileInfo classFileInfo,
                                                                        boolean checkTypeModifiers)
        Parameters:
        classFileInfo -
        checkTypeModifiers - - this flag reflects whether Jandex version including fix for JANDEX-37 could be used
        Returns:
      • isDecoratorDeclaringInAppropriateConstructor

        public static boolean isDecoratorDeclaringInAppropriateConstructor​(org.jboss.weld.resources.spi.ClassFileInfo classFileInfo)
      • isDecoratorDeclaringInAppropriateConstructor

        public static boolean isDecoratorDeclaringInAppropriateConstructor​(AnnotatedType<?> annotatedType)
      • hasSimpleCdiConstructor

        public static boolean hasSimpleCdiConstructor​(AnnotatedType<?> type)
      • isVetoed

        public static boolean isVetoed​(Class<?> javaClass)
        Determines if this Java class should be vetoed as a result of presence of Veto annotations.
      • isVetoed

        public static boolean isVetoed​(AnnotatedType<?> type)
      • 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​(Bean<?> bean)
      • getBeanDefiningAnnotationScope

        public static Class<? extends Annotation> getBeanDefiningAnnotationScope​(AnnotatedType<?> annotatedType)
      • getLegalBeanTypes

        public static Set<Type> getLegalBeanTypes​(Set<Type> types,
                                                  Object baseType,
                                                  Type... additionalTypes)
        Parameters:
        types - The initial set of types
        baseType -
        additionalTypes - Types to add to the initial set
        Returns:
        the set of legal bean types
      • getIdentifier

        public static org.jboss.weld.serialization.spi.BeanIdentifier getIdentifier​(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​(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)
      • shouldIgnoreFinalMethods

        public static boolean shouldIgnoreFinalMethods​(Bean<?> bean)
        Parameters:
        bean -
        Returns:
        true if final methods should be ignored when checking proxyability
      • unwrap

        public static Bean<?> unwrap​(Bean<?> bean)