|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.lang.ThreadGroup com.massimo.tools.scriptrunner.ScriptRunner
public class ScriptRunner
Run tasks as specified in an XML file.
This extends ThreadGroup in order to handle uncaught exceptions.
To do that, this must run in a new Thread, so Runnable is implemented as well.
Extending ThreadGroup also makes waiting for spawned threads easier.
There are no UI concerns here. Main handles the command line interface.
Constructor Summary | |
---|---|
ScriptRunner(String fileName,
Map<String,String> properties,
boolean validate)
An XML Document is built from the file and the root Task is created by the TaskFactory. |
|
ScriptRunner(Task rootTask)
Simple constructor. |
Method Summary | |
---|---|
ExecutionContext |
getExecutionContext()
A factory method for the ExecutionContext. |
int |
getScriptResult()
|
void |
run()
Implement Runnable Creates the ExecutionContext and ensures that the run identifier is set. |
void |
stopProcessing()
Attempt to interrupt the root task |
String |
toString()
|
void |
uncaughtException(Thread t,
Throwable e)
Called by JVM when a thread in this group stops because of an uncaught exception. |
void |
validate()
Check whether the tasks should be able to run. |
void |
waitForSpawnedThreads()
Tasks may be running in spawned Threads. |
Methods inherited from class java.lang.ThreadGroup |
---|
activeCount, activeGroupCount, allowThreadSuspension, checkAccess, destroy, enumerate, enumerate, enumerate, enumerate, getMaxPriority, getName, getParent, interrupt, isDaemon, isDestroyed, list, parentOf, resume, setDaemon, setMaxPriority, stop, suspend |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ScriptRunner(String fileName, Map<String,String> properties, boolean validate) throws Exception
xi:include
elements are resolved by XIncluder.
fileName
- The XML file nameproperties
- Command line propertiesvalidate
- Whether to use a validating parser or not.
A validating parser will check the XML file against the ScriptRunner and XInclude XSD schemas.
IOException
- if fail to read XML file
ParsingException
- if fail to parse XML file
ValidityException
- if XML file is not valid
XIncludeException
- if XInclude fails
NoIncludeLocationException
- if XInclude fails
InclusionLoopException
- if XInclude finds an inclusion loop
BadParseAttributeException
- if XInclude fails
ClassNotFoundException
- if Task class not found
SecurityException
- Need to be able to call the current Thread's ClassLoader
NoSuchMethodException
- if the constructor signature does not match
AbstractTask's constructor
IllegalArgumentException
- if neither Task type nor class is set, or the Task class does not implement Task
InstantiationException
- if Task class instantiation fails
IllegalAccessException
- if an underlying constructor is inaccessible
InvocationTargetException
- if an underlying constructor throws an exception
Exception
public ScriptRunner(Task rootTask)
rootTask
- Method Detail |
---|
public ExecutionContext getExecutionContext() throws SRException
SRException
- on failurepublic int getScriptResult()
public void run()
run
in interface Runnable
public void stopProcessing()
public String toString()
toString
in class ThreadGroup
ThreadGroup.toString()
public void uncaughtException(Thread t, Throwable e)
uncaughtException
in interface Thread.UncaughtExceptionHandler
uncaughtException
in class ThreadGroup
t
- the thread that is about to exit.e
- the uncaught exception.public void validate()
public void waitForSpawnedThreads()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |