Class JBossClassLoaderHandler
- java.lang.Object
-
- nonapi.io.github.classgraph.classloaderhandler.JBossClassLoaderHandler
-
- All Implemented Interfaces:
ClassLoaderHandler
class JBossClassLoaderHandler extends java.lang.Object implements ClassLoaderHandler
Extract classpath entries from the JBoss ClassLoader. See:https://github.com/jboss-modules/jboss-modules/blob/master/src/main/java/org/jboss/modules/ModuleClassLoader.java
-
-
Constructor Summary
Constructors Modifier Constructor Description privateJBossClassLoaderHandler()Class cannot be constructed.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleancanHandle(java.lang.Class<?> classLoaderClass, LogNode log)Check whether thisClassLoaderHandlercan handle a givenClassLoader.static voidfindClassLoaderOrder(java.lang.ClassLoader classLoader, ClassLoaderOrder classLoaderOrder, LogNode log)Find theClassLoaderdelegation order for aClassLoader.static voidfindClasspathOrder(java.lang.ClassLoader classLoader, ClasspathOrder classpathOrder, ScanSpec scanSpec, LogNode log)Find the classpath entries for the associatedClassLoader.private static java.lang.Class<?>getJBossVFSAccess(java.lang.Object root)Get the access to the JBoss VFS class.private static voidhandleRealModule(java.lang.Object module, java.util.Set<java.lang.Object> visitedModules, java.lang.ClassLoader classLoader, ClasspathOrder classpathOrderOut, ScanSpec scanSpec, LogNode log)Handle a module.private static voidhandleResourceLoader(java.lang.Object resourceLoader, java.lang.ClassLoader classLoader, ClasspathOrder classpathOrderOut, ScanSpec scanSpec, LogNode log)Handle a resource loader.private static booleanisPathExisting(java.lang.String path)Checks if the given path exists and is a regular file.private static java.lang.StringloadJarPathFromClassicVFS(java.lang.Object root, ClasspathOrder classpathOrderOut)Returns the absolute path of a JAR file from a given root object using the 'classic' VFS read mechanism.private static java.lang.StringloadJarPathFromNewVFS(java.lang.Object root, ClasspathOrder classpathOrderOut)Returns the absolute path of a JAR file from a given root object using the JBoss VFS mechanism.private static java.lang.Class<?>loadJBossVFS(java.lang.ClassLoader classLoader)
-
-
-
Method Detail
-
canHandle
public static boolean canHandle(java.lang.Class<?> classLoaderClass, LogNode log)Check whether thisClassLoaderHandlercan handle a givenClassLoader.- Parameters:
classLoaderClass- theClassLoaderclass or one of its superclasses.log- the log- Returns:
- true if this
ClassLoaderHandlercan handle theClassLoader.
-
findClassLoaderOrder
public static void findClassLoaderOrder(java.lang.ClassLoader classLoader, ClassLoaderOrder classLoaderOrder, LogNode log)Find theClassLoaderdelegation order for aClassLoader.- Parameters:
classLoader- theClassLoaderto find the order for.classLoaderOrder- aClassLoaderOrderobject to update.log- the log
-
handleResourceLoader
private static void handleResourceLoader(java.lang.Object resourceLoader, java.lang.ClassLoader classLoader, ClasspathOrder classpathOrderOut, ScanSpec scanSpec, LogNode log)Handle a resource loader.- Parameters:
resourceLoader- the resource loaderclassLoader- the classloaderclasspathOrderOut- the classpath orderscanSpec- the scan speclog- the log
-
isPathExisting
private static boolean isPathExisting(java.lang.String path)
Checks if the given path exists and is a regular file.- Parameters:
path- the path to check- Returns:
- true if the path exists and is a regular file, false otherwise
-
loadJarPathFromNewVFS
private static java.lang.String loadJarPathFromNewVFS(java.lang.Object root, ClasspathOrder classpathOrderOut)Returns the absolute path of a JAR file from a given root object using the JBoss VFS mechanism. This works for Versions of JBoss/Wildfly that contain the following change: WFLY-18544 JBEAP-25879 JBEAP-25677- Parameters:
root- The root object to get the JAR path from.classpathOrderOut- The ClasspathOrder object for updating the classpath order.- Returns:
- The absolute path of the JAR file, or null if the path couldn't be found.
-
getJBossVFSAccess
private static java.lang.Class<?> getJBossVFSAccess(java.lang.Object root)
Get the access to the JBoss VFS class. Tries to load VFS first from the classloader of the provided root object if it's an object from org.jboss.vfs. If the root object is not from org.jboss.vfs, VFS will be tried to be loaded from the current thread class loader. It might be unnecessary to load VFS from the current thread context, because this means that the root object is not from org.jboss.vfs and VFS will not help here... but as a defensive approach we really try to get VFS access here.- Parameters:
root- The root VirtualFile of JBoss VFS. Used to load the VFS via the classloader of the root. Can not be null.- Returns:
- The Class object representing the JBoss VFS class, or null if it couldn't be found.
-
loadJBossVFS
private static java.lang.Class<?> loadJBossVFS(java.lang.ClassLoader classLoader) throws java.lang.ClassNotFoundException- Throws:
java.lang.ClassNotFoundException
-
loadJarPathFromClassicVFS
private static java.lang.String loadJarPathFromClassicVFS(java.lang.Object root, ClasspathOrder classpathOrderOut)Returns the absolute path of a JAR file from a given root object using the 'classic' VFS read mechanism. This works for Versions of JBoss/Wildfly prior to this change: WFLY-18544 JBEAP-25879 JBEAP-25677- Parameters:
root- The root object to get the JAR path from.classpathOrderOut- The ClasspathOrder object for updating the classpath order.- Returns:
- The absolute path of the JAR file, or null if the path couldn't be found.
-
handleRealModule
private static void handleRealModule(java.lang.Object module, java.util.Set<java.lang.Object> visitedModules, java.lang.ClassLoader classLoader, ClasspathOrder classpathOrderOut, ScanSpec scanSpec, LogNode log)Handle a module.- Parameters:
module- the modulevisitedModules- visited modulesclassLoader- the classloaderclasspathOrderOut- the classpath orderscanSpec- the scan speclog- the log
-
findClasspathOrder
public static void findClasspathOrder(java.lang.ClassLoader classLoader, ClasspathOrder classpathOrder, ScanSpec scanSpec, LogNode log)Find the classpath entries for the associatedClassLoader.- Parameters:
classLoader- theClassLoaderto find the classpath entries order for.classpathOrder- aClasspathOrderobject to update.scanSpec- theScanSpec.log- the log.
-
-