Class 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
      private JBossClassLoaderHandler()
      Class cannot be constructed.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean canHandle​(java.lang.Class<?> classLoaderClass, LogNode log)
      Check whether this ClassLoaderHandler can handle a given ClassLoader.
      static void findClassLoaderOrder​(java.lang.ClassLoader classLoader, ClassLoaderOrder classLoaderOrder, LogNode log)
      Find the ClassLoader delegation order for a ClassLoader.
      static void findClasspathOrder​(java.lang.ClassLoader classLoader, ClasspathOrder classpathOrder, ScanSpec scanSpec, LogNode log)
      Find the classpath entries for the associated ClassLoader.
      private static java.lang.Class<?> getJBossVFSAccess​(java.lang.Object root)
      Get the access to the JBoss VFS class.
      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.
      private static void handleResourceLoader​(java.lang.Object resourceLoader, java.lang.ClassLoader classLoader, ClasspathOrder classpathOrderOut, ScanSpec scanSpec, LogNode log)
      Handle a resource loader.
      private static boolean isPathExisting​(java.lang.String path)
      Checks if the given path exists and is a regular file.
      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.
      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.
      private static java.lang.Class<?> loadJBossVFS​(java.lang.ClassLoader classLoader)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JBossClassLoaderHandler

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

      • canHandle

        public static boolean canHandle​(java.lang.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​(java.lang.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​(java.lang.Object resourceLoader,
                                                 java.lang.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​(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 module
        visitedModules - visited modules
        classLoader - the classloader
        classpathOrderOut - the classpath order
        scanSpec - the scan spec
        log - the log
      • findClasspathOrder

        public static void findClasspathOrder​(java.lang.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.