|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectclassUtils.pack.util.ClassFinder
public class ClassFinder
This class emulates JDK 1.2 behaviour for finding class, providing direct access to the files / streams.
It works only when classes are loaded from a filesystem.
Field Summary | |
---|---|
ClassPathBean |
classPathBean
The application class path used by this classFileFinder |
Constructor Summary | |
---|---|
ClassFinder(ClassPathBean cpb)
Creates a classfinder which looks (besides system directories) in the given class path |
Method Summary | |
---|---|
void |
addClassPathEntry(java.lang.String entry)
|
void |
clearCorruptFiles()
Empty the set of files considered corrupted since they failed to open when the finder was searching for classes, so that subsequent work will not ignore them. |
java.io.File |
findClassFile(java.lang.String className)
This method emulates 1.2 behaviour for class finding - which means: - it first searches into the $java.home/lib/ and $java.home/lib/*.jar; - then in $java.ext.dirs/*.jar; - eventually in $java.class.path |
java.io.File |
findResourceFile(java.lang.String resource)
Find a resource in the filesystem. |
byte[] |
getBytes(java.lang.String className)
Return the byte array for the class |
byte[] |
getClassBytes(java.lang.String className)
Returns a byte array with the bytecode for the class |
java.lang.String |
getClassPath()
|
java.util.Set |
getCorruptFiles()
Return the set, possibly empty, of files which couldn't be opened when the finder was searching for classes. |
byte[] |
getResourceBytes(java.lang.String resource)
Return a byte array with the bytes for the resource, or null if the resource cannot be found. |
java.lang.String |
getSupportedLoadingScheme()
Returns the supported loading scheme |
boolean |
isClassCacheOn()
Returns the classCacheOn. |
boolean |
isJar(java.io.File f)
Just checks if the file ends with .jar |
static void |
main(java.lang.String[] args)
|
java.io.InputStream |
openClass(java.lang.String className)
Open class data. |
java.io.InputStream |
openResource(java.lang.String resource)
Return the stream associated to a resource in the filesystem, or null if such resource cannot be found. |
java.io.File |
searchJars(java.lang.String className,
java.io.File[] jars)
Searches jar files for a given class path |
void |
setClassCacheOn(boolean classCacheOn)
Sets the classCacheOn. |
void |
setClassPath(java.lang.String classPath)
|
static void |
testClassFinder()
|
void |
testFindClassFile()
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public ClassPathBean classPathBean
Constructor Detail |
---|
public ClassFinder(ClassPathBean cpb)
cpb
- the search class pathMethod Detail |
---|
public java.lang.String getSupportedLoadingScheme()
getSupportedLoadingScheme
in interface ClassFinderInterface
getSupportedLoadingScheme
in interface ResourceFinderInterface
public java.io.InputStream openClass(java.lang.String className) throws java.io.IOException, java.lang.ClassNotFoundException
openClass
in interface ClassFinderInterface
className
- the name of the class to find
java.lang.ClassNotFoundException
- if the class is not found
java.io.IOException
- if an I/O Exception occurspublic void testFindClassFile() throws java.io.IOException, java.lang.ClassNotFoundException
java.io.IOException
java.lang.ClassNotFoundException
public java.io.File findClassFile(java.lang.String className) throws java.io.IOException, java.lang.ClassNotFoundException
findClassFile
in interface ClassFinderInterface
className
- the name of the class to find
java.lang.ClassNotFoundException
- if the class is not found
java.io.IOException
- if an I/O Exception occurspublic byte[] getBytes(java.lang.String className) throws java.io.IOException, java.lang.ClassNotFoundException
java.lang.ClassNotFoundException
- if the class is not found in the JAR
file
java.io.IOException
- if an I/O Exception occurspublic boolean isJar(java.io.File f)
f
- the file to check
public java.io.File searchJars(java.lang.String className, java.io.File[] jars) throws java.io.IOException, java.lang.ClassNotFoundException
className
- the name of the class to findjars
- an array of JAR file objects
java.lang.ClassNotFoundException
- if the class is not found
java.io.IOException
- if an I/O Exception occurspublic byte[] getClassBytes(java.lang.String className) throws java.io.IOException, java.lang.ClassNotFoundException
ClassFinderInterface
getClassBytes
in interface ClassFinderInterface
className
- the name of the class to find
java.io.IOException
- if a problem arises while loading the bytecode
java.lang.ClassNotFoundException
- if the class definition cannot be foundClassFinderInterface.getClassBytes(java.lang.String)
public java.io.InputStream openResource(java.lang.String resource) throws java.io.IOException
openResource
in interface ResourceFinderInterface
resource
- the resource path
java.io.IOException
- if a problem arises accessing the resourcepublic java.io.File findResourceFile(java.lang.String resource) throws java.io.IOException
findClassFile()
and attempting to
locate the resource within directories or JAR files therein.
Resource loading from other than filesystem is not supported.
findResourceFile
in interface ResourceFinderInterface
resource
- the resource path
java.io.IOException
- if a problem arises accessing the resourcepublic byte[] getResourceBytes(java.lang.String resource) throws java.io.IOException
getResourceBytes
in interface ResourceFinderInterface
resource
- the resource name
java.io.IOException
- if a problem arises accessing the resourceResourceFinderInterface.getResourceBytes(String)
public static void testClassFinder()
public void addClassPathEntry(java.lang.String entry)
addClassPathEntry
in interface DynamicClassFinderInterface
addClassPathEntry
in interface DynamicResourceFinderInterfaceInterface
public void setClassPath(java.lang.String classPath)
setClassPath
in interface DynamicClassFinderInterface
setClassPath
in interface DynamicResourceFinderInterfaceInterface
public java.lang.String getClassPath()
getClassPath
in interface DynamicClassFinderInterface
getClassPath
in interface DynamicResourceFinderInterfaceInterface
DynamicClassFinderInterface.getClassPath()
public boolean isClassCacheOn()
public void setClassCacheOn(boolean classCacheOn)
classCacheOn
- The classCacheOn to setpublic java.util.Set getCorruptFiles()
public void clearCorruptFiles()
public static void main(java.lang.String[] args) throws java.io.IOException, java.lang.ClassNotFoundException
java.io.IOException
java.lang.ClassNotFoundException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |