Class LoaderUtil

    • Field Detail

      • IGNORE_TCCL_PROPERTY

        public static final String IGNORE_TCCL_PROPERTY
        System property to set to ignore the thread context ClassLoader.
        Since:
        2.1
        See Also:
        Constant Field Values
    • Method Detail

      • getThreadContextClassLoader

        public static ClassLoader getThreadContextClassLoader()
        Gets the current Thread ClassLoader. Returns the system ClassLoader if the TCCL is null. If the system ClassLoader is null as well, then the ClassLoader for this class is returned. If running with a SecurityManager that does not allow access to the Thread ClassLoader or system ClassLoader, then the ClassLoader for this class is returned.
        Returns:
        the current ThreadContextClassLoader.
      • getClassLoaders

        public static ClassLoader[] getClassLoaders()
      • isClassAvailable

        public static boolean isClassAvailable​(String className)
        Determines if a named Class can be loaded or not.
        Parameters:
        className - The class name.
        Returns:
        true if the class could be found or false otherwise.
        Since:
        2.7
      • loadClass

        public static Class<?> loadClass​(String className)
                                  throws ClassNotFoundException
        Loads a class by name. This method respects the IGNORE_TCCL_PROPERTY Log4j property. If this property is specified and set to anything besides false, then the default ClassLoader will be used.
        Parameters:
        className - The class name.
        Returns:
        the Class for the given name.
        Throws:
        ClassNotFoundException - if the specified class name could not be found
        Since:
        2.1
      • findResources

        public static Collection<URL> findResources​(String resource)
        Finds classpath resources.
        Parameters:
        resource - the name of the resource to find.
        Returns:
        a Collection of URLs matching the resource name. If no resources could be found, then this will be empty.
        Since:
        2.1