Class ClassRealm
java.lang.Object
java.lang.ClassLoader
java.security.SecureClassLoader
java.net.URLClassLoader
org.codehaus.plexus.classworlds.realm.ClassRealm
- All Implemented Interfaces:
Closeable
,AutoCloseable
- Direct Known Subclasses:
ClassRealmReverseAdapter
,FilteredClassRealm
The class loading gateway. Each class realm has access to a base class loader, imports form zero or more other class
loaders, an optional parent class loader and of course its own class path. When queried for a class/resource, a class
realm will always query its base class loader first before it delegates to a pluggable strategy. The strategy in turn
controls the order in which imported class loaders, the parent class loader and the realm itself are searched. The
base class loader is assumed to be capable of loading of the bootstrap classes.
- Author:
- bob mcwhirter, Jason van Zyl
-
Constructor Summary
ConstructorDescriptionClassRealm
(ClassWorld world, String id, ClassLoader baseClassLoader) Creates a new class realm. -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
display()
void
display
(PrintStream out) protected Class
<?> protected Class
<?> protected Class
<?> findClassInternal
(String name) findResource
(String name) findResources
(String name) protected Object
getClassLoadingLock
(String name) getId()
getImportClassLoader
(String name) getResource
(String name) getResources
(String name) getWorld()
void
importFrom
(ClassLoader classLoader, String packageName) void
importFrom
(String realmId, String packageName) void
importFromParent
(String packageName) Class
<?> protected Class
<?> Class
<?> loadClassFromImport
(String name) Class
<?> loadClassFromParent
(String name) Class
<?> loadClassFromSelf
(String name) loadResourceFromImport
(String name) loadResourceFromParent
(String name) loadResourceFromSelf
(String name) loadResourcesFromSelf
(String name) void
setParentClassLoader
(ClassLoader parentClassLoader) void
setParentRealm
(ClassRealm realm) toString()
Methods inherited from class java.net.URLClassLoader
close, definePackage, getPermissions, getResourceAsStream, getURLs, newInstance, newInstance
Methods inherited from class java.security.SecureClassLoader
defineClass, defineClass
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getPackage, getPackages, getParent, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, registerAsParallelCapable, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
-
Constructor Details
-
ClassRealm
Creates a new class realm.- Parameters:
world
- The class world this realm belongs to, must not benull
.id
- The identifier for this realm, must not benull
.baseClassLoader
- The base class loader for this realm, may benull
to use the bootstrap class loader.
-
-
Method Details
-
getId
-
getWorld
-
importFromParent
-
importFrom
- Throws:
NoSuchRealmException
-
importFrom
-
getImportClassLoader
-
getImportRealms
-
getStrategy
-
setParentClassLoader
-
getParentClassLoader
-
setParentRealm
-
getParentRealm
-
createChildRealm
- Throws:
DuplicateRealmException
-
addURL
- Overrides:
addURL
in classURLClassLoader
-
loadClass
- Overrides:
loadClass
in classClassLoader
- Throws:
ClassNotFoundException
-
loadClass
- Overrides:
loadClass
in classClassLoader
- Throws:
ClassNotFoundException
-
findClass
-
findClass
- Overrides:
findClass
in classURLClassLoader
- Throws:
ClassNotFoundException
-
findClassInternal
- Throws:
ClassNotFoundException
-
getResource
- Overrides:
getResource
in classClassLoader
-
findResource
- Overrides:
findResource
in classURLClassLoader
-
getResources
- Overrides:
getResources
in classClassLoader
- Throws:
IOException
-
findResources
- Overrides:
findResources
in classURLClassLoader
- Throws:
IOException
-
display
public void display() -
display
-
toString
-
loadClassFromImport
-
loadClassFromSelf
-
getClassLoadingLock
- Overrides:
getClassLoadingLock
in classClassLoader
-
loadClassFromParent
-
loadResourceFromImport
-
loadResourceFromSelf
-
loadResourceFromParent
-
loadResourcesFromImport
-
loadResourcesFromSelf
-
loadResourcesFromParent
-