Class WebsphereLibertyClassLoaderHandler

  • All Implemented Interfaces:
    ClassLoaderHandler

    class WebsphereLibertyClassLoaderHandler
    extends java.lang.Object
    implements ClassLoaderHandler
    WebsphereLibertyClassLoaderHandler.

    Used to support WAS Liberty Profile classloading in io.github.classgraph

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.lang.String IBM_APP_CLASS_LOADER
      "com.ibm.ws.classloading.internal.AppClassLoader"
      private static java.lang.String IBM_THREAD_CONTEXT_CLASS_LOADER
      "com.ibm.ws.classloading.internal.ThreadContextClassLoader"
      private static java.lang.String PKG_PREFIX
      "com.ibm.ws.classloading.internal."
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static java.util.Collection<java.lang.Object> callGetUrls​(java.lang.Object container, java.lang.String methodName, ReflectionUtils reflectionUtils)
      Utility to call a "getURLs" method, flattening "collections of collections" and ignoring "UnsupportedOperationException".
      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.util.Collection<java.lang.Object> getPaths​(java.lang.Object containerClassLoader, ReflectionUtils reflectionUtils)
      Get the paths from a containerClassLoader object.
      • Methods inherited from class java.lang.Object

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

      • PKG_PREFIX

        private static final java.lang.String PKG_PREFIX
        "com.ibm.ws.classloading.internal."
        See Also:
        Constant Field Values
      • IBM_APP_CLASS_LOADER

        private static final java.lang.String IBM_APP_CLASS_LOADER
        "com.ibm.ws.classloading.internal.AppClassLoader"
        See Also:
        Constant Field Values
      • IBM_THREAD_CONTEXT_CLASS_LOADER

        private static final java.lang.String IBM_THREAD_CONTEXT_CLASS_LOADER
        "com.ibm.ws.classloading.internal.ThreadContextClassLoader"
        See Also:
        Constant Field Values
    • Constructor Detail

      • WebsphereLibertyClassLoaderHandler

        private WebsphereLibertyClassLoaderHandler()
        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
      • getPaths

        private static java.util.Collection<java.lang.Object> getPaths​(java.lang.Object containerClassLoader,
                                                                       ReflectionUtils reflectionUtils)
        Get the paths from a containerClassLoader object.

        The passed in object should be an instance of "com.ibm.ws.classloading.internal.ContainerClassLoader".

        Will attempt to use "getContainerURLs" methods to recap the classpath.

        Parameters:
        containerClassLoader - the containerClassLoader object
        Returns:
        Collection of path objects as a URL or String.
      • callGetUrls

        private static java.util.Collection<java.lang.Object> callGetUrls​(java.lang.Object container,
                                                                          java.lang.String methodName,
                                                                          ReflectionUtils reflectionUtils)
        Utility to call a "getURLs" method, flattening "collections of collections" and ignoring "UnsupportedOperationException". All of the "getURLs" methods eventually call "com.ibm.wsspi.adaptable.module.Container#getURLs()". https://www.ibm.com/support/knowledgecenter/SSEQTP_liberty/com.ibm.websphere.javadoc.liberty.doc /com.ibm.websphere.appserver.spi.artifact_1.2-javadoc /com/ibm/wsspi/adaptable/module/Container.html?view=embed#getURLs() "A collection of URLs that represent all of the locations on disk that contribute to this container"
      • 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.