com.googlecode.lightest.core
Class LightestTask

java.lang.Object
  extended by com.googlecode.lightest.core.LightestContextAware
      extended by com.googlecode.lightest.core.LightestTask
All Implemented Interfaces:
IBreakpointTask, ITask, ITaskProvider, groovy.lang.GroovyObject

public abstract class LightestTask
extends LightestContextAware
implements groovy.lang.GroovyObject, IBreakpointTask

A convenient base class for implementations of ITask.


Field Summary
protected  TaskNode config
           
protected  ITaskResult parentResult
           
protected  ITaskResult taskResult
           
 
Constructor Summary
LightestTask()
           
 
Method Summary
protected  Set configurableProperties()
          Returns a Set of this class' bean property name String's that can be automatically set based on the TaskNode passed to the configure() method.
 void configure(TaskNode config, ITaskResult parentResult)
          Configures the task by making member variables available to concrete subclasses, and automatically setting configurable bean properties.
abstract  void doPerform(ITaskResult result)
          Concrete subclasses must implement this method, which is wrapped by the perform() method.
 TaskNodeBuilder getBuilder()
          Returns the builder this task provider uses to create task nodes to be sent for dispatch.
 String getDescription()
          Returns a user supplied description of the task instance, its purpose, etc.
 groovy.lang.MetaClass getMetaClass()
           
 String getName()
          Returns the name of this task, which is the binary name of the class.
 Map getParams()
          Returns a new Map of names to values of the paremeters to the task.
 Object getProperty(String name)
           
 String getShortName()
          Returns the short name of the task, which is the unqualified class name.
 Object getValue()
          Returns the value set as the node value in the configuration.
 Object invokeMethod(String name, Object args)
           
 boolean isBreakpoint()
          Returns true if this task has its breakpoint set, and false otherwise.
 ITaskResult perform()
          Performs the task in an environment, and returns the result.
 void setMetaClass(groovy.lang.MetaClass metaClass)
           
 void setProperty(String name, Object value)
           
 
Methods inherited from class com.googlecode.lightest.core.LightestContextAware
getContext, getDispatcher, getEnv, getPrefs, setDispatcher
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.googlecode.lightest.core.ITask
setDispatcher
 

Field Detail

config

protected TaskNode config

parentResult

protected ITaskResult parentResult

taskResult

protected ITaskResult taskResult
Constructor Detail

LightestTask

public LightestTask()
Method Detail

configurableProperties

protected Set configurableProperties()
Returns a Set of this class' bean property name String's that can be automatically set based on the TaskNode passed to the configure() method. This Set is basically the full listing of settable properties for this class, minus all properties of the LightestTask class. This method can be overriden to exclude additional bean properties that should not be auto-configured.


configure

public void configure(TaskNode config,
                      ITaskResult parentResult)
Configures the task by making member variables available to concrete subclasses, and automatically setting configurable bean properties. Implicit conversion between Integer, String, and Boolean types is supported. Override this method for different configuration behavior.

Specified by:
configure in interface ITask
Parameters:
config -
parentResult - the result of performing the parent task. May be null if this task has no parent.

getName

public String getName()
Returns the name of this task, which is the binary name of the class.

Specified by:
getName in interface ITask

getShortName

public String getShortName()
Returns the short name of the task, which is the unqualified class name.

Specified by:
getShortName in interface ITask

getDescription

public String getDescription()
Description copied from interface: ITask
Returns a user supplied description of the task instance, its purpose, etc.

Specified by:
getDescription in interface ITask

getParams

public Map getParams()
Description copied from interface: ITask
Returns a new Map of names to values of the paremeters to the task. This identifies how the task can be reproduced. Names are String's, values are Object's.

Specified by:
getParams in interface ITask

getValue

public Object getValue()
Description copied from interface: ITask
Returns the value set as the node value in the configuration. This, like getParams(), is information about how the task was configured.

Specified by:
getValue in interface ITask

isBreakpoint

public boolean isBreakpoint()
Description copied from interface: IBreakpointTask
Returns true if this task has its breakpoint set, and false otherwise.

Specified by:
isBreakpoint in interface IBreakpointTask

doPerform

public abstract void doPerform(ITaskResult result)
Concrete subclasses must implement this method, which is wrapped by the perform() method. The result is passed in, so implementing methods may simply populate it without needing to create it or return it.

Parameters:
result - the result which will be returned by the outer call to perform().

perform

public ITaskResult perform()
Performs the task in an environment, and returns the result. Tasks may choose to use or ignore the results of their parent tasks. This implementation wraps doPerform() so it can safely execute the task and add some behaviors to the result.

Specified by:
perform in interface ITask

getBuilder

public TaskNodeBuilder getBuilder()
Description copied from interface: ITaskProvider
Returns the builder this task provider uses to create task nodes to be sent for dispatch.

Specified by:
getBuilder in interface ITaskProvider

getMetaClass

public groovy.lang.MetaClass getMetaClass()
Specified by:
getMetaClass in interface groovy.lang.GroovyObject
Overrides:
getMetaClass in class LightestContextAware

setMetaClass

public void setMetaClass(groovy.lang.MetaClass metaClass)
Specified by:
setMetaClass in interface groovy.lang.GroovyObject
Overrides:
setMetaClass in class LightestContextAware

invokeMethod

public Object invokeMethod(String name,
                           Object args)
Specified by:
invokeMethod in interface groovy.lang.GroovyObject
Overrides:
invokeMethod in class LightestContextAware

getProperty

public Object getProperty(String name)
Specified by:
getProperty in interface groovy.lang.GroovyObject
Overrides:
getProperty in class LightestContextAware

setProperty

public void setProperty(String name,
                        Object value)
Specified by:
setProperty in interface groovy.lang.GroovyObject
Overrides:
setProperty in class LightestContextAware


Copyright © 2009. All Rights Reserved.