org.codehaus.classworlds
Interface ClassRealm


public interface ClassRealm

Autonomous sub-portion of a ClassWorld.

This class most closed maps to the ClassLoader role from Java and in facts can provide a ClassLoader view of itself using getClassLoader().

Version:
$Id: ClassRealm.java,v 1.3 2004/04/03 22:21:36 dandiep Exp $
Author:
bob mcwhirter, Jason van Zyl

Method Summary
 void addConstituent(java.lang.String name, byte[] b)
          Adds a byte[] class definition as a constituent for locating classes.
 void addConstituent(java.net.URL constituent)
          Add a constituent to this realm for locating classes.
 ClassRealm createChildRealm(java.lang.String id)
          Create a child realm.
 java.util.Enumeration findResources(java.lang.String name)
           
 java.lang.ClassLoader getClassLoader()
          Retrieve the ClassLoader that models this ClassRealm.
 java.lang.String getId()
          Retrieve the id.
 java.net.URL getResource(java.lang.String name)
           
 java.util.Enumeration getResources(java.lang.String name)
           
 ClassWorld getWorld()
          Retrieve the ClassWorld of which this is a member.
 void importFrom(java.lang.String realmId, java.lang.String pkgName)
          Import packages from another ClassRealm.
 java.lang.Class loadClass(java.lang.String name)
          Load a class.
 void reload()
          Reload all the constituents in the realm.
 void reload(boolean reloadParent)
          Reload all the constituents in the realm.
 void setParent(ClassRealm classRealm)
          Set the parent ClassRealm.
 

Method Detail

addConstituent

void addConstituent(java.lang.String name,
                    byte[] b)
                    throws java.lang.ClassNotFoundException
Adds a byte[] class definition as a constituent for locating classes.

Parameters:
name - class name
b - the class definition as a byte[]
off - offset
len - length
Throws:
java.lang.ClassNotFoundException

addConstituent

void addConstituent(java.net.URL constituent)
Add a constituent to this realm for locating classes.

A constituent is a URL that points to either a JAR format file containing classes and/or resources, or a directory that should be used for searching. If the constituent is a directory, then the URL must end with a slash (/). Otherwise the constituent will be treated as a JAR file.

Parameters:
constituent - URL to contituent jar or directory.

createChildRealm

ClassRealm createChildRealm(java.lang.String id)
Create a child realm.

Parameters:
id - The name of child realm.

findResources

java.util.Enumeration findResources(java.lang.String name)
                                    throws java.io.IOException
Throws:
java.io.IOException

getClassLoader

java.lang.ClassLoader getClassLoader()
Retrieve the ClassLoader that models this ClassRealm.

Returns:
The classloader.

getId

java.lang.String getId()
Retrieve the id.

Returns:
The id.

getResource

java.net.URL getResource(java.lang.String name)

getResources

java.util.Enumeration getResources(java.lang.String name)
                                   throws java.io.IOException
Throws:
java.io.IOException

getWorld

ClassWorld getWorld()
Retrieve the ClassWorld of which this is a member.

Returns:
The class-world.

importFrom

void importFrom(java.lang.String realmId,
                java.lang.String pkgName)
                throws NoSuchRealmException
Import packages from another ClassRealm.

Specific packages can be imported from another realm instead of attempting to load them locally from this one. When importing a package a realm defers completely to the foreign realm to satisfy the package dependencies.

Parameters:
realmId - The realm id from which to import.
pkgName - The package name to import.
Throws:
NoSuchRealmException - If the id of the realm from which to import does not correspond to a foreign realm within this realm's world.

loadClass

java.lang.Class loadClass(java.lang.String name)
                          throws java.lang.ClassNotFoundException
Load a class.

Parameters:
name - The name of the class to load.
Returns:
The loaded class.
Throws:
java.lang.ClassNotFoundException - If the class cannot be found.

reload

void reload()
Reload all the constituents in the realm.


reload

void reload(boolean reloadParent)
Reload all the constituents in the realm.

Parameters:
reloadParent - Whether or not to reload the parent realm.

setParent

void setParent(ClassRealm classRealm)
Set the parent ClassRealm.

Parameters:
classRealm - The parent ClassRealm.


Copyright © 2001-2004 Apache Software Foundation. Documenation generated May 8 2005.