Class WMUrlClassLoader

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public class WMUrlClassLoader
    extends java.net.URLClassLoader
    • Constructor Summary

      Constructors 
      Constructor Description
      WMUrlClassLoader​(java.net.URL[] urls, java.lang.String loaderContext)  
      WMUrlClassLoader​(java.net.URL[] urls, java.lang.String loaderContext, java.lang.ClassLoader parent)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.net.URL getResource​(java.lang.String name)
      If we want to load a resource and it is available in both the parent classloader and the child classloader, then the default behaviour is, first it will check in the parent classloader if it not found then it will check in the child classloader.
      java.util.Enumeration<java.net.URL> getResources​(java.lang.String name)  
      java.lang.String toString()  
      • Methods inherited from class java.net.URLClassLoader

        addURL, close, definePackage, findClass, findResource, findResources, getPermissions, getResourceAsStream, getURLs, newInstance, newInstance
      • Methods inherited from class java.security.SecureClassLoader

        defineClass, defineClass
      • Methods inherited from class java.lang.ClassLoader

        clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getName, getPackage, getPackages, getParent, getPlatformClassLoader, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
      • Methods inherited from class java.lang.Object

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

      • WMUrlClassLoader

        public WMUrlClassLoader​(java.net.URL[] urls,
                                java.lang.String loaderContext,
                                java.lang.ClassLoader parent)
      • WMUrlClassLoader

        public WMUrlClassLoader​(java.net.URL[] urls,
                                java.lang.String loaderContext)
    • Method Detail

      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getResource

        public java.net.URL getResource​(java.lang.String name)
        If we want to load a resource and it is available in both the parent classloader and the child classloader, then the default behaviour is, first it will check in the parent classloader if it not found then it will check in the child classloader. So if we want to load the this type resource, we will always get the resource from the parent classloader, child's resource will never get loaded. To solve this first we are checking in the child classloader, if it is not found then checking in the parent classloader.
        Overrides:
        getResource in class java.lang.ClassLoader
        Parameters:
        name - The resource name
        Returns:
        A URL object for reading the resource, or null if the resource could not be found or the invoker doesn't have adequate privileges to get the resource.
      • getResources

        public java.util.Enumeration<java.net.URL> getResources​(java.lang.String name)
                                                         throws java.io.IOException
        Overrides:
        getResources in class java.lang.ClassLoader
        Throws:
        java.io.IOException