org.inxar.hotswap
Class ProxyCompiler

java.lang.Object
  |
  +--org.inxar.hotswap.ProxyCompiler
All Implemented Interfaces:
org.inxar.hotswap.PriorityQueue.Listener
Direct Known Subclasses:
JavacCompiler, SystemCompiler

public abstract class ProxyCompiler
extends Object
implements org.inxar.hotswap.PriorityQueue.Listener

The ProxyCompiler mediates sourcefile compilation.

ProxyCompiler Usage
 ProxyCompiler compiler = new JavacCompiler();
 ProxyCompiler compiler = new SystemCompiler("jikes");

 compiler.setDestinationpath("path/to/location/where/classfiles/are/written/");
 compiler.setSourcepath("path/to/location/where/sourcefiles/are/searched/");
 compiler.getClasspath().add("path/to/any/other/necessary/libraries/or/jarfiles");

 proxyClass.setCompiler(compiler);
 proxyClassLoader.setDefaultCompiler(compiler);
 

Since:
0.8.2

Field Summary
static int COMPILE_FAILURE
          int compile return code signifying that a compilation was attempted and NOT completed successfully.
static int COMPILE_SUCCESS
          int compile return code signifying that a compilation was attempted and completed successfully.
static int COMPILE_UNKNOWN
          int compile return code signifying the outcome of a compilation could not be determined.
static int STATUS_COMPILE
          int getStatus return code signifying the classfile is out of date and needs to be recompiled.
static int STATUS_CURRENT
          int getStatus return code signifying that a the Class object in memory is up to date.
static int STATUS_ERROR
          int getStatus return code signifying that the class needs to be loaded, but no classfile or sourcefile could be found.
static int STATUS_LOAD
          int getStatus return code signifying that the object in memory is out of date with the classfile, it needs to be reloaded from the classfile.
static int STATUS_UNKNOWN
          int getStatus return code signifying that a the status could not be determined.
static int STATUS_WARN
          int getStatus return code signifying that no classfile or sourcefile could be found EVEN though the object was previously loaded into memory (suggesting that both the classfile and sourcefile were subsequently deleted).
 
Method Summary
 void addCompileListener(ProxyEventListener l)
          Adds the given listener of ProxyCompileEvent notifications.
abstract  ProxyCompileEvent compile(ProxyClass cls)
          Compiles the class associated with the given ProxyClass.
 ProxyResource getClassfile(ProxyClass cls)
          Returns the classfile ProxyResource for this ProxyClass.
 List getClasspath()
          Returns the List of the classpath entries.
 String getDestinationpath()
          Sets the pathname where the class files should be written (and read from).
 List getOptions()
          Returns the List of the option entries.
 ProxyResource getSourcefile(ProxyClass cls)
          Returns the sourcefile ProxyResource for this ProxyClass.
 Object getSourcepath()
          Returns the location where the source files packages are located.
 int getStatus(ProxyClass proxyClass)
          Returns the status of ProxyClass as one of the STATUS_XXX constants in this class.
 boolean initialize(Properties p)
          Initializes the ProxyCompiler instance from the given Properties.
 void queue_notify(Object callback)
          Asynchronous callback method that is invoked by the priority queue thread.
 void removeCompileListener(ProxyEventListener l)
          Removes the given listener of ProxyCompileEvent notifications.
 void setDestinationpath(String dst)
          Returns the pathname where the compiled classes will be written.
 void setProxyClassLoader(ProxyClassLoader loader)
          Sets the parent ProxyClassLoader.
 void setSourcepath(Object sourcepath)
          Sets the Object where the source files packages are located.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STATUS_CURRENT

public static final int STATUS_CURRENT
int getStatus return code signifying that a the Class object in memory is up to date.

STATUS_LOAD

public static final int STATUS_LOAD
int getStatus return code signifying that the object in memory is out of date with the classfile, it needs to be reloaded from the classfile.

STATUS_COMPILE

public static final int STATUS_COMPILE
int getStatus return code signifying the classfile is out of date and needs to be recompiled. Also returned when a sourcefile exists but no classfile has yet been compiled.

STATUS_WARN

public static final int STATUS_WARN
int getStatus return code signifying that no classfile or sourcefile could be found EVEN though the object was previously loaded into memory (suggesting that both the classfile and sourcefile were subsequently deleted).

STATUS_ERROR

public static final int STATUS_ERROR
int getStatus return code signifying that the class needs to be loaded, but no classfile or sourcefile could be found.

STATUS_UNKNOWN

public static final int STATUS_UNKNOWN
int getStatus return code signifying that a the status could not be determined.

COMPILE_SUCCESS

public static final int COMPILE_SUCCESS
int compile return code signifying that a compilation was attempted and completed successfully.

COMPILE_FAILURE

public static final int COMPILE_FAILURE
int compile return code signifying that a compilation was attempted and NOT completed successfully.

COMPILE_UNKNOWN

public static final int COMPILE_UNKNOWN
int compile return code signifying the outcome of a compilation could not be determined.
Method Detail

compile

public abstract ProxyCompileEvent compile(ProxyClass cls)
Compiles the class associated with the given ProxyClass.

queue_notify

public void queue_notify(Object callback)
Asynchronous callback method that is invoked by the priority queue thread.
Specified by:
queue_notify in interface org.inxar.hotswap.PriorityQueue.Listener

setProxyClassLoader

public void setProxyClassLoader(ProxyClassLoader loader)
Sets the parent ProxyClassLoader. This must be set directly after instantiation of the ProxyCompiler.

initialize

public boolean initialize(Properties p)
Initializes the ProxyCompiler instance from the given Properties. If initialization was unsuccessful, return false.

setSourcepath

public void setSourcepath(Object sourcepath)
Sets the Object where the source files packages are located. The run-time type of this Object may be a String or File (may add URL later).

getSourcepath

public Object getSourcepath()
Returns the location where the source files packages are located.

setDestinationpath

public void setDestinationpath(String dst)
Returns the pathname where the compiled classes will be written.

getDestinationpath

public String getDestinationpath()
Sets the pathname where the class files should be written (and read from).

getOptions

public List getOptions()
Returns the List of the option entries. Users should interact with the List directly to add Object instances whose toString() method will render appropriately. Each entry is printed as-is, no dashes are added by the compiler.

getClasspath

public List getClasspath()
Returns the List of the classpath entries. Users should interact with the List directly to add Object instances whose toString() method will render appropriately.

addCompileListener

public void addCompileListener(ProxyEventListener l)
Adds the given listener of ProxyCompileEvent notifications.

removeCompileListener

public void removeCompileListener(ProxyEventListener l)
Removes the given listener of ProxyCompileEvent notifications.

getSourcefile

public ProxyResource getSourcefile(ProxyClass cls)
Returns the sourcefile ProxyResource for this ProxyClass.

getClassfile

public ProxyResource getClassfile(ProxyClass cls)
Returns the classfile ProxyResource for this ProxyClass.

getStatus

public int getStatus(ProxyClass proxyClass)
Returns the status of ProxyClass as one of the STATUS_XXX constants in this class.