|
Web Site | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.lang.ClassLoader
org.codehaus.janino.JavaSourceClassLoader
org.codehaus.janino.CachingJavaSourceClassLoader
public class CachingJavaSourceClassLoader
A JavaSourceClassLoader that uses a
resource storage provided by the application to cache compiled
classes and thus saving unnecessary recompilations.
The application provides access to the resource storeage through a pair of
a ResourceFinder and a
ResourceCreator (see
CachingJavaSourceClassLoader(ClassLoader, ResourceFinder, String, ResourceFinder, ResourceCreator, EnumeratorSet).
See JavaSourceClassLoader.main(String[]) for
an example how to use this class.
Notice: You must NOT rely on that this class stores some particular data in some
particular resources through the given classFileCacheResourceFinder/Creator!
These serve only as a means for the CachingJavaSourceClassLoader to persistently
cache some data between invocations. In other words: If you want to compile .java
files into .class files, then don't use this class but Compiler
instead!
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class org.codehaus.janino.JavaSourceClassLoader |
|---|
JavaSourceClassLoader.ProtectionDomainFactory |
| Constructor Summary | |
|---|---|
CachingJavaSourceClassLoader(java.lang.ClassLoader parentClassLoader,
java.io.File[] optionalSourcePath,
java.lang.String optionalCharacterEncoding,
java.io.File cacheDirectory,
EnumeratorSet debuggingInformation)
See CachingJavaSourceClassLoader(ClassLoader, ResourceFinder, String, ResourceFinder, ResourceCreator, EnumeratorSet). |
|
CachingJavaSourceClassLoader(java.lang.ClassLoader parentClassLoader,
ResourceFinder sourceFinder,
java.lang.String optionalCharacterEncoding,
ResourceFinder classFileCacheResourceFinder,
ResourceCreator classFileCacheResourceCreator,
EnumeratorSet debuggingInformation)
Notice that this class is thread-safe if and only if the classFileCacheResourceCreator stores its data atomically,
i.e. |
|
| Method Summary | |
|---|---|
protected java.util.Map |
generateBytecodes(java.lang.String className)
Override JavaSourceClassLoader.generateBytecodes(String) to implement
class file caching. |
| Methods inherited from class org.codehaus.janino.JavaSourceClassLoader |
|---|
defineBytecode, defineBytecodes, findClass, main, setCompileErrorHandler, setProtectionDomainFactory, setWarningHandler |
| 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 |
|---|
public CachingJavaSourceClassLoader(java.lang.ClassLoader parentClassLoader,
java.io.File[] optionalSourcePath,
java.lang.String optionalCharacterEncoding,
java.io.File cacheDirectory,
EnumeratorSet debuggingInformation)
CachingJavaSourceClassLoader(ClassLoader, ResourceFinder, String, ResourceFinder, ResourceCreator, EnumeratorSet).
optionalSourcePath - Directories to scan for source filescacheDirectory - Directory to use for caching generated class files (see class description)
public CachingJavaSourceClassLoader(java.lang.ClassLoader parentClassLoader,
ResourceFinder sourceFinder,
java.lang.String optionalCharacterEncoding,
ResourceFinder classFileCacheResourceFinder,
ResourceCreator classFileCacheResourceCreator,
EnumeratorSet debuggingInformation)
classFileCacheResourceCreator stores its data atomically,
i.e. the classFileCacheResourceFinder sees the resource
written by the classFileCacheResourceCreator only after
the OutputStream is closed.
In order to make the caching scheme work, both the
classFileCacheResourceFinder and the
sourceFinder must support the Resource.lastModified()
method, so that the modification time of the source and the class files
can be compared.
parentClassLoader - Attempt to load classes through this one before looking for source filessourceFinder - Finds JavaTM source for class pkg.Cls in resource pkg/Cls.javaoptionalCharacterEncoding - Encoding of JavaTM source or null for platform default encodingclassFileCacheResourceFinder - Finds precompiled class pkg.Cls in resource pkg/Cls.class (see class description)classFileCacheResourceCreator - Stores compiled class pkg.Cls in resource pkg/Cls.class (see class description)debuggingInformation - What debugging information to include into the generated class files| Method Detail |
|---|
protected java.util.Map generateBytecodes(java.lang.String className)
throws java.lang.ClassNotFoundException
JavaSourceClassLoader.generateBytecodes(String) to implement
class file caching.
generateBytecodes in class JavaSourceClassLoadernull if no source code could be found
java.lang.ClassNotFoundException - on compilation problems or class file cache I/O problems
|
Web Site | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||