org.springframework.instrument.classloading

Class ResourceOverridingShadowingClassLoader



  • public class ResourceOverridingShadowingClassLoader
    extends ShadowingClassLoader
    Subclass of ShadowingClassLoader that overrides attempts to locate certain files.
    Since:
    2.0
    Author:
    Rod Johnson, Adrian Colyer
    • Constructor Summary

      Constructors 
      Constructor and Description
      ResourceOverridingShadowingClassLoader(java.lang.ClassLoader enclosingClassLoader)
      Create a new ResourceOverridingShadowingClassLoader, decorating the given ClassLoader.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void copyOverrides(ResourceOverridingShadowingClassLoader other)
      Copy all overrides from the given ClassLoader.
      java.net.URL getResource(java.lang.String requestedPath) 
      java.io.InputStream getResourceAsStream(java.lang.String requestedPath) 
      java.util.Enumeration<java.net.URL> getResources(java.lang.String requestedPath) 
      void override(java.lang.String oldPath, java.lang.String newPath)
      Return the resource (if any) at the new path on an attempt to locate a resource at the old path.
      void suppress(java.lang.String oldPath)
      Ensure that a resource with the given path is not found.
      • Methods inherited from class java.lang.ClassLoader

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

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

      • ResourceOverridingShadowingClassLoader

        public ResourceOverridingShadowingClassLoader(java.lang.ClassLoader enclosingClassLoader)
        Create a new ResourceOverridingShadowingClassLoader, decorating the given ClassLoader.
        Parameters:
        enclosingClassLoader - the ClassLoader to decorate
    • Method Detail

      • override

        public void override(java.lang.String oldPath,
                             java.lang.String newPath)
        Return the resource (if any) at the new path on an attempt to locate a resource at the old path.
        Parameters:
        oldPath - the path requested
        newPath - the actual path to be looked up
      • suppress

        public void suppress(java.lang.String oldPath)
        Ensure that a resource with the given path is not found.
        Parameters:
        oldPath - the path of the resource to hide even if it exists in the parent ClassLoader
      • copyOverrides

        public void copyOverrides(ResourceOverridingShadowingClassLoader other)
        Copy all overrides from the given ClassLoader.
        Parameters:
        other - the other ClassLoader to copy from
      • getResources

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