com.ls.util.taskrun
Class TaskRunner

java.lang.Object
  |
  +--com.ls.util.taskrun.TaskRunner

public class TaskRunner
extends Object

This class executes scripts which are defined as xml documents.

Version:
$Revision: 1.3 $
Author:
Last modified by $Author: MFehrenbach $

Constructor Summary
TaskRunner()
           
 
Method Summary
 void execute()
          Executes the task batch according to the task definitions.
 Map getEnvironment()
          Returns the environment used for execution the task batch.
 ILogger getLogger()
          Returns the logger instance to which this class and all associated task objects will report information to.
 void setLogger(ILogger logger)
          Sets the logger instance that will handle log requests from this class and all associated tasks.
 void setScript(String fileName)
          Initializes this task runner with tasks defined in the xml file denoted by the given argument.
 void setScript(XMLFragment script)
          Initializes this task runner with tasks defined in the given xml structure.
 void setTaskBatch(XMLFragment taskBatch)
          Initializes this task runner with the task batch contained in the given xml structure.
 void setTaskDef(XMLFragment taskDef)
          Initializes this task runner with task definitions contained in the given xml structure.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TaskRunner

public TaskRunner()
Method Detail

getLogger

public ILogger getLogger()
Returns the logger instance to which this class and all associated task objects will report information to.

Returns:
The logger instance.

setLogger

public void setLogger(ILogger logger)
Sets the logger instance that will handle log requests from this class and all associated tasks.

Parameters:
logger - The logger instance.

setScript

public void setScript(String fileName)
               throws FileNotFoundException,
                      XMLException
Initializes this task runner with tasks defined in the xml file denoted by the given argument.

Parameters:
fileName - The xml file which contains all necessary parts of a script file, the script-, taskdef- and taskbatch-elements.
Throws:
FileNotFoundException - If the given file does not exist.
XMLException - If the xml file could not be parsed. It might be invalid formatted.

setScript

public void setScript(XMLFragment script)
               throws XMLException
Initializes this task runner with tasks defined in the given xml structure.

Parameters:
script - The xml structure containing the required parts of a script, the script-, taskdef- and taskbatch-elements.
Throws:
XMLException - If the xml structure is not of the expected format.

setTaskDef

public void setTaskDef(XMLFragment taskDef)
                throws XMLException
Initializes this task runner with task definitions contained in the given xml structure.

Parameters:
taskDef - The xml structure containing task definitions. This means, that its root element is the taskdef-element.
Throws:
XMLException - If the xml structure is not of the expected format.

setTaskBatch

public void setTaskBatch(XMLFragment taskBatch)
                  throws XMLException
Initializes this task runner with the task batch contained in the given xml structure.

Parameters:
taskBatch - The xml structure containing task batch. This means, that its root element is the taskbatch-element.
Throws:
XMLException - If the xml structure is not of the expected format.

getEnvironment

public Map getEnvironment()
Returns the environment used for execution the task batch.

Returns:
A map representing the task environment.

execute

public void execute()
Executes the task batch according to the task definitions. This method assumes that both, task definition and task batch were already set before, otherwise it will throw an IllegalStateException.