org.apache.commons.beanutils.converters
Class ClassReloader
java.lang.Object
java.lang.ClassLoader
org.apache.commons.beanutils.converters.ClassReloader
public class ClassReloader
- extends ClassLoader
A special classloader useful for testing j2ee-like scenarios.
In some tests we want to be able to emulate "container" frameworks,
where code runs in a hierarchy of classloaders, and certain classes may
be loaded by various classloaders in the hierarchy.
Normally this is done by having certain jars or class-file-directories
in the classpath of some classloaders but not others. This is quite
difficult difficult to integrate with the build process for the unit
tests though; compiling certain classes and having the output go into
places that is not in the default classpath for the unit tests would be
a major pain.
So this class takes a sneaky alternative approach: it can grab any class
already loaded by a parent classloader and reload that class via this
classloader. The effect is exactly as if a class (or jar file) had been
present in the classpath for a container's "shared" classloader and
been present in the component-specific classpath too, without any messing
about with the way unit test code is compiled or executed.
Method Summary |
Class |
reload(Class clazz)
Given a class already in the classpath of a parent classloader,
reload that class via this classloader. |
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, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ClassReloader
public ClassReloader(ClassLoader parent)
reload
public Class reload(Class clazz)
throws FileNotFoundException,
IOException
- Given a class already in the classpath of a parent classloader,
reload that class via this classloader.
- Throws:
FileNotFoundException
IOException
Copyright © 2004-2012 The Kuali Foundation. All Rights Reserved.