org.apache.geronimo.kernel.classloader
Class JarFileClassLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by java.security.SecureClassLoader
          extended by java.net.URLClassLoader
              extended by org.apache.geronimo.kernel.config.MultiParentClassLoader
                  extended by org.apache.geronimo.kernel.classloader.JarFileClassLoader

public class JarFileClassLoader
extends MultiParentClassLoader

The JarFileClassLoader that loads classes and resources from a list of JarFiles. This method is simmilar to URLClassLoader except it properly closes JarFiles when the classloader is destroyed so that the file read lock will be released, and the jar file can be modified and deleted.

Note: This implementation currently does not work reliably on windows, since the jar URL handler included with the Sun JavaVM holds a read lock on the JarFile, and this lock is not released when the jar url is dereferenced. To fix this a replacement for the jar url handler must be written.

Since:
2.0
Author:
Dain Sundstrom

Constructor Summary
JarFileClassLoader(Artifact id, URL[] urls)
          Creates a JarFileClassLoader that is a child of the system class loader.
JarFileClassLoader(Artifact id, URL[] urls, ClassLoader parent)
          Creates a JarFileClassLoader that is a child of the specified class loader.
JarFileClassLoader(Artifact id, URL[] urls, ClassLoader[] parents)
          Creates a named class loader as a child of the specified parents.
JarFileClassLoader(Artifact id, URL[] urls, ClassLoader[] parents, boolean inverseClassLoading, Collection hiddenClasses, Collection nonOverridableClasses)
           
JarFileClassLoader(Artifact id, URL[] urls, ClassLoader[] parents, boolean inverseClassLoading, String[] hiddenClasses, String[] nonOverridableClasses)
           
JarFileClassLoader(Artifact id, URL[] urls, ClassLoader parent, boolean inverseClassLoading, String[] hiddenClasses, String[] nonOverridableClasses)
           
JarFileClassLoader(JarFileClassLoader source)
           
 
Method Summary
 void addURL(URL url)
          
protected  void addURLs(URL[] urls)
          Adds an array of urls to the end of this class loader.
static ClassLoader copy(ClassLoader source)
           
 void destroy()
          
protected  Class findClass(String className)
          
protected  String findLibrary(String libraryName)
          
 URL findResource(String resourceName)
          
 URL[] getURLs()
          
protected  Enumeration<URL> internalfindResources(String name)
          
 
Methods inherited from class org.apache.geronimo.kernel.config.MultiParentClassLoader
finalize, findResources, getId, getParents, getResource, isDestroyed, loadClass, loadClassInternal, loadOptimizedClass, loadSafeClass, recursiveFind, toString
 
Methods inherited from class java.net.URLClassLoader
definePackage, getPermissions, newInstance, newInstance
 
Methods inherited from class java.security.SecureClassLoader
defineClass, defineClass
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLoadedClass, findSystemClass, getPackage, getPackages, getParent, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JarFileClassLoader

public JarFileClassLoader(Artifact id,
                          URL[] urls)
Creates a JarFileClassLoader that is a child of the system class loader.

Parameters:
id - the name of this class loader
urls - a list of URLs from which classes and resources should be loaded

JarFileClassLoader

public JarFileClassLoader(Artifact id,
                          URL[] urls,
                          ClassLoader parent)
Creates a JarFileClassLoader that is a child of the specified class loader.

Parameters:
id - the name of this class loader
urls - a list of URLs from which classes and resources should be loaded
parent - the parent of this class loader

JarFileClassLoader

public JarFileClassLoader(Artifact id,
                          URL[] urls,
                          ClassLoader parent,
                          boolean inverseClassLoading,
                          String[] hiddenClasses,
                          String[] nonOverridableClasses)

JarFileClassLoader

public JarFileClassLoader(Artifact id,
                          URL[] urls,
                          ClassLoader[] parents)
Creates a named class loader as a child of the specified parents.

Parameters:
id - the name of this class loader
urls - the urls from which this class loader will classes and resources
parents - the parents of this class loader

JarFileClassLoader

public JarFileClassLoader(Artifact id,
                          URL[] urls,
                          ClassLoader[] parents,
                          boolean inverseClassLoading,
                          Collection hiddenClasses,
                          Collection nonOverridableClasses)

JarFileClassLoader

public JarFileClassLoader(Artifact id,
                          URL[] urls,
                          ClassLoader[] parents,
                          boolean inverseClassLoading,
                          String[] hiddenClasses,
                          String[] nonOverridableClasses)

JarFileClassLoader

public JarFileClassLoader(JarFileClassLoader source)
Method Detail

copy

public static ClassLoader copy(ClassLoader source)

getURLs

public URL[] getURLs()

Overrides:
getURLs in class URLClassLoader

addURL

public void addURL(URL url)

Overrides:
addURL in class MultiParentClassLoader

addURLs

protected void addURLs(URL[] urls)
Adds an array of urls to the end of this class loader.

Parameters:
urls - the URLs to add

destroy

public void destroy()

Overrides:
destroy in class MultiParentClassLoader

findResource

public URL findResource(String resourceName)

Overrides:
findResource in class URLClassLoader

internalfindResources

protected Enumeration<URL> internalfindResources(String name)
                                          throws IOException

Overrides:
internalfindResources in class MultiParentClassLoader
Throws:
IOException

findLibrary

protected String findLibrary(String libraryName)

Overrides:
findLibrary in class ClassLoader

findClass

protected Class findClass(String className)
                   throws ClassNotFoundException

Overrides:
findClass in class URLClassLoader
Throws:
ClassNotFoundException


Copyright © 2003-2008 The Apache Geronimo development community. All Rights Reserved.