org.codehaus.plexus.classworlds.realm

## Class ClassRealm

- java.lang.Object
- - java.lang.ClassLoader
  - - java.security.SecureClassLoader
    - - java.net.URLClassLoader
      - - org.codehaus.plexus.classworlds.realm.ClassRealm

All Implemented Interfaces:
  java.io.Closeable, java.lang.AutoCloseable

Direct Known Subclasses:
  ClassRealmReverseAdapter

    public class ClassRealm
    extends java.net.URLClassLoader

Implementation of `ClassRealm`. The realm is the class loading gateway. The search is proceded as follows:

1. Search the parent class loader (passed via the constructor) if there is one.
2. Search the imports.
3. Search this realm's constituents.
4. Search the parent realm.

Version:
  $Id: ClassRealm.java 8170 2009-05-05 12:41:28Z bentmann $
Author:
  bob mcwhirter, Jason van Zyl

### Constructor Summary

Constructors
Constructor and Description
`ClassRealm(ClassWorld world, java.lang.String id)`
`ClassRealm(ClassWorld world, java.lang.String id, java.lang.ClassLoader foreignClassLoader)`

### Method Summary

Methods
`void` `addURL(java.net.URL url)`
`ClassRealm` `createChildRealm(java.lang.String id)`
`void` `display()`
`boolean` `equals(java.lang.Object o)`
`java.util.Enumeration` `findRealmResources(java.lang.String name)`
`java.util.Enumeration` `findResources(java.lang.String name)`
`java.lang.String` `getId()`
`ClassRealm` `getImportRealm(java.lang.String classname)`
`ClassRealm` `getParentRealm()`
`java.net.URL` `getRealmResource(java.lang.String name)`
`java.io.InputStream` `getRealmResourceAsStream(java.lang.String name)`
`java.net.URL` `getResource(java.lang.String name)`
`java.io.InputStream` `getResourceAsStream(java.lang.String name)`
`Strategy` `getStrategy()`
`ClassWorld` `getWorld()`
`void` `importFrom(java.lang.String realmId, java.lang.String packageName)`
`java.lang.Class` `loadClass(java.lang.String name)`
`protected java.lang.Class` `loadClass(java.lang.String name, boolean resolve)`
`java.lang.Class` `loadClassFromImport(java.lang.String name)`
`java.lang.Class` `loadClassFromParent(java.lang.String name)`
`java.lang.Class` `loadClassFromSelf(java.lang.String name)`
`java.lang.Class` `loadRealmClass(java.lang.String name)`
`java.net.URL` `loadResourceFromImport(java.lang.String name)`
`java.net.URL` `loadResourceFromParent(java.lang.String name)`
`java.net.URL` `loadResourceFromSelf(java.lang.String name)`
`java.util.Enumeration` `loadResourcesFromImport(java.lang.String name)`
`java.util.Enumeration` `loadResourcesFromParent(java.lang.String name)`
`java.util.Enumeration` `loadResourcesFromSelf(java.lang.String name)`
`ClassRealm` `locateSourceRealm(java.lang.String classname)`
`void` `setParentRealm(ClassRealm realm)`
`java.lang.String` `toString()`

### Methods inherited from class java.net.URLClassLoader

`close, definePackage, findClass, findResource, 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, getClassLoadingLock, getPackage, getPackages, getParent, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, registerAsParallelCapable, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### ClassRealm

    public ClassRealm(ClassWorld world,
              java.lang.String id)

#### ClassRealm

    public ClassRealm(ClassWorld world,
              java.lang.String id,
              java.lang.ClassLoader foreignClassLoader)

### Method Detail

#### getId

    public java.lang.String getId()

#### getWorld

    public ClassWorld getWorld()

#### importFrom

    public void importFrom(java.lang.String realmId,
                  java.lang.String packageName)
                    throws NoSuchRealmException

Throws:
  `NoSuchRealmException`

#### locateSourceRealm

    public ClassRealm locateSourceRealm(java.lang.String classname)

#### getStrategy

    public Strategy getStrategy()

#### setParentRealm

    public void setParentRealm(ClassRealm realm)

#### getParentRealm

    public ClassRealm getParentRealm()

#### createChildRealm

    public ClassRealm createChildRealm(java.lang.String id)
                                throws DuplicateRealmException

Throws:
  `DuplicateRealmException`

#### addURL

    public void addURL(java.net.URL url)

Overrides:
  `addURL` in class `java.net.URLClassLoader`

#### loadRealmClass

    public java.lang.Class loadRealmClass(java.lang.String name)
                                   throws java.lang.ClassNotFoundException

Throws:
  `java.lang.ClassNotFoundException`

#### getRealmResource

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

#### getRealmResourceAsStream

    public java.io.InputStream getRealmResourceAsStream(java.lang.String name)

#### findRealmResources

    public java.util.Enumeration findRealmResources(java.lang.String name)
                                             throws java.io.IOException

Throws:
  `java.io.IOException`

#### loadClass

    public java.lang.Class loadClass(java.lang.String name)
                              throws java.lang.ClassNotFoundException

Overrides:
  `loadClass` in class `java.lang.ClassLoader`
Throws:
  `java.lang.ClassNotFoundException`

#### loadClass

    protected java.lang.Class loadClass(java.lang.String name,
                            boolean resolve)
                                 throws java.lang.ClassNotFoundException

Overrides:
  `loadClass` in class `java.lang.ClassLoader`
Throws:
  `java.lang.ClassNotFoundException`

#### getResource

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

Overrides:
  `getResource` in class `java.lang.ClassLoader`

#### getResourceAsStream

    public java.io.InputStream getResourceAsStream(java.lang.String name)

Overrides:
  `getResourceAsStream` in class `java.net.URLClassLoader`

#### findResources

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

Overrides:
  `findResources` in class `java.net.URLClassLoader`
Throws:
  `java.io.IOException`

#### display

    public void display()

#### equals

    public boolean equals(java.lang.Object o)

Overrides:
  `equals` in class `java.lang.Object`

#### toString

    public java.lang.String toString()

Overrides:
  `toString` in class `java.lang.Object`

#### getImportRealm

    public ClassRealm getImportRealm(java.lang.String classname)

#### loadClassFromImport

    public java.lang.Class loadClassFromImport(java.lang.String name)

#### loadClassFromSelf

    public java.lang.Class loadClassFromSelf(java.lang.String name)

#### loadClassFromParent

    public java.lang.Class loadClassFromParent(java.lang.String name)

#### loadResourceFromImport

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

#### loadResourceFromSelf

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

#### loadResourceFromParent

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

#### loadResourcesFromImport

    public java.util.Enumeration loadResourcesFromImport(java.lang.String name)

#### loadResourcesFromSelf

    public java.util.Enumeration loadResourcesFromSelf(java.lang.String name)

#### loadResourcesFromParent

    public java.util.Enumeration loadResourcesFromParent(java.lang.String name)