nl.beesting.beangenerator.locators.methodlocators
Class JarClassResolver

java.lang.Object
  extended by java.lang.ClassLoader
      extended by java.security.SecureClassLoader
          extended by nl.beesting.beangenerator.locators.methodlocators.JarClassResolver
All Implemented Interfaces:
ClassResolver

public class JarClassResolver
extends java.security.SecureClassLoader
implements ClassResolver

A simple ClassLoader implementation that loads classes from a set of JAR files. It provides a close() function that forces all currently opened JAR files to be closed (that solves a problem on Windows machines were a opened file cannot be deleted during hot undeploy).
Note: Always prefer to use getResourceAsStream() instead of getResource() as the latter function performs caching (therefore, prevents cached files to be deleted on Windows during hot undeploy).


Constructor Summary
JarClassResolver(java.util.List<java.io.File> files)
           
 
Method Summary
 void close()
           
 java.lang.Class<?> findClass(java.lang.String name)
          Find a class with given name regardless of the package
protected  java.util.List<Entry> getJarFiles()
          For junit testing.
 boolean isCaching()
           
 void setCaching(boolean caching)
           
 
Methods inherited from class java.security.SecureClassLoader
defineClass, defineClass, getPermissions
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findResource, findResources, findSystemClass, getPackage, getPackages, getParent, getResource, getResourceAsStream, 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

JarClassResolver

public JarClassResolver(java.util.List<java.io.File> files)
                 throws java.io.IOException
Parameters:
files - list of jar files (directories are ignored or any files that are not readable by the user.
Throws:
java.io.IOException
Method Detail

close

public void close()

setCaching

public void setCaching(boolean caching)

isCaching

public boolean isCaching()

findClass

public java.lang.Class<?> findClass(java.lang.String name)
Find a class with given name regardless of the package

Specified by:
findClass in interface ClassResolver
Overrides:
findClass in class java.lang.ClassLoader
Parameters:
name - the name of the class
Returns:
the found class or null if none was found

getJarFiles

protected java.util.List<Entry> getJarFiles()
For junit testing.

Returns:
the jar files


Copyright 2008. All Rights Reserved.