org.schmant.task.stub
Class AbstractTaskFactory<T extends AbstractTaskFactory<T,U>,U extends TaskSpecification<U>>

java.lang.Object
  extended by org.schmant.task.stub.AbstractTaskFactory<T,U>
All Implemented Interfaces:
LoggingConfigurable<T>, TaskFactory<T,U>, TaskRunnable
Direct Known Subclasses:
AbstractActionTaskFactory, AbstractExtProcessTaskFactory, AbstractGeneratorTaskFactory, AbstractSvnTaskFactory, CompoundTF

public abstract class AbstractTaskFactory<T extends AbstractTaskFactory<T,U>,U extends TaskSpecification<U>>
extends Object
implements TaskFactory<T,U>

This is a starting point for TaskFactory implementations.

A task factory configures a Task by configuring its TaskSpecification object. When a Task is created, a flag is set that says that that specification object cannot be used anymore. The next time a setter method is called on the task factory, the factory creates a new TaskSpecification object and copies the previous specification object's configuration by calling its TaskSpecification.copyProperties(TaskSpecification) method.

Since:
0.5
Author:
Karl Gustafsson

Constructor Summary
AbstractTaskFactory()
           
 
Method Summary
 T copy()
          Create a copy of this task factory.
 Task create()
          Create a task.
protected abstract  U createSpecification()
          Subclasses implement this to create the task specification object that this factory uses to configure the task that it is creating.
 Task getLastCreated()
          Get the last created task.
 U getSpecification()
          Subclasses use this to get the task specification that they are currently configuring.
protected  T getThis()
          This method returns this object cast to its actual type.
 Task run()
          Run the task and return it.
 T setLogFooter(String s)
          Set the task's log footer (the message that is logged to level info after the task has completed successfully).
 T setLogHeader(String s)
          Set the task's log header (the message that is logged to level info before the task is run).
 T setReportLevel(Level l)
          Set the Report level to use when running tasks created by this factory.
 T setTraceLogging(boolean b)
          Enable or disable trace logging for tasks created by this factory.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractTaskFactory

public AbstractTaskFactory()
Method Detail

createSpecification

protected abstract U createSpecification()
Subclasses implement this to create the task specification object that this factory uses to configure the task that it is creating.


getSpecification

public final U getSpecification()
Subclasses use this to get the task specification that they are currently configuring. The task specification is created via a call to the createSpecification() method the first time this method is called and whenever a new specification must be created since the current specification has been used to create a task.

Specified by:
getSpecification in interface TaskFactory<T extends AbstractTaskFactory<T,U>,U extends TaskSpecification<U>>
Returns:
The current task specification.

getThis

protected final T getThis()
This method returns this object cast to its actual type.

Returns:
this

setLogHeader

public final T setLogHeader(String s)
Description copied from interface: LoggingConfigurable
Set the task's log header (the message that is logged to level info before the task is run). If no log header is set, the default log header from AbstractTask.getDefaultLogHeader() is used.

Specified by:
setLogHeader in interface LoggingConfigurable<T extends AbstractTaskFactory<T,U>>
Parameters:
s - The log header. Set to null to not log a header.
Returns:
this

setLogFooter

public final T setLogFooter(String s)
Description copied from interface: LoggingConfigurable
Set the task's log footer (the message that is logged to level info after the task has completed successfully). Set to null to disable the footer.

Specified by:
setLogFooter in interface LoggingConfigurable<T extends AbstractTaskFactory<T,U>>
Parameters:
s - The footer to log.
Returns:
this

create

public final Task create()
Description copied from interface: TaskFactory
Create a task.

Specified by:
create in interface TaskFactory<T extends AbstractTaskFactory<T,U>,U extends TaskSpecification<U>>
Returns:
The task.

copy

public final T copy()
Description copied from interface: TaskFactory
Create a copy of this task factory. The copied factory will use a new (copied) TaskSpecification object having the same configuration as this task factory's specification object.

Specified by:
copy in interface TaskFactory<T extends AbstractTaskFactory<T,U>,U extends TaskSpecification<U>>
Returns:
A copy of this task factory.

getLastCreated

public final Task getLastCreated()
Description copied from interface: TaskFactory
Get the last created task.

Specified by:
getLastCreated in interface TaskFactory<T extends AbstractTaskFactory<T,U>,U extends TaskSpecification<U>>
Returns:
The last created task.

setTraceLogging

public T setTraceLogging(boolean b)
Description copied from interface: LoggingConfigurable
Enable or disable trace logging for tasks created by this factory. Trace logging means that a task's configuration is printed before it is run.

Task configuration is trace logged if trace logging is enabled for the task itself or for its task factory.

Specified by:
setTraceLogging in interface LoggingConfigurable<T extends AbstractTaskFactory<T,U>>
Parameters:
b - Set to true to enable trace logging.
Returns:
this.

setReportLevel

public T setReportLevel(Level l)
Description copied from interface: LoggingConfigurable
Set the Report level to use when running tasks created by this factory.

Specified by:
setReportLevel in interface LoggingConfigurable<T extends AbstractTaskFactory<T,U>>
Parameters:
l - The report level. If null, the report level will not be modified.
Returns:
this.

run

public Task run()
Description copied from interface: TaskRunnable
Run the task and return it.

Specified by:
run in interface TaskRunnable
Returns:
The task that was run.

toString

public String toString()
Overrides:
toString in class Object