Package org.glassfish.weld.connector
Class WeldUtils
- java.lang.Object
-
- org.glassfish.weld.connector.WeldUtils
-
public class WeldUtils extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classWeldUtils.BDATypeBean Deployment Archive type.
-
Field Summary
Fields Modifier and Type Field Description static StringBEANS_XML_FILENAMEprotected static Set<String>cdiEnablingAnnotationsprotected static Set<String>cdiScopeAnnotationsstatic StringCLASS_SUFFIXstatic StringEXPANDED_JAR_SUFFIXstatic StringEXPANDED_RAR_SUFFIXstatic StringJAR_SUFFIXstatic StringMETA_INF_BCE_SERVICES_EXTENSIONstatic StringMETA_INF_BEANS_XMLstatic StringMETA_INF_SERVICES_EXTENSIONstatic StringRAR_SUFFIXstatic charSEPARATOR_CHARstatic StringWEB_INFstatic StringWEB_INF_BCE_EXTENSIONstatic StringWEB_INF_BEANS_XMLstatic StringWEB_INF_CLASSESstatic StringWEB_INF_CLASSES_META_INF_BEANS_XMLstatic StringWEB_INF_LIBstatic StringWEB_INF_SERVICES_EXTENSION
-
Constructor Summary
Constructors Constructor Description WeldUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringgetBeanDiscoveryMode(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.static InputStreamgetBeansXmlInputStream(ReadableArchive archive)static InputStreamgetBeansXmlInputStream(DeploymentContext context)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.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.static Collection<String>getInjectionTargetClassNames(org.glassfish.hk2.classmodel.reflect.Types types, Collection<String> knownClassNames)Searches through the known class names of aBeanDeploymentArchiveto determine which have fields or methods with theInjectannotation.static intgetPreLoaderThreads()static booleanhasBeansXML(ReadableArchive archive)static booleanhasCDIEnablingAnnotation(Class clazz)Determine whether the specified class is annotated with a CDI-enabling annotation.static booleanhasCDIEnablingAnnotations(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.static booleanhasCDIEnablingAnnotations(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.static booleanhasExtension(ReadableArchive archive)static booleanhasScopeAnnotation(Class clazz)Determine whether the specified class is annotated with a CDI scope annotation.static booleanhasValidAnnotation(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.static booleanisCDIDevModeEnabled(DeploymentContext context)static booleanisConcurrentDeploymentEnabled()static booleanisEmptyBeansXmlModeALL(DeploymentContext context)static booleanisImplicitBeanArchive(DeploymentContext context, URI archivePath)Determine whether the specified archive is an implicit bean deployment archive.static booleanisImplicitBeanArchive(DeploymentContext context, ReadableArchive archive)Determine whether the specified archive is an implicit bean deployment archive.static booleanisImplicitBeanDiscoveryEnabled()static booleanisImplicitBeanDiscoveryEnabled(DeploymentContext context)static booleanisValidBdaBasedOnExtensionAndBeansXml(ReadableArchive archive)Determine if an archive is a valid bda based on what the spec says about extensions.static voidsetCDIDevMode(DeploymentContext context, boolean enabled)
-
-
-
Field Detail
-
SEPARATOR_CHAR
public static final char SEPARATOR_CHAR
- See Also:
- Constant Field Values
-
WEB_INF
public static final String WEB_INF
- See Also:
- Constant Field Values
-
WEB_INF_CLASSES
public static final String WEB_INF_CLASSES
- See Also:
- Constant Field Values
-
WEB_INF_LIB
public static final String WEB_INF_LIB
- See Also:
- Constant Field Values
-
BEANS_XML_FILENAME
public static final String BEANS_XML_FILENAME
- See Also:
- Constant Field Values
-
WEB_INF_BEANS_XML
public static final String WEB_INF_BEANS_XML
- See Also:
- Constant Field Values
-
META_INF_BEANS_XML
public static final String META_INF_BEANS_XML
- See Also:
- Constant Field Values
-
WEB_INF_CLASSES_META_INF_BEANS_XML
public static final String WEB_INF_CLASSES_META_INF_BEANS_XML
- See Also:
- Constant Field Values
-
META_INF_SERVICES_EXTENSION
public static final String META_INF_SERVICES_EXTENSION
- See Also:
- Constant Field Values
-
META_INF_BCE_SERVICES_EXTENSION
public static final String META_INF_BCE_SERVICES_EXTENSION
- See Also:
- Constant Field Values
-
WEB_INF_SERVICES_EXTENSION
public static final String WEB_INF_SERVICES_EXTENSION
- See Also:
- Constant Field Values
-
WEB_INF_BCE_EXTENSION
public static final String WEB_INF_BCE_EXTENSION
- See Also:
- Constant Field Values
-
CLASS_SUFFIX
public static final String CLASS_SUFFIX
- See Also:
- Constant Field Values
-
JAR_SUFFIX
public static final String JAR_SUFFIX
- See Also:
- Constant Field Values
-
RAR_SUFFIX
public static final String RAR_SUFFIX
- See Also:
- Constant Field Values
-
EXPANDED_RAR_SUFFIX
public static final String EXPANDED_RAR_SUFFIX
- See Also:
- Constant Field Values
-
EXPANDED_JAR_SUFFIX
public static final String EXPANDED_JAR_SUFFIX
- See Also:
- Constant Field Values
-
-
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 contextarchive- 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 contextarchivePath- 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 DeploymentContextpath- 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 DeploymentContextpaths- 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.
-
getInjectionTargetClassNames
public static Collection<String> getInjectionTargetClassNames(org.glassfish.hk2.classmodel.reflect.Types types, Collection<String> knownClassNames)
Searches through the known class names of aBeanDeploymentArchiveto determine which have fields or methods with theInjectannotation.- Parameters:
types- The Types obtained from aDeploymentContext's transient metadataknownClassNames- The known class names of aBeanDeploymentArchive- Returns:
- The class names from the given list which have fields or methods annotated with
Inject
-
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 namesexcludedScopes- 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)
-
isEmptyBeansXmlModeALL
public static boolean isEmptyBeansXmlModeALL(DeploymentContext context)
-
getBeansXmlInputStream
public static InputStream getBeansXmlInputStream(DeploymentContext context)
-
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
-
hasExtension
public static boolean hasExtension(ReadableArchive archive)
-
hasBeansXML
public static boolean hasBeansXML(ReadableArchive archive) throws IOException
- Throws:
IOException
-
getBeansXmlInputStream
public static InputStream getBeansXmlInputStream(ReadableArchive archive)
-
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 annotated. 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 "annotated" 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.
-
-