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.1.1.1 2003/07/29 04:38:00 bob Exp $
Author:
bob mcwhirter, Jason van Zyl

Method Summary
 void addConstituent(java.net.URL constituent)
          Add a constituent to this realm for locating classes.
 org.codehaus.classworlds.ClassRealm createChildRealm(java.lang.String id)
          Create a child realm.
 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)
           
 org.codehaus.classworlds.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 setParent(org.codehaus.classworlds.ClassRealm classRealm)
          Set the parent ClassRealm.
 

Method Detail

getId

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

Returns:
The id.

getWorld

public org.codehaus.classworlds.ClassWorld getWorld()
Retrieve the ClassWorld of which this is a member.

Returns:
The class-world.

importFrom

public 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.

getClassLoader

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

Returns:
The classloader.

loadClass

public 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.

getResource

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

addConstituent

public 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.

setParent

public void setParent(org.codehaus.classworlds.ClassRealm classRealm)
Set the parent ClassRealm.

Parameters:
classRealm - The parent ClassRealm.

createChildRealm

public org.codehaus.classworlds.ClassRealm createChildRealm(java.lang.String id)
Create a child realm.

Parameters:
id - The name of child realm.


Copyright © 2002-2003 The Codehaus. All Rights Reserved.