com.ds.fw.utils
Class FwTask

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--com.ds.fw.utils.FwTask
All Implemented Interfaces:
java.lang.Runnable

public abstract class FwTask
extends java.lang.Thread

This class is a base class for all tasks that are going to be scheduled in a FwScheduler instance or have to execute a cyclic algorithm with a specified timeout between each iteration. Each task is executed in a separate thread. The action that will be executed in a cyclic manner has to overwrite the abstract method exec().The timeout between each iteration could be set with setTaskTimeout() method (in minutes). Tha task execution flow could be managed by the following methods: start() - starts the task; _suspend() - pauses the task but keeps it in its run() method, if the task is performing the exec() method when _suspend is called, it finishes its work first and then pauses; _resume() - resumes the suspended task; _stop() - stops the task by making it go out of the run() method scope, if the task is performing the exec() method when _stop is called, it finishes its work first and then stops.


Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
FwTask()
          Class constructor
 
Method Summary
 void _resume()
          This method is called by the Task scheduler to resume the paused Task
 void _stop()
          This method is called by the Task scheduler to stop the Task
 void _suspend()
          This method is called by the Task scheduler to pause the Task
abstract  boolean exec()
          This method should be implemented by subclasses of this class
 long getDay()
           
 long getHours()
           
 long getMinutes()
           
 long getMonth()
           
 java.lang.String getPeriod()
           
 long getRestartTime()
           
 long getStartTime()
           
 long getTaskTimeout()
          Gets the Task timeout in minutes
 java.lang.String getType()
           
 long getWDay()
           
 long getYear()
           
 void run()
           
 void setDay(long n)
           
 void setHours(long n)
           
 void setMinutes(long n)
           
 void setMonth(long n)
           
 void setPeriod(java.lang.String n)
           
 void setRestartTime(long n)
           
 void setStartTime(long n)
           
 void setTaskTimeout(long time)
          Sets the task timeout
 void setType(java.lang.String n)
           
 void setWDay(long n)
           
 void setYear(long n)
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FwTask

public FwTask()
Class constructor

Method Detail

getTaskTimeout

public long getTaskTimeout()
Gets the Task timeout in minutes


setTaskTimeout

public void setTaskTimeout(long time)
Sets the task timeout


exec

public abstract boolean exec()
                      throws java.lang.Exception
This method should be implemented by subclasses of this class

java.lang.Exception

_stop

public void _stop()
This method is called by the Task scheduler to stop the Task


_suspend

public void _suspend()
This method is called by the Task scheduler to pause the Task


_resume

public void _resume()
This method is called by the Task scheduler to resume the paused Task


run

public void run()
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

getPeriod

public java.lang.String getPeriod()

setPeriod

public void setPeriod(java.lang.String n)

getType

public java.lang.String getType()

setType

public void setType(java.lang.String n)

getStartTime

public long getStartTime()

setStartTime

public void setStartTime(long n)

getRestartTime

public long getRestartTime()

setRestartTime

public void setRestartTime(long n)

getYear

public long getYear()

setYear

public void setYear(long n)

getMonth

public long getMonth()

setMonth

public void setMonth(long n)

getDay

public long getDay()

setDay

public void setDay(long n)

getWDay

public long getWDay()

setWDay

public void setWDay(long n)

getHours

public long getHours()

setHours

public void setHours(long n)

getMinutes

public long getMinutes()

setMinutes

public void setMinutes(long n)