org.schmant.task.template.process
Class AbstractExtProcessTask<T extends AbstractExtProcessTask<T>>

java.lang.Object
  extended by org.schmant.support.AbstractArgumentChecker
      extended by org.schmant.task.stub.AbstractTask<T>
          extended by org.schmant.task.template.process.AbstractExtProcessTask<T>
All Implemented Interfaces:
TaskDependency, LoggingConfigurable<T>, Task, TaskRunnable, TaskSpecification<T>, ExtProcessConfigured, ExtProcessTask<T>
Direct Known Subclasses:
AbstractExtJvmTask, AntTask, ExtJarSignerTask, ExtProcessTask

public abstract class AbstractExtProcessTask<T extends AbstractExtProcessTask<T>>
extends AbstractTask<T>
implements ExtProcessTask<T>

Abstract base class for tasks running an external program.

Since:
0.5
Author:
Karl Gustafsson

Constructor Summary
AbstractExtProcessTask()
           
 
Method Summary
protected  void addArgumentsToCommandList(ArgumentList al)
          Add the program arguments to the list (which will be modified by this operation).
 void copyProperties(T spec)
          Copy the properties to the target object.
protected  ProcessResult execAndWait(ArgumentList al)
          Run the external program.
protected  List<String> getArguments()
           
 List<String> getEnvironmentVariables()
           
 ProcessResult getProcessResult()
          Get the result of the external program.
 ProcessOutputStrategy getStderrStrategy()
           
 ProcessOutputStrategy getStdoutStrategy()
           
 Object getWorkingDirectory()
           
 boolean isFailOnErrors()
           
 boolean isInheritEnvironmentVariables()
           
 
Methods inherited from class org.schmant.task.stub.AbstractTask
cancel, createTask, getDefaultLogFooter, getDefaultLogHeader, getDependencyForTasksScheduledByThisTask, getDependencyObservable, getFailureCause, getLogFooter, getLogHeader, getSatisfiedStateLock, getThis, isCancelled, isDone, isInterrupted, isRunning, isSatisfied, isSuccessful, run, runInternal, setLogFooter, setLogHeader, setReportLevel, setTraceLogging, toString, validate
 
Methods inherited from class org.schmant.support.AbstractArgumentChecker
check, check, check, check
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.schmant.task.Task
cancel, getDependencyForTasksScheduledByThisTask, getFailureCause, isCancelled, isDone, isInterrupted, isRunning, isSuccessful
 
Methods inherited from interface org.schmant.run.TaskDependency
getDependencyObservable, getSatisfiedStateLock, isSatisfied
 
Methods inherited from interface org.schmant.task.TaskRunnable
run
 

Constructor Detail

AbstractExtProcessTask

public AbstractExtProcessTask()
Method Detail

getProcessResult

public ProcessResult getProcessResult()
Get the result of the external program.

Specified by:
getProcessResult in interface ExtProcessTask<T extends AbstractExtProcessTask<T>>
Returns:
The result of the external program.

getArguments

protected final List<String> getArguments()

isFailOnErrors

public final boolean isFailOnErrors()
Specified by:
isFailOnErrors in interface ExtProcessConfigured

getWorkingDirectory

public final Object getWorkingDirectory()
Specified by:
getWorkingDirectory in interface ExtProcessConfigured

getEnvironmentVariables

public final List<String> getEnvironmentVariables()
Specified by:
getEnvironmentVariables in interface ExtProcessConfigured

isInheritEnvironmentVariables

public final boolean isInheritEnvironmentVariables()
Specified by:
isInheritEnvironmentVariables in interface ExtProcessConfigured

getStdoutStrategy

public final ProcessOutputStrategy getStdoutStrategy()
Specified by:
getStdoutStrategy in interface ExtProcessConfigured

getStderrStrategy

public final ProcessOutputStrategy getStderrStrategy()
Specified by:
getStderrStrategy in interface ExtProcessConfigured

addArgumentsToCommandList

protected void addArgumentsToCommandList(ArgumentList al)
Add the program arguments to the list (which will be modified by this operation).

Parameters:
al - The list of program arguments. Modified by this call.

execAndWait

protected ProcessResult execAndWait(ArgumentList al)
                             throws InterruptedException
Run the external program. This method configures the process with environment variables, etc.

Parameters:
al - A list of the command to run and its arguments.
Returns:
The result of the process.
Throws:
InterruptedException - If the thread is interrupted.

copyProperties

public void copyProperties(T spec)
Description copied from class: AbstractTask
Copy the properties to the target object.

Subclasses must override this to copy their properties. The overriding method must call super.copyProperties.

Specified by:
copyProperties in interface TaskSpecification<T extends AbstractExtProcessTask<T>>
Overrides:
copyProperties in class AbstractTask<T extends AbstractExtProcessTask<T>>
Parameters:
spec - The specification to copy properties to.