com.jfw.scheduler
Class ScheduleTypes

java.lang.Object
  extended by com.jfw.scheduler.ScheduleTypes
Direct Known Subclasses:
Daily, Monthly, Period, Startup, Weekly

public abstract class ScheduleTypes
extends java.lang.Object

Must be extend by the classes implement a particular type of scheduling.


Field Summary
protected  java.lang.String className
          Used for logging.
static java.lang.String EXECUTE_NOW_KEY
          Key used in status properties file.
protected  java.lang.String frequence
          Execution frequence.
protected  java.lang.String id
          Scduled bean unique id.
static java.lang.String NEXT_EXECUTION_DATE_KEY
          Key used in status properties file.
static java.lang.String NEXT_EXECUTION_TIME_KEY
          Key used in status properties file.
static java.lang.String PREVIOUS_EXECUTION_DATE_KEY
          Key used in status properties file.
static java.lang.String PREVIOUS_EXECUTION_TIME_KEY
          Key used in status properties file.
protected  java.lang.String scheduleBean
          The class name of the scheduled bean.
protected  ScheduleThread scheduleThread
          The thread who execute the scheduled bean.
protected  java.util.Properties statusProperties
          Contains execution info relative of the scheduled bean.
 
Constructor Summary
ScheduleTypes()
           
 
Method Summary
protected  void addError(java.lang.String message)
          Add an error message in ScheduleThread.errors.
protected  void commonSleep()
          Implement the logic of common sleep before the schedule bean is execute.
 boolean existStatusProperties()
          Check if the properties file, relative of the execution of a scheduled bean, exist.
protected  java.lang.String getFileName()
          Return the file name of the properties file.
protected abstract  java.util.Date getNextExecutionDate()
          Return the next execution day.
protected  java.lang.String getScheduleObjectsPath()
          Get the path where the scheduling execution can be saved.
protected  void readStatus()
          Read file saved in saveStatus().
protected  void saveStatus()
          Save attribute statusProperties as a file in disk.
protected abstract  void setParams()
          Set init parameters for the specific type of scheduling.
protected abstract  void sleep()
          Implement the logic of sleep before the schedule bean is execute.
protected  void updateProperties(long nextExecutionTime)
          Update attribute statusProperties with the status of execution.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

className

protected java.lang.String className
Used for logging.


frequence

protected java.lang.String frequence
Execution frequence.


id

protected java.lang.String id
Scduled bean unique id.


scheduleThread

protected ScheduleThread scheduleThread
The thread who execute the scheduled bean.


scheduleBean

protected java.lang.String scheduleBean
The class name of the scheduled bean.


statusProperties

protected java.util.Properties statusProperties
Contains execution info relative of the scheduled bean.


NEXT_EXECUTION_TIME_KEY

public static final java.lang.String NEXT_EXECUTION_TIME_KEY
Key used in status properties file.

See Also:
Constant Field Values

NEXT_EXECUTION_DATE_KEY

public static final java.lang.String NEXT_EXECUTION_DATE_KEY
Key used in status properties file.

See Also:
Constant Field Values

PREVIOUS_EXECUTION_TIME_KEY

public static final java.lang.String PREVIOUS_EXECUTION_TIME_KEY
Key used in status properties file.

See Also:
Constant Field Values

PREVIOUS_EXECUTION_DATE_KEY

public static final java.lang.String PREVIOUS_EXECUTION_DATE_KEY
Key used in status properties file.

See Also:
Constant Field Values

EXECUTE_NOW_KEY

public static final java.lang.String EXECUTE_NOW_KEY
Key used in status properties file.

See Also:
Constant Field Values
Constructor Detail

ScheduleTypes

public ScheduleTypes()
Method Detail

readStatus

protected void readStatus()
                   throws java.lang.Exception
Read file saved in saveStatus(). This file contains execution info for the scheduled bean.

Throws:
java.lang.Exception

saveStatus

protected void saveStatus()
                   throws java.lang.Exception
Save attribute statusProperties as a file in disk. The path to save the file is returned by getScheduleObjectsPath(). for example CleanLogFiles1.properties.

Throws:
java.lang.Exception

updateProperties

protected void updateProperties(long nextExecutionTime)
                         throws java.lang.Exception
Update attribute statusProperties with the status of execution.

Throws:
java.lang.Exception

existStatusProperties

public boolean existStatusProperties()
Check if the properties file, relative of the execution of a scheduled bean, exist. The properties file is saved in path returned by getScheduleObjectsPath(). The name of the properties file is the name of the class of the scheduled bean, plus properties.

Returns:
true if file exist, false if not exist.

addError

protected void addError(java.lang.String message)
Add an error message in ScheduleThread.errors.

Parameters:
message - error message to add.

getScheduleObjectsPath

protected java.lang.String getScheduleObjectsPath()
Get the path where the scheduling execution can be saved.

Returns:
the path where the scheduling execution can be saved..

getFileName

protected java.lang.String getFileName()
Return the file name of the properties file. The name is the concatanation of scheduleBean + - + id + .properties

Returns:
the file name of the properties file.

getNextExecutionDate

protected abstract java.util.Date getNextExecutionDate()
                                                throws java.lang.Exception
Return the next execution day.

Returns:
next execution date or null.
Throws:
java.lang.Exception

sleep

protected abstract void sleep()
                       throws java.lang.Exception
Implement the logic of sleep before the schedule bean is execute.

Throws:
java.lang.Exception

setParams

protected abstract void setParams()
Set init parameters for the specific type of scheduling.


commonSleep

protected void commonSleep()
                    throws java.lang.Exception
Implement the logic of common sleep before the schedule bean is execute.

Throws:
java.lang.Exception