|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.infoengine.SAK.TaskCompiler
This class supports dynamic compilation of Info*Engine tasks.
Nested Class Summary | |
private class |
TaskCompiler.Tag
Inner class for parsing tags from a stream tokenizer. |
private class |
TaskCompiler.TaskClassLoader
Inner class for loading tasklets. |
private class |
TaskCompiler.UnitDescriptor
Inner class supporting task units ( |
Field Summary | |
private String |
codebase
|
private Hashtable |
compiledClasses
|
private String |
compilerClassPath
|
private static String |
ID_COMP_CLASSES
|
private static String |
ID_COMP_CLASSPATH
|
private static String |
ID_TASK_FILE_EXPIRY
|
private static String |
ID_TASK_SRC_EXPIRY
|
private static String |
ID_TASKS
|
private int |
iteratorOrdinal
|
private com.infoengine.log.LogWriter |
log
|
private Vector |
processors
|
boolean |
recoveryCode
|
static String |
RESOURCE
|
static String |
TAGLIB_URI
|
private String |
tagPrefix
|
private Hashtable |
taskFileExpiry
|
private int |
taskOrdinal
|
private String |
taskRoot
|
private Hashtable |
tasks
|
private Hashtable |
taskSourceExpiry
|
private long |
timeToLive
|
static int |
VERSION
|
private int |
webjectOrdinal
|
Constructor Summary | |
TaskCompiler()
Constructs a simple instance. |
Method Summary | |
Tasklet |
compile(String url)
Compiles a task and returns an instance that can be invoked. |
private void |
compileTask(String className,
String uri)
Parse task source and produce a Java tasklet from it. |
private void |
emitParam(String wsp,
String prefix,
TaskCompiler.Tag paramTag,
String uri,
int lineNumber,
PrintWriter pw)
Emits code to process a webject or task parameter. |
private String |
escape(String source)
Returns the escaped version of a string that possibly contains characters that aren't suitable as contents of Java source strings, e.g., double quotes and backslashes. |
private void |
generateJavaSource(String className,
String uri,
BufferedReader rdr,
PrintWriter pw)
Parse a task file and produce a Java source file from it. |
private String |
getClassNameForTask(String uri)
Return the class name associated with a task URI. |
String |
getCodebase()
Returns the pathname of the file system root directory of the codebase to which generated code will be written. |
private String |
getCodebasePathForTask(String uri)
Return the base pathname of the generated java and class files associated with a task URI. |
com.infoengine.log.LogWriter |
getLog()
Returns the LogWriter to which log messages are currently written. |
String |
getTaskRoot()
Returns the pathname of the file system directory where tasks specified by relative URL are found. |
private String |
indent(int depth)
Returns a string of blanks reflecting the indenting depth. |
private boolean |
isTaskStale(String uri)
Return true if the specified task file has been modified since the tasklet generated from it was last compiled. |
private Class |
loadTask(String className,
String uri)
Load the class associated with a specified tasklet. |
private String |
parseParamValue(String attr,
String data,
String deflt,
String uri,
int lineno,
boolean runtimeSubst)
Parses a tag attribute value to generate code for special substitution strings and embedded <%= ... |
private void |
parseTask(StreamTokenizer tokenizer,
String uri,
PrintWriter spw,
PrintWriter dpw,
PrintWriter cpw,
TaskCompiler.Tag tag,
int indentDepth,
int parallelDepth,
boolean inheritForm)
Parses a TASK tag and generates Java source for it. |
private String |
parseWebject(StreamTokenizer tokenizer,
String uri,
PrintWriter spw,
PrintWriter dpw,
PrintWriter cpw,
TaskCompiler.Tag tag,
int indentDepth,
int parallelDepth)
Parses a WEBJECT tag and generates Java source for it. |
void |
setCodebase(String pathname)
Sets the pathname of the file system root directory of the codebase to which generated code will be written. |
void |
setLog(com.infoengine.log.LogWriter log)
Sets the LogWriter to which log messages will be written. |
private void |
setTaskFileExpiry(File taskFile)
Sets the expiration on a task file if configured to do so. |
void |
setTaskRoot(String pathname)
Sets the pathname of the default file system directory in which task source is found for tasks specified by relative URL. |
private String |
unescape(String source)
Returns the unescaped version of a string that possibly contains escapes for characters that aren't valid characters for Java identifiers. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String TAGLIB_URI
public static final int VERSION
public static final String RESOURCE
public boolean recoveryCode
private String codebase
private int iteratorOrdinal
private com.infoengine.log.LogWriter log
private Vector processors
private String tagPrefix
private int taskOrdinal
private String taskRoot
private long timeToLive
private int webjectOrdinal
private static final String ID_COMP_CLASSES
private static final String ID_COMP_CLASSPATH
private static final String ID_TASKS
private static final String ID_TASK_SRC_EXPIRY
private static final String ID_TASK_FILE_EXPIRY
private Hashtable compiledClasses
private String compilerClassPath
private Hashtable tasks
private Hashtable taskSourceExpiry
private Hashtable taskFileExpiry
Constructor Detail |
public TaskCompiler()
Method Detail |
public void setTaskRoot(String pathname)
pathname
- The pathname of the directory where tasks specified
by relative URL are found.public String getTaskRoot()
public void setCodebase(String pathname)
pathname
- The pathname of the root directory of the codebase.public String getCodebase()
public void setLog(com.infoengine.log.LogWriter log)
log
- The LogWriter object.public com.infoengine.log.LogWriter getLog()
public Tasklet compile(String url) throws IEException, IOException
url
- The URL of the task to be compiled. The URL can be
a relative URL that is relative to the task root
directory, it can be an LDAP URL that identifies a
directory entry and associated attribute containing the
source for a task, or it can be an HTTP URL that identifies
the source for a task.
IEException
- if an error other than an I/O error occurs.
IOException
- if an I/O error occurs.private String getClassNameForTask(String uri)
uri
- task URI
private String getCodebasePathForTask(String uri)
uri
- task URI
private Class loadTask(String className, String uri) throws IEException
className
- the tasklet class nameuri
- the URI of the task source
IEException
private boolean isTaskStale(String uri)
uri
- the URI of the task source
private void setTaskFileExpiry(File taskFile)
taskFile
- The File object referencing the task.private void compileTask(String className, String uri) throws IEException
className
- the name of the class to be compileduri
- the URI of the task source
IEException
private void generateJavaSource(String className, String uri, BufferedReader rdr, PrintWriter pw) throws IEException
className
- the name of the class to be generateduri
- the URI of the task for which to generate Java sourcerdr
- task source file readerpw
- Java output file writer
IEException
private String parseWebject(StreamTokenizer tokenizer, String uri, PrintWriter spw, PrintWriter dpw, PrintWriter cpw, TaskCompiler.Tag tag, int indentDepth, int parallelDepth) throws IEException
tokenizer
- The stream tokenizer from which to obtain
webject tokensuri
- The URI of the task for which to generate Java sourcespw
- The PrintWriter on which to write normal textdpw
- The PrintWriter on which to write compiler directivescpw
- The PrintWriter on which to write class-level script texttag
- The webject tagindentDepth
- The current indentation levelparallelDepth
- The current nesting level of IEException
private void parseTask(StreamTokenizer tokenizer, String uri, PrintWriter spw, PrintWriter dpw, PrintWriter cpw, TaskCompiler.Tag tag, int indentDepth, int parallelDepth, boolean inheritForm) throws IEException
tokenizer
- The stream tokenizer from which to obtain
webject tokensuri
- The URI of the task for which to generate Java sourcespw
- The PrintWriter on which to write script text
bracketed by <% and %>dpw
- The PrintWriter on which to write compiler directivescpw
- The PrintWriter on which to write class-level script texttag
- The task tagindentDepth
- The current indentation levelparallelDepth
- The current nesting level of inheritForm
- true if the new task should inherit the FORM
context group of its parent
IEException
private void emitParam(String wsp, String prefix, TaskCompiler.Tag paramTag, String uri, int lineNumber, PrintWriter pw) throws IEException
wsp
- The whitespace indentation.prefix
- The webject or task instance prefix.paramTag
- The parameter tag object instance.uri
- The URI of the task being compiledpw
- The PrintWriter on which to write the code.
IEException
private String parseParamValue(String attr, String data, String deflt, String uri, int lineno, boolean runtimeSubst) throws IEException
attr
- The tag attribute namedata
- The value to parsedeflt
- The default value for parametersuri
- The URI of the task being compiledlineno
- The current line number being parsedruntimeSubst
- true if runtime resolution of substitution syntax
is allowed
IEException
private String escape(String source)
source
- The string containing unescaped characters
private String unescape(String source)
source
- The string containing escaped characters
private String indent(int depth)
depth
- The indenting depth
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |