Class WeldUtils


  • public class WeldUtils
    extends Object
    • Constructor Detail

      • WeldUtils

        public WeldUtils()
    • Method Detail

      • isImplicitBeanArchive

        public static boolean isImplicitBeanArchive​(DeploymentContext context,
                                                    ReadableArchive archive)
                                             throws IOException
        Determine whether the specified archive is an implicit bean deployment archive.
        Parameters:
        context - The deployment context
        archive - The archive in question
        Returns:
        true, if it is an implicit bean deployment archive; otherwise, false.
        Throws:
        IOException
      • isImplicitBeanArchive

        public static boolean isImplicitBeanArchive​(DeploymentContext context,
                                                    URI archivePath)
        Determine whether the specified archive is an implicit bean deployment archive.
        Parameters:
        context - The deployment context
        archivePath - The URI of the archive
        Returns:
        true, if it is an implicit bean deployment archive; otherwise, false.
      • hasCDIEnablingAnnotations

        public static boolean hasCDIEnablingAnnotations​(DeploymentContext context,
                                                        URI path)
        Determine whether there are any beans annotated with annotations that should enable CDI processing even in the absence of a beans.xml descriptor.
        Parameters:
        context - The DeploymentContext
        path - The path to check for annotated beans
        Returns:
        true, if there is at least one bean annotated with a qualified annotation in the specified path
      • hasCDIEnablingAnnotations

        public static boolean hasCDIEnablingAnnotations​(DeploymentContext context,
                                                        Collection<URI> paths)
        Determine whether there are any beans annotated with annotations that should enable CDI processing even in the absence of a beans.xml descriptor.
        Parameters:
        context - The DeploymentContext
        paths - The paths to check for annotated beans
        Returns:
        true, if there is at least one bean annotated with a qualified annotation in the specified paths
      • getCDIEnablingAnnotations

        public static String[] getCDIEnablingAnnotations​(DeploymentContext context)
        Get the names of any annotation types that are applied to beans, which should enable CDI processing even in the absence of a beans.xml descriptor.
        Parameters:
        context - The DeploymentContext
        Returns:
        An array of annotation type names; The array could be empty if none are found.
      • getCDIAnnotatedClassNames

        public static Collection<String> getCDIAnnotatedClassNames​(DeploymentContext context)
        Get the names of any classes that are annotated with bean-defining annotations, which should enable CDI processing even in the absence of a beans.xml descriptor.
        Parameters:
        context - The DeploymentContext
        Returns:
        A collection of class names; The collection could be empty if none are found.
      • hasScopeAnnotation

        public static boolean hasScopeAnnotation​(Class clazz)
        Determine whether the specified class is annotated with a CDI scope annotation.
        Parameters:
        clazz - The class to check.
        Returns:
        true, if the specified class has a CDI scope annotation; Otherwise, false.
      • hasCDIEnablingAnnotation

        public static boolean hasCDIEnablingAnnotation​(Class clazz)
        Determine whether the specified class is annotated with a CDI-enabling annotation.
        Parameters:
        clazz - The class to check.
        Returns:
        true, if the specified class has a CDI scope annotation; Otherwise, false.
      • hasValidAnnotation

        public static boolean hasValidAnnotation​(Class annotatedClass,
                                                 Set<String> validScopes,
                                                 Collection<String> excludedScopes)
        Determine whether the specified class is annotated with one of the annotations in the specified validScopes collection, but not with any of the annotations in the specified exclusion set.
        Parameters:
        annotatedClass - The class to check.
        validScopes - A collection of valid CDI scope type names
        excludedScopes - A collection of excluded CDI scope type names
        Returns:
        true, if the specified class has at least one of the annotations specified in validScopes, and none of the annotations specified in excludedScopes; Otherwise, false.
      • getPreLoaderThreads

        public static int getPreLoaderThreads()
      • isConcurrentDeploymentEnabled

        public static boolean isConcurrentDeploymentEnabled()
      • isImplicitBeanDiscoveryEnabled

        public static boolean isImplicitBeanDiscoveryEnabled()
      • isImplicitBeanDiscoveryEnabled

        public static boolean isImplicitBeanDiscoveryEnabled​(DeploymentContext context)
      • isCDIDevModeEnabled

        public static boolean isCDIDevModeEnabled​(DeploymentContext context)
      • setCDIDevMode

        public static void setCDIDevMode​(DeploymentContext context,
                                         boolean enabled)
      • isValidBdaBasedOnExtensionAndBeansXml

        public static boolean isValidBdaBasedOnExtensionAndBeansXml​(ReadableArchive archive)
        Determine if an archive is a valid bda based on what the spec says about extensions. See section 12.1 which states that if an archive contains an extension but no beans.xml then it is NOT a valid bean deployment archive.
        Parameters:
        archive - The archive to check.
        Returns:
        false if there is an extension and no beans.xml true otherwise
      • getBeanDiscoveryMode

        public static String getBeanDiscoveryMode​(InputStream beansXmlInputStream)
        Get the "bean-discovery-mode" from the "beans" element if it exists in beans.xml From section 12.1 of CDI spec: A bean archive has a bean discovery mode of all, annotated or none. A bean archive which contains a beans.xml file with no version has a default bean discovery mode of all. A bean archive which contains a beans.xml file with version 1.1 (or later) must specify the bean- discovey-mode attribute. The default value for the attribute is annotated.
        Parameters:
        beansXmlInputStream - The InputStream for the beans.xml to check.
        Returns:
        "annotated" if there is no beans.xml "all" if the bean-discovery-mode is missing "annotated" if the bean-discovery-mode is empty The value of bean-discovery-mode in all other cases.