org.schmant.task.template.proxy
Class AbstractProxyTask<T extends AbstractProxyTask<T>>

java.lang.Object
  extended by org.schmant.support.AbstractArgumentChecker
      extended by org.schmant.task.stub.AbstractTask<T>
          extended by org.schmant.task.stub.AbstractActionTask<T>
              extended by org.schmant.task.stub.AbstractProcessTask<T>
                  extended by org.schmant.task.template.proxy.AbstractProxyTask<T>
All Implemented Interfaces:
TaskDependency, ActionTaskConfigurable<T>, ActionTaskSpec<T>, LoggingConfigurable<T>, OverwriteConfigurable<T>, SourceConfigurable<T>, SourceConfigured, TargetConfigurable<T>, TargetConfigured, GeneratorTaskConfigurable<T>, GeneratorTaskSpec<T>, ProcessTaskConfigurable<T>, ProcessTaskSpec<T>, Task, TaskRunnable, TaskSpecification<T>
Direct Known Subclasses:
ErrorIgnoringTask, RedirectReportTask, TimedExecutionTask

public abstract class AbstractProxyTask<T extends AbstractProxyTask<T>>
extends AbstractProcessTask<T>

Abstract base class for task proxy implementations.

Since:
0.5
Author:
Karl Gustafsson

Field Summary
 
Fields inherited from interface org.schmant.task.confable.OverwriteConfigurable
DEFAULT_OVERWRITE_STRATEGY
 
Constructor Summary
AbstractProxyTask()
           
 
Method Summary
 void copyProperties(T spec)
          Override the implementation from AbstractTask to copy the source properties.
protected  Task createAndConfigureProxiedTask()
          Create and configure the proxied task.
protected  void disableLoggingIfOwnLoggingIsDisabled(TaskSpecification<?> t)
           
protected  String getDefaultLogHeader()
          By default, logging is disabled.
protected  Object getTaskFactory()
           
protected  boolean isSourcesMandatory()
          Must the sources property be set? This method returns true.
protected  boolean isTargetMandatory()
          Is a target mandatory? This method always returns true.
protected  Collection<String> validate(Report r)
          Override the method inherited from AbstractTask to give a validation error if no source is set (and AbstractActionTask.isSourcesMandatory() is true).
 
Methods inherited from class org.schmant.task.stub.AbstractProcessTask
getOverwriteStrategy, getTarget, setOverwrite, setOverwriteStrategy, setTarget, toString
 
Methods inherited from class org.schmant.task.stub.AbstractActionTask
addSource, addSources, clearSources, getRelativeToBase, getSource, getSources, isMoreThanOneSourceAllowed, setRelativeToBase, setSource, setSources
 
Methods inherited from class org.schmant.task.stub.AbstractTask
cancel, createTask, getDefaultLogFooter, getDependencyForTasksScheduledByThisTask, getDependencyObservable, getFailureCause, getLogFooter, getLogHeader, getSatisfiedStateLock, getThis, isCancelled, isDone, isInterrupted, isRunning, isSatisfied, isSuccessful, run, runInternal, setLogFooter, setLogHeader, setReportLevel, setTraceLogging
 
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.confable.SourceConfigurable
addSource, addSources, clearSources, setRelativeToBase, setSource, setSources
 
Methods inherited from interface org.schmant.task.confable.SourceConfigured
getSource, getSources
 
Methods inherited from interface org.schmant.task.TaskSpecification
createTask
 
Methods inherited from interface org.schmant.task.confable.LoggingConfigurable
setLogFooter, setLogHeader, setReportLevel, setTraceLogging
 

Constructor Detail

AbstractProxyTask

public AbstractProxyTask()
Method Detail

getTaskFactory

protected final Object getTaskFactory()
Returns:
May be a TaskFactory or a closure.

getDefaultLogHeader

protected String getDefaultLogHeader()
By default, logging is disabled.

Overrides:
getDefaultLogHeader in class AbstractTask<T extends AbstractProxyTask<T>>
Returns:
"Running " + toString()

isSourcesMandatory

protected boolean isSourcesMandatory()
Description copied from class: AbstractActionTask
Must the sources property be set? This method returns true. Subclasses may override this method to return false if the sources property is not mandatory.

Overrides:
isSourcesMandatory in class AbstractActionTask<T extends AbstractProxyTask<T>>
Returns:
true, always.

isTargetMandatory

protected boolean isTargetMandatory()
Description copied from class: AbstractProcessTask
Is a target mandatory? This method always returns true. Subclasses may override this to return false if a target is not mandatory for them.

Overrides:
isTargetMandatory in class AbstractProcessTask<T extends AbstractProxyTask<T>>
Returns:
true, always

validate

protected Collection<String> validate(Report r)
Description copied from class: AbstractActionTask
Override the method inherited from AbstractTask to give a validation error if no source is set (and AbstractActionTask.isSourcesMandatory() is true).

Subclasses may override this to add their own validations.

Overrides:
validate in class AbstractProcessTask<T extends AbstractProxyTask<T>>
Parameters:
r - A report to log warning and debug messages to. Validation errors should not be logged, though. They are logged later.
Returns:
A collection of error messages.

createAndConfigureProxiedTask

protected Task createAndConfigureProxiedTask()
Create and configure the proxied task. If the task is an action task, it inherits the source settings from this task. If it is a generator task, it inherits the target settings.

Returns:
The configured proxied task.

disableLoggingIfOwnLoggingIsDisabled

protected final void disableLoggingIfOwnLoggingIsDisabled(TaskSpecification<?> t)

copyProperties

public void copyProperties(T spec)
Description copied from class: AbstractActionTask
Override the implementation from AbstractTask to copy the source properties. Subclasses must override this to copy their own properties.

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