Milyn-Smooks Version 0.4

org.milyn.cdr
Class CDRClassLoader

java.lang.Object
  extended byjava.lang.ClassLoader
      extended byorg.milyn.cdr.CDRClassLoader

public class CDRClassLoader
extends java.lang.ClassLoader

Content Delivery Resource (CDR) classloader.

Classloading is delegated to the parent classloader. If the class is not loaded by the parent classloader this classloader attempts to load the class from the loaded CDRArchive files. If this too fails a ClassNotFoundException results.

Author:
tfennelly

Constructor Summary
CDRClassLoader(java.lang.ClassLoader parent, CDRStore cdrarStore)
          Public constructor.
 
Method Summary
 java.lang.Class findClass(java.lang.String name)
          Get the specified class from the CDRStore.
protected  java.net.URL findResource(java.lang.String name)
          Overriden to remove support for this method.
protected  java.util.Enumeration findResources(java.lang.String name)
          Overriden to remove support for this method.
 java.net.URL getResource(java.lang.String name)
          Overriden to remove support for this method.
 java.io.InputStream getResourceAsStream(java.lang.String name)
          Overriding getResourceAsStream to provide access to the CdrarLoaded resources through this Classloader.
 java.lang.Class loadClass(CDRDef unitDef)
          Load a runtime class from an archive CDRDef instance.
static java.lang.String toClassName(java.lang.String fileName)
          Convert the Java-class-file-name to the equivalent Java-class-name (dot delimited package name).
static java.lang.String toFileName(java.lang.String className)
          Convert the Java-class-name (dot delimited package name)to the equivalent Java-class-file-name .
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getPackage, getPackages, getParent, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CDRClassLoader

public CDRClassLoader(java.lang.ClassLoader parent,
                      CDRStore cdrarStore)
Public constructor.

Parameters:
parent - The parent classloader in the classloader hierarchy.
Method Detail

loadClass

public java.lang.Class loadClass(CDRDef unitDef)
                          throws java.lang.ClassNotFoundException
Load a runtime class from an archive CDRDef instance.

Parameters:
unitDef - The CDRDef to be used for loading the runtime class.
Returns:
Runtime Class instance.
Throws:
java.lang.ClassNotFoundException - See java.lang.ClassLoader.loadClass

findClass

public java.lang.Class findClass(java.lang.String name)
                          throws java.lang.ClassNotFoundException
Get the specified class from the CDRStore.

Parameters:
name - The name of the class.
Throws:
java.lang.ClassNotFoundException - Class cannot be loaded from this point in the classloader hierarchy.

toClassName

public static java.lang.String toClassName(java.lang.String fileName)
Convert the Java-class-file-name to the equivalent Java-class-name (dot delimited package name).

EG:
a/b/c/X.class converts to a.b.c.X
a/b/c/X converts to a.b.c.X
a.b.c.X converts to a.b.c.X
a.b.c.X.class converts to a.b.c.X

Parameters:
fileName - The file name String to be translated.
Returns:
Java Class runtime name representation of the supplied file name String.

toFileName

public static java.lang.String toFileName(java.lang.String className)
Convert the Java-class-name (dot delimited package name)to the equivalent Java-class-file-name .

EG:
a.b.c.X converts to a/b/c/X.class
a.b.c.X.class converts to a/b/c/X.class
a/b/c/X.class converts to a/b/c/X.class
a/b/c/X converts to a/b/c/X.class

Parameters:
className - The class name string to be translated.
Returns:
The file name representaion of the supplied runtime class String.

getResourceAsStream

public java.io.InputStream getResourceAsStream(java.lang.String name)
Overriding getResourceAsStream to provide access to the CdrarLoaded resources through this Classloader.

Calls the parent class loader and if the stream is not available from the parent it tries to load the org.milyn.resource from the CDRStore.

Parameters:
name - The name of the required org.milyn.resource.
Returns:
An input stream for the specified org.milyn.resource, or null if the org.milyn.resource cold not be located.
See Also:
ClassLoader.getResourceAsStream(java.lang.String)

findResource

protected java.net.URL findResource(java.lang.String name)
Overriden to remove support for this method. Proper URL support will need to be added at some stage.

See Also:
ClassLoader.findResource(java.lang.String)

findResources

protected java.util.Enumeration findResources(java.lang.String name)
                                       throws java.io.IOException
Overriden to remove support for this method. Proper URL support will nee to be added at some stage.

Throws:
java.io.IOException
See Also:
ClassLoader.findResources(java.lang.String)

getResource

public java.net.URL getResource(java.lang.String name)
Overriden to remove support for this method. Proper URL support will nee to be added at some stage.

See Also:
ClassLoader.getResource(java.lang.String)

Milyn-Smooks Version 0.4