|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.lang.ClassLoader org.springframework.core.DecoratingClassLoader org.springframework.core.OverridingClassLoader
public class OverridingClassLoader
ClassLoader
that does not always delegate to the
parent loader, as normal class loaders do. This enables, for example,
instrumentation to be forced in the overriding ClassLoader, or a
"throwaway" class loading behavior, where selected classes are
temporarily loaded in the overriding ClassLoader, in order to load
an instrumented version of the class in the parent ClassLoader later on.
Field Summary | |
---|---|
static String[] |
DEFAULT_EXCLUDED_PACKAGES
Packages that are excluded by default |
Constructor Summary | |
---|---|
OverridingClassLoader(ClassLoader parent)
Create a new OverridingClassLoader for the given class loader. |
Method Summary | |
---|---|
protected boolean |
isEligibleForOverriding(String className)
Determine whether the specified class is eligible for overriding by this class loader. |
protected byte[] |
loadBytesForClass(String name)
Load the defining bytes for the given class, to be turned into a Class object through a ClassLoader.defineClass(byte[], int, int) call. |
protected Class |
loadClass(String name,
boolean resolve)
|
protected Class |
loadClassForOverriding(String name)
Load the specified class for overriding purposes in this ClassLoader. |
protected InputStream |
openStreamForClass(String name)
Open an InputStream for the specified class. |
protected byte[] |
transformIfNecessary(String name,
byte[] bytes)
Transformation hook to be implemented by subclasses. |
Methods inherited from class org.springframework.core.DecoratingClassLoader |
---|
excludeClass, excludePackage, isExcluded |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String[] DEFAULT_EXCLUDED_PACKAGES
Constructor Detail |
---|
public OverridingClassLoader(ClassLoader parent)
parent
- the ClassLoader to build an overriding ClassLoader forMethod Detail |
---|
protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException
loadClass
in class ClassLoader
ClassNotFoundException
protected boolean isEligibleForOverriding(String className)
className
- the class name to check
DecoratingClassLoader.isExcluded(java.lang.String)
protected Class loadClassForOverriding(String name) throws ClassNotFoundException
The default implementation delegates to ClassLoader.findLoadedClass(java.lang.String)
,
loadBytesForClass(java.lang.String)
and ClassLoader.defineClass(byte[], int, int)
.
name
- the name of the class
null
if no class defined for that name
ClassNotFoundException
- if the class for the given name couldn't be loadedprotected byte[] loadBytesForClass(String name) throws ClassNotFoundException
ClassLoader.defineClass(byte[], int, int)
call.
The default implementation delegates to openStreamForClass(java.lang.String)
and transformIfNecessary(java.lang.String, byte[])
.
name
- the name of the class
null
if no class defined for that name
ClassNotFoundException
- if the class for the given name couldn't be loadedprotected InputStream openStreamForClass(String name)
The default implementation loads a standard class file through
the parent ClassLoader's getResourceAsStream
method.
name
- the name of the class
protected byte[] transformIfNecessary(String name, byte[] bytes)
The default implementation simply returns the given bytes as-is.
name
- the fully-qualified name of the class being transformedbytes
- the raw bytes of the class
null
;
same as the input bytes if the transformation produced no changes)
|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |