org.sapia.clazzy
Class JarClassLoader

java.lang.Object
  |
  +--java.lang.ClassLoader
        |
        +--java.security.SecureClassLoader
              |
              +--org.sapia.clazzy.BaseClassLoader
                    |
                    +--org.sapia.clazzy.JarClassLoader
All Implemented Interfaces:
Consts

public class JarClassLoader
extends BaseClassLoader
implements Consts

This class overrides the BaseClassLoader class and search classes in a given jar file. It is provided as an alternative to the implementation that comes with the JDK, which locks the underlying jar files (in fact keeping the files open).

Under some OS (WIN!"$D%?), this prevents the jar files from being deleted (for example, in the case of hot-deployments).

An instance of this class works around this limitation by internally using a JarLoader instance, which opens the jar file at instantiation time, and allows closing the said jar file when it is not needed anymore.

Client applications should call close() on an instance of this class to ensure that the underlying JarLoader is disposed of cleanly (i.e.: that the jar file it holds is closed).

Author:
Yanick Duchesne
See Also:
JarLoader, ClazzyURLConnection,
Copyright:
Copyright © 2002-2004 Sapia Open Source Software . All Rights Reserved.
License:
Read the license.txt file of the jar or visit the license page at the Sapia OSS web site

Field Summary
 
Fields inherited from interface org.sapia.clazzy.Consts
PACKAGE_IMPL_TITLE, PACKAGE_IMPL_VENDOR, PACKAGE_IMPL_VERSION, PACKAGE_SPEC_TITLE, PACKAGE_SPEC_VENDOR, PACKAGE_SPEC_VERSION
 
Constructor Summary
JarClassLoader(ClassLoader parent, File jar)
           
JarClassLoader(File jar)
           
 
Method Summary
 void close()
           
protected  Class findClass(String name)
           
protected  URL findResource(String name)
           
 InputStream findResourceAsStream(String name)
           
 File getFile()
           
 
Methods inherited from class org.sapia.clazzy.BaseClassLoader
loadClass, setParentFirst
 
Methods inherited from class java.security.SecureClassLoader
defineClass, getPermissions
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findResources, findSystemClass, getPackage, getPackages, getParent, getResource, 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, toString, wait, wait, wait
 

Constructor Detail

JarClassLoader

public JarClassLoader(File jar)

JarClassLoader

public JarClassLoader(ClassLoader parent,
                      File jar)
Method Detail

getFile

public File getFile()
Returns:
the File corresponding to the archive in which this instance looks up.

findClass

protected Class findClass(String name)
                   throws ClassNotFoundException
Overrides:
findClass in class ClassLoader
ClassNotFoundException
See Also:
ClassLoader.findClass(java.lang.String)

findResourceAsStream

public InputStream findResourceAsStream(String name)
Parameters:
name - the name of the resource whose stream should be returned.
Returns:
an InputStream.

findResource

protected URL findResource(String name)
Overrides:
findResource in class ClassLoader
See Also:
ClassLoader.findResource(java.lang.String)

close

public void close()
See Also:
JarLoader.close()


Copyright © 2002 Sapia Open Community, Inc. All Rights Reserved.