jodd.util
Class RuntimeJavaSourceLoader

java.lang.Object
  extended by jodd.util.RuntimeJavaSourceLoader

public class RuntimeJavaSourceLoader
extends java.lang.Object

Manager for JavaSourceClassLoader: loading java sources transparently into the VM. When class is requested, it will be loaded using new instance of JavaSourceClassLoader. Non-aggressive mode is used, which means that only the request class is loaded with this classloader, all depended class are loaded with parent (default) classloader).

By default, RuntimeJavaSourceLoader monitors specified source folder for source file changes (using FileMonitor). If some source file is changed, class will be recompiled and reloaded and registered listener will be invoked.


Nested Class Summary
static interface RuntimeJavaSourceLoader.ChangeListener
          Listener for class changes, invoked after the class reload.
 
Field Summary
protected  java.util.Map<java.lang.String,jodd.util.RuntimeJavaSourceLoader.Data> allClasses
           
protected  java.util.Map<java.io.File,jodd.util.RuntimeJavaSourceLoader.Data> allSources
           
protected  RuntimeJavaSourceLoader.ChangeListener changeListener
           
protected  boolean debugInfo
           
protected  java.lang.String destinationFolder
           
protected  java.lang.String encoding
           
protected  FileChangeListener fileChangeListener
           
protected  FileMonitor fileMonitor
           
protected  long refreshPeriod
           
protected  java.lang.String sourceFolder
           
 
Constructor Summary
RuntimeJavaSourceLoader(java.lang.String sourceFolder)
           
RuntimeJavaSourceLoader(java.lang.String sourceFolder, long refreshPeriod)
           
 
Method Summary
 void attach(java.lang.Class clazz)
          Attaches class sources for monitoring.
 void attach(java.lang.String className)
          Attaches class sources for monitoring.
protected  java.lang.Class classForName(java.lang.String className, boolean forced)
           
 java.lang.String getDestinationFolder()
           
 java.lang.String getEncoding()
           
 java.lang.String getSourceFolder()
           
 boolean isDebugInfo()
           
 java.lang.Class loadClass(java.lang.String className)
          Loads new class from its source files.
protected  jodd.util.RuntimeJavaSourceLoader.Data register(java.lang.String className)
           
 void registerChangeListener(RuntimeJavaSourceLoader.ChangeListener listener)
          Registeres new change listener.
protected  void reloadClass(jodd.util.RuntimeJavaSourceLoader.Data data)
           
 java.lang.Class reloadClass(java.lang.String className)
          Reloads new class.
 void setDebugInfo(boolean debugInfo)
          Specifies if debug information should be added during compilation.
 void setDestinationFolder(java.lang.String destinationFolder)
          Specifies destination folder where classes will be compiled to.
 void setEncoding(java.lang.String encoding)
          Specifies encoding of java source files.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sourceFolder

protected final java.lang.String sourceFolder

destinationFolder

protected java.lang.String destinationFolder

debugInfo

protected boolean debugInfo

encoding

protected java.lang.String encoding

refreshPeriod

protected final long refreshPeriod

fileMonitor

protected final FileMonitor fileMonitor

fileChangeListener

protected final FileChangeListener fileChangeListener

allClasses

protected final java.util.Map<java.lang.String,jodd.util.RuntimeJavaSourceLoader.Data> allClasses

allSources

protected final java.util.Map<java.io.File,jodd.util.RuntimeJavaSourceLoader.Data> allSources

changeListener

protected RuntimeJavaSourceLoader.ChangeListener changeListener
Constructor Detail

RuntimeJavaSourceLoader

public RuntimeJavaSourceLoader(java.lang.String sourceFolder,
                               long refreshPeriod)

RuntimeJavaSourceLoader

public RuntimeJavaSourceLoader(java.lang.String sourceFolder)
Method Detail

getSourceFolder

public java.lang.String getSourceFolder()

getDestinationFolder

public java.lang.String getDestinationFolder()

setDestinationFolder

public void setDestinationFolder(java.lang.String destinationFolder)
Specifies destination folder where classes will be compiled to. By default, it is system temporary folder.


isDebugInfo

public boolean isDebugInfo()

setDebugInfo

public void setDebugInfo(boolean debugInfo)
Specifies if debug information should be added during compilation.


getEncoding

public java.lang.String getEncoding()

setEncoding

public void setEncoding(java.lang.String encoding)
Specifies encoding of java source files.


loadClass

public java.lang.Class loadClass(java.lang.String className)
                          throws java.lang.ClassNotFoundException
Loads new class from its source files.

Throws:
java.lang.ClassNotFoundException

reloadClass

public java.lang.Class reloadClass(java.lang.String className)
                            throws java.lang.ClassNotFoundException
Reloads new class.

Throws:
java.lang.ClassNotFoundException

attach

public void attach(java.lang.Class clazz)
Attaches class sources for monitoring. Classes will be not loaded on this call, but on very first change.


attach

public void attach(java.lang.String className)
Attaches class sources for monitoring. Classes will be not loaded on this call, but on very first change.


register

protected jodd.util.RuntimeJavaSourceLoader.Data register(java.lang.String className)

classForName

protected java.lang.Class classForName(java.lang.String className,
                                       boolean forced)
                                throws java.lang.ClassNotFoundException
Throws:
java.lang.ClassNotFoundException

reloadClass

protected void reloadClass(jodd.util.RuntimeJavaSourceLoader.Data data)
                    throws java.lang.ClassNotFoundException
Throws:
java.lang.ClassNotFoundException

registerChangeListener

public void registerChangeListener(RuntimeJavaSourceLoader.ChangeListener listener)
Registeres new change listener.



Copyright ©2008 Jodd Team