org.apache.geronimo.kernel.classloader
Class JarFileClassLoader

java.lang.Object
  extended byjava.lang.ClassLoader
      extended byjava.security.SecureClassLoader
          extended byjava.net.URLClassLoader
              extended byorg.apache.geronimo.kernel.config.MultiParentClassLoader
                  extended byorg.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
Version:
$Id: JarFileClassLoader.java 409817 2006-05-27 07:56:38Z jsisson $
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)
           
 
Method Summary
 void addURL(URL url)
          
protected  void addURLs(URL[] urls)
          Adds an array of urls to the end of this class loader.
 void destroy()
          
protected  Class findClass(String className)
          
protected  String findLibrary(String libraryName)
          
 URL findResource(String resourceName)
          
 Enumeration findResources(String resourceName)
          
 URL[] getURLs()
          
 
Methods inherited from class org.apache.geronimo.kernel.config.MultiParentClassLoader
getId, getParents, getResource, isDestroyed, loadClass, toString
 
Methods inherited from class java.net.URLClassLoader
definePackage, getPermissions, newInstance, newInstance
 
Methods inherited from class java.security.SecureClassLoader
defineClass
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, 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, finalize, 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)
Method Detail

getURLs

public URL[] getURLs()


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)


findResources

public Enumeration findResources(String resourceName)
                          throws IOException

Overrides:
findResources in class MultiParentClassLoader
Throws:
IOException

findLibrary

protected String findLibrary(String libraryName)


findClass

protected Class findClass(String className)
                   throws ClassNotFoundException

Throws:
ClassNotFoundException


Copyright © 2003-2007 Apache Software Foundation. All Rights Reserved.