org.springframework.context.support
Class ContextTypeMatchClassLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by org.springframework.core.DecoratingClassLoader
          extended by org.springframework.context.support.ContextTypeMatchClassLoader
All Implemented Interfaces:
SmartClassLoader

 class ContextTypeMatchClassLoader
extends DecoratingClassLoader
implements SmartClassLoader

Special variant of an overriding ClassLoader, used for temporary type matching in AbstractApplicationContext. Redefines classes from a cached byte array for every loadClass call in order to pick up recently loaded types in the parent ClassLoader.

Since:
2.5
Author:
Juergen Hoeller
See Also:
AbstractApplicationContext, ConfigurableBeanFactory.setTempClassLoader(java.lang.ClassLoader)

Nested Class Summary
private  class ContextTypeMatchClassLoader.ContextOverridingClassLoader
          ClassLoader to be created for each loaded class.
 
Field Summary
private  java.util.Map<java.lang.String,byte[]> bytesCache
          Cache for byte array per class name
private static java.lang.reflect.Method findLoadedClassMethod
           
 
Constructor Summary
ContextTypeMatchClassLoader(java.lang.ClassLoader parent)
           
 
Method Summary
 boolean isClassReloadable(java.lang.Class clazz)
          Determine whether the given class is reloadable (in this ClassLoader).
 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, getResource, getResourceAsStream, getResources, 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

findLoadedClassMethod

private static java.lang.reflect.Method findLoadedClassMethod

bytesCache

private final java.util.Map<java.lang.String,byte[]> bytesCache
Cache for byte array per class name

Constructor Detail

ContextTypeMatchClassLoader

public ContextTypeMatchClassLoader(java.lang.ClassLoader parent)
Method Detail

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

isClassReloadable

public boolean isClassReloadable(java.lang.Class clazz)
Description copied from interface: SmartClassLoader
Determine whether the given class is reloadable (in this ClassLoader).

Typically used to check whether the result may be cached (for this ClassLoader) or whether it should be reobtained every time.

Specified by:
isClassReloadable in interface SmartClassLoader
Parameters:
clazz - the class to check (usually loaded from this ClassLoader)
Returns:
whether the class should be expected to appear in a reloaded version (with a different Class object) later on