org.codehaus.plexus.classworlds.realm
Class ClassRealm

java.lang.Object
  extended by java.lang.ClassLoader
      extended by java.security.SecureClassLoader
          extended by java.net.URLClassLoader
              extended by org.codehaus.plexus.classworlds.realm.ClassRealm
Direct Known Subclasses:
ClassRealmReverseAdapter

public class ClassRealm
extends URLClassLoader

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.

Version:
$Id$
Author:
bob mcwhirter, Jason van Zyl

Constructor Summary
ClassRealm(ClassWorld world, String id, ClassLoader baseClassLoader)
          Creates a new class realm.
 
Method Summary
 void addURL(URL url)
           
 ClassRealm createChildRealm(String id)
           
 void display()
           
 void display(PrintStream out)
           
protected  Class findClass(String name)
           
 URL findResource(String name)
           
 Enumeration findResources(String name)
           
 String getId()
           
 ClassLoader getImportClassLoader(String name)
           
 Collection getImportRealms()
           
 ClassLoader getParentClassLoader()
           
 ClassRealm getParentRealm()
           
 Strategy getStrategy()
           
 ClassWorld getWorld()
           
 void importFrom(ClassLoader classLoader, String packageName)
           
 void importFrom(String realmId, String packageName)
           
 void importFromParent(String packageName)
           
 Class loadClass(String name)
           
protected  Class loadClass(String name, boolean resolve)
           
 Class loadClassFromImport(String name)
           
 Class loadClassFromParent(String name)
           
 Class loadClassFromSelf(String name)
           
 URL loadResourceFromImport(String name)
           
 URL loadResourceFromParent(String name)
           
 URL loadResourceFromSelf(String name)
           
 Enumeration loadResourcesFromImport(String name)
           
 Enumeration loadResourcesFromParent(String name)
           
 Enumeration loadResourcesFromSelf(String name)
           
 void setParentClassLoader(ClassLoader parentClassLoader)
           
 void setParentRealm(ClassRealm realm)
           
 String toString()
           
 
Methods inherited from class java.net.URLClassLoader
definePackage, getPermissions, 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, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ClassRealm

public ClassRealm(ClassWorld world,
                  String id,
                  ClassLoader baseClassLoader)
Creates a new class realm.

Parameters:
world - The class world this realm belongs to, must not be null.
id - The identifier for this realm, must not be null.
baseClassLoader - The base class loader for this realm, may be null to use the bootstrap class loader.
Method Detail

getId

public String getId()

getWorld

public ClassWorld getWorld()

importFromParent

public void importFromParent(String packageName)

importFrom

public void importFrom(String realmId,
                       String packageName)
                throws NoSuchRealmException
Throws:
NoSuchRealmException

importFrom

public void importFrom(ClassLoader classLoader,
                       String packageName)

getImportClassLoader

public ClassLoader getImportClassLoader(String name)

getImportRealms

public Collection getImportRealms()

getStrategy

public Strategy getStrategy()

setParentClassLoader

public void setParentClassLoader(ClassLoader parentClassLoader)

getParentClassLoader

public ClassLoader getParentClassLoader()

setParentRealm

public void setParentRealm(ClassRealm realm)

getParentRealm

public ClassRealm getParentRealm()

createChildRealm

public ClassRealm createChildRealm(String id)
                            throws DuplicateRealmException
Throws:
DuplicateRealmException

addURL

public void addURL(URL url)
Overrides:
addURL in class URLClassLoader

loadClass

public Class loadClass(String name)
                throws ClassNotFoundException
Overrides:
loadClass in class ClassLoader
Throws:
ClassNotFoundException

loadClass

protected Class loadClass(String name,
                          boolean resolve)
                   throws ClassNotFoundException
Overrides:
loadClass in class ClassLoader
Throws:
ClassNotFoundException

findClass

protected Class findClass(String name)
                   throws ClassNotFoundException
Overrides:
findClass in class URLClassLoader
Throws:
ClassNotFoundException

findResource

public URL findResource(String name)
Overrides:
findResource in class URLClassLoader

findResources

public Enumeration findResources(String name)
                          throws IOException
Overrides:
findResources in class URLClassLoader
Throws:
IOException

display

public void display()

display

public void display(PrintStream out)

toString

public String toString()
Overrides:
toString in class Object

loadClassFromImport

public Class loadClassFromImport(String name)

loadClassFromSelf

public Class loadClassFromSelf(String name)

loadClassFromParent

public Class loadClassFromParent(String name)

loadResourceFromImport

public URL loadResourceFromImport(String name)

loadResourceFromSelf

public URL loadResourceFromSelf(String name)

loadResourceFromParent

public URL loadResourceFromParent(String name)

loadResourcesFromImport

public Enumeration loadResourcesFromImport(String name)

loadResourcesFromSelf

public Enumeration loadResourcesFromSelf(String name)

loadResourcesFromParent

public Enumeration loadResourcesFromParent(String name)


Copyright © 2002-2011 Codehaus. All Rights Reserved.