railo.loader.classloader
Class RailoClassLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by railo.loader.classloader.RailoClassLoader

public final class RailoClassLoader
extends ClassLoader

This class implements a simple class loader that can be used to load at runtime classes contained in a JAR file.


Constructor Summary
RailoClassLoader(File jarFile, ClassLoader parent)
          Creates a new JarClassLoader that will allow the loading of classes stored in a jar file.
RailoClassLoader(InputStream jar, ClassLoader parent, boolean secured)
           
 
Method Summary
 Class findClass(String className)
          Looks among the contents of the jar file (cached in memory) and tries to find and define a class, given its name.
 InputStream getResourceAsStream(String name)
           
 Class loadClass(String name)
          Loads the class with the specified name.
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, getParent, getResource, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RailoClassLoader

public RailoClassLoader(File jarFile,
                        ClassLoader parent)
                 throws IOException
Creates a new JarClassLoader that will allow the loading of classes stored in a jar file.

Parameters:
jarFile - the name of the jar file
parent - parent class loader
Throws:
IOException
IOException - an error happened while reading the contents of the jar file

RailoClassLoader

public RailoClassLoader(InputStream jar,
                        ClassLoader parent,
                        boolean secured)
                 throws IOException
Throws:
IOException
Method Detail

findClass

public Class findClass(String className)
                throws ClassNotFoundException
Looks among the contents of the jar file (cached in memory) and tries to find and define a class, given its name.

Overrides:
findClass in class ClassLoader
Parameters:
className - the name of the class
Returns:
a Class object representing our class
Throws:
ClassNotFoundException - the jar file did not contain a class named className

loadClass

public Class loadClass(String name)
                throws ClassNotFoundException
Loads the class with the specified name. This method searches for classes in the same manner as the "loadClass(String, boolean)" method. It is called by the Java virtual machine to resolve class references. Calling this method is equivalent to calling loadClass(name, false).

Overrides:
loadClass in class ClassLoader
Parameters:
name - the name of the class
Returns:
the resulting Class object
Throws:
ClassNotFoundException - if the class was not found

getResourceAsStream

public InputStream getResourceAsStream(String name)
Overrides:
getResourceAsStream in class ClassLoader
See Also:
ClassLoader.getResourceAsStream(java.lang.String)


Copyright © 2012 Railo