Class JBossClassLoaderHandler

java.lang.Object
nonapi.io.github.classgraph.classloaderhandler.JBossClassLoaderHandler
All Implemented Interfaces:
ClassLoaderHandler

class JBossClassLoaderHandler extends 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 Details

    • JBossClassLoaderHandler

      private JBossClassLoaderHandler()
      Class cannot be constructed.
  • Method Details

    • canHandle

      public static boolean canHandle(Class<?> classLoaderClass, LogNode log)
      Check whether this ClassLoaderHandler can handle a given ClassLoader.
      Parameters:
      classLoaderClass - the ClassLoader class or one of its superclasses.
      log - the log
      Returns:
      true if this ClassLoaderHandler can handle the ClassLoader.
    • findClassLoaderOrder

      public static void findClassLoaderOrder(ClassLoader classLoader, ClassLoaderOrder classLoaderOrder, LogNode log)
      Find the ClassLoader delegation order for a ClassLoader.
      Parameters:
      classLoader - the ClassLoader to find the order for.
      classLoaderOrder - a ClassLoaderOrder object to update.
      log - the log
    • handleResourceLoader

      private static void handleResourceLoader(Object resourceLoader, ClassLoader classLoader, ClasspathOrder classpathOrderOut, ScanSpec scanSpec, LogNode log)
      Handle a resource loader.
      Parameters:
      resourceLoader - the resource loader
      classLoader - the classloader
      classpathOrderOut - the classpath order
      scanSpec - the scan spec
      log - the log
    • isPathExisting

      private static boolean isPathExisting(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 String loadJarPathFromNewVFS(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 Class<?> getJBossVFSAccess(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 Class<?> loadJBossVFS(ClassLoader classLoader) throws ClassNotFoundException
      Throws:
      ClassNotFoundException
    • loadJarPathFromClassicVFS

      private static String loadJarPathFromClassicVFS(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(Object module, Set<Object> visitedModules, ClassLoader classLoader, ClasspathOrder classpathOrderOut, ScanSpec scanSpec, LogNode log)
      Handle a module.
      Parameters:
      module - the module
      visitedModules - visited modules
      classLoader - the classloader
      classpathOrderOut - the classpath order
      scanSpec - the scan spec
      log - the log
    • findClasspathOrder

      public static void findClasspathOrder(ClassLoader classLoader, ClasspathOrder classpathOrder, ScanSpec scanSpec, LogNode log)
      Find the classpath entries for the associated ClassLoader.
      Parameters:
      classLoader - the ClassLoader to find the classpath entries order for.
      classpathOrder - a ClasspathOrder object to update.
      scanSpec - the ScanSpec.
      log - the log.