|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.lang.ClassLoader | +--com.javageeks.classloader.StrategyClassLoader
StrategyClassLoader uses the Strategy pattern to implement more reusable (and chainable) ClassLoader-possibilities.
Note that the StrategyClassLoader itself in turn implements the ClassLoaderStrategy interface; this means that instances of the StrategyClassLoader could, in turn, be used within a StrategyClassLoader. The need for this isn't obvious until one considers the CompositeClassLoader, which uses a collection of ClassLoaderStrategy-implementing classes to do its work. Without implementing this interface, StrategyClassLoader would be unable to participate in that system.
Constructor Summary | |
StrategyClassLoader(ClassLoaderStrategy strategy)
Construct using the given Strategy instance and use the ClassLoader that loaded this class as the parent. |
|
StrategyClassLoader(ClassLoaderStrategy strategy,
java.lang.ClassLoader parent)
Construct using the given Strategy instance and use the ClassLoader passed in as the parent. |
Method Summary | |
protected java.lang.Class |
findClass(java.lang.String name)
Find the class bytecode; defers to the Strategy's findClassBytes method. |
byte[] |
findClassBytes(java.lang.String className)
Return byte array (which will be turned into a Class instance via ClassLoader.defineClass) for class |
java.lang.String |
findLibraryPath(java.lang.String libraryName)
Return full path to native library given by the name libraryName. |
java.util.Enumeration |
findResourcesEnum(java.lang.String resourceName)
Return Enumeration of resources corresponding to resourceName. |
java.net.URL |
findResourceURL(java.lang.String resourceName)
Return URL for resource given by resourceName |
static void |
main(java.lang.String[] args)
For JDK1.1 use, uncomment the following method |
Methods inherited from class java.lang.ClassLoader |
defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findResource, findResources, findSystemClass, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, loadClass, resolveClass, setSigners |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public StrategyClassLoader(ClassLoaderStrategy strategy)
public StrategyClassLoader(ClassLoaderStrategy strategy, java.lang.ClassLoader parent)
Method Detail |
public byte[] findClassBytes(java.lang.String className)
findClassBytes
in interface ClassLoaderStrategy
public java.net.URL findResourceURL(java.lang.String resourceName)
findResourceURL
in interface ClassLoaderStrategy
public java.util.Enumeration findResourcesEnum(java.lang.String resourceName)
findResourcesEnum
in interface ClassLoaderStrategy
public java.lang.String findLibraryPath(java.lang.String libraryName)
findLibraryPath
in interface ClassLoaderStrategy
protected java.lang.Class findClass(java.lang.String name) throws java.lang.ClassNotFoundException
findClassBytes
method.findClass
in class java.lang.ClassLoader
public static void main(java.lang.String[] args) throws java.lang.Exception
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |