Spring Framework

org.springframework.instrument.classloading
Class ShadowingClassLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by org.springframework.core.DecoratingClassLoader
          extended by org.springframework.instrument.classloading.ShadowingClassLoader
Direct Known Subclasses:
ResourceOverridingShadowingClassLoader

public class ShadowingClassLoader
extends DecoratingClassLoader

ClassLoader decorator that shadows an enclosing ClassLoader, applying registered transformers to all affected classes.

Since:
2.0
Author:
Rob Harrop, Juergen Hoeller, Costin Leau
See Also:
addTransformer(java.lang.instrument.ClassFileTransformer), OverridingClassLoader

Field Summary
static java.lang.String[] DEFAULT_EXCLUDED_PACKAGES
          Packages that are excluded by default
 
Constructor Summary
ShadowingClassLoader(java.lang.ClassLoader enclosingClassLoader)
          Create a new ShadowingClassLoader, decorating the given ClassLoader.
 
Method Summary
 void addTransformer(java.lang.instrument.ClassFileTransformer transformer)
          Add the given ClassFileTransformer to the list of transformers that this ClassLoader will apply.
 void copyTransformers(ShadowingClassLoader other)
          Copy all ClassFileTransformers from the given ClassLoader to the list of transformers that this ClassLoader will apply.
 java.net.URL getResource(java.lang.String name)
           
 java.io.InputStream getResourceAsStream(java.lang.String name)
           
 java.util.Enumeration<java.net.URL> getResources(java.lang.String name)
           
protected  boolean isEligibleForShadowing(java.lang.String className)
          Determine whether the specified class is eligible for shadowing by this class loader.
 java.lang.Class<?> loadClass(java.lang.String name)
           
 
Methods inherited from class org.springframework.core.DecoratingClassLoader
excludeClass, excludePackage, isExcluded
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findResources, findSystemClass, getPackage, getPackages, getParent, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_EXCLUDED_PACKAGES

public static final java.lang.String[] DEFAULT_EXCLUDED_PACKAGES
Packages that are excluded by default

Constructor Detail

ShadowingClassLoader

public ShadowingClassLoader(java.lang.ClassLoader enclosingClassLoader)
Create a new ShadowingClassLoader, decorating the given ClassLoader.

Parameters:
enclosingClassLoader - the ClassLoader to decorate
Method Detail

addTransformer

public void addTransformer(java.lang.instrument.ClassFileTransformer transformer)
Add the given ClassFileTransformer to the list of transformers that this ClassLoader will apply.

Parameters:
transformer - the ClassFileTransformer

copyTransformers

public void copyTransformers(ShadowingClassLoader other)
Copy all ClassFileTransformers from the given ClassLoader to the list of transformers that this ClassLoader will apply.

Parameters:
other - the ClassLoader to copy from

loadClass

public java.lang.Class<?> loadClass(java.lang.String name)
                             throws java.lang.ClassNotFoundException
Overrides:
loadClass in class java.lang.ClassLoader
Throws:
java.lang.ClassNotFoundException

isEligibleForShadowing

protected boolean isEligibleForShadowing(java.lang.String className)
Determine whether the specified class is eligible for shadowing by this class loader.

Parameters:
className - the class name to check
Returns:
whether the specified class is eligible
See Also:
DecoratingClassLoader.isExcluded(java.lang.String)

getResource

public java.net.URL getResource(java.lang.String name)
Overrides:
getResource in class java.lang.ClassLoader

getResourceAsStream

public java.io.InputStream getResourceAsStream(java.lang.String name)
Overrides:
getResourceAsStream in class java.lang.ClassLoader

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

Spring Framework