Class RealmClassLoader
java.lang.Object
java.lang.ClassLoader
java.security.SecureClassLoader
java.net.URLClassLoader
org.codehaus.classworlds.RealmClassLoader
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
UberJarRealmClassLoader
Classloader for
ClassRealms.- Version:
- $Id: RealmClassLoader.java 126 2006-01-12 04:17:51Z $
- Author:
- bob mcwhirter
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConstruct.RealmClassLoader(DefaultClassRealm realm, ClassLoader classLoader) Construct. -
Method Summary
Modifier and TypeMethodDescription(package private) voidaddConstituent(URL constituent) Add a constituent to this realm for locating classes.findResource(String name) Find a resource within this ClassLoader only (don't delegate to the parent).findResources(String name) findResourcesDirect(String name) Find resources from this ClassLoader, and don't search the realm.byte[]Helper method for addConstituent that reads in a DataInputStream and returns it as a byte[] It attempts to use in.available - the size of the file - else defaults to 2048(package private) DefaultClassRealmgetRealm()Retrieve the realm.getResource(String name) getResourceDirect(String name) Get a resource from this ClassLoader, and don't search the realm.URL[]getURLs()Retrieve theURLs used by thisClassLoader.protected ClassLoad a class.(package private) ClassloadClassDirect(String name) Load a class directly from this classloader without defering through any otherClassRealm.Methods inherited from class java.net.URLClassLoader
addURL, close, definePackage, findClass, getPermissions, getResourceAsStream, newInstance, newInstanceMethods inherited from class java.security.SecureClassLoader
defineClass, defineClassMethods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getName, getPackage, getPackages, getParent, getPlatformClassLoader, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
-
Field Details
-
realm
The realm.
-
-
Constructor Details
-
RealmClassLoader
RealmClassLoader(DefaultClassRealm realm) Construct.- Parameters:
realm- The realm for which this loads.
-
RealmClassLoader
RealmClassLoader(DefaultClassRealm realm, ClassLoader classLoader) Construct.- Parameters:
realm- The realm for which this loads.classLoader- The parent ClassLoader.
-
-
Method Details
-
getRealm
-
addConstituent
Add a constituent to this realm for locating classes. If the url definition ends in .class its a BytesURLStreamHandler so use defineClass insead. addURL is still called for byte[] even though it has no affect and we use defineClass instead, this is for consistentency and to allow access to the class with getURLs()- Parameters:
constituent- URL to contituent jar or directory.
-
getBytesToEndOfStream
Helper method for addConstituent that reads in a DataInputStream and returns it as a byte[] It attempts to use in.available - the size of the file - else defaults to 2048- Throws:
IOException
-
loadClassDirect
Load a class directly from this classloader without defering through any otherClassRealm.- Parameters:
name- The name of the class to load.- Returns:
- The loaded class.
- Throws:
ClassNotFoundException- If the class could not be found.
-
loadClass
Load a class.- Overrides:
loadClassin classClassLoader- Parameters:
name- The name of the class to load.resolve- Iftruethen resolve the class.- Returns:
- The loaded class.
- Throws:
ClassNotFoundException- If the class cannot be found.
-
getURLs
Retrieve theURLs used by thisClassLoader.- Overrides:
getURLsin classURLClassLoader- Returns:
- The urls.
-
findResource
Find a resource within this ClassLoader only (don't delegate to the parent).- Overrides:
findResourcein classURLClassLoader- Returns:
- The resource.
-
getResource
- Overrides:
getResourcein classClassLoader
-
getResourceDirect
-
findResources
- Overrides:
findResourcesin classURLClassLoader- Throws:
IOException
-
findResourcesDirect
Find resources from this ClassLoader, and don't search the realm. Otherwise we'd recurse indefinitely.- Returns:
- The resource.
- Throws:
IOException
-