org.sape.carbon.services.scheduler
Class FixedRateTask

java.lang.Object
  |
  +--org.sape.carbon.services.scheduler.AbstractTask
        |
        +--org.sape.carbon.services.scheduler.FixedRateTask

class FixedRateTask
extends AbstractTask

Utility class used to interperet FixedRateTaskConfiguration and schedule fixed rate tasks. Copyright 2002 Sapient

Since:
carbon 1.0
Version:
$Revision: 1.16 $($Author: dvoet $ / $Date: 2003/11/20 21:46:15 $)
Author:
Douglas Voet, June 2002

Nested Class Summary
 
Nested classes inherited from class org.sape.carbon.services.scheduler.AbstractTask
 
Field Summary
private static long EVERY_DAY
          Milliseconds for one day.
private static long EVERY_HOUR
          Milliseconds for one hour.
private static long EVERY_MINUTE
          Milliseconds for one minute.
private static long EVERY_MONTH
          Milliseconds for one month.
private static long EVERY_WEEK
          Milliseconds for one week.
private static long EVERY_YEAR
          Milliseconds for one year.
private  org.apache.commons.logging.Log log
          Provides a handle to Apache-commons logger
private static int MAX_DAY_OF_MONTH
          Maximum valid day of month value.
private static int MAX_HOUR
          Maximum valid hour value.
private static int MAX_MINUTE
          Maximum valid minute value.
private static int MIN_DAY_OF_MONTH
          Mininum valid day of month value.
private static int MIN_HOUR
          Mininum valid hour value.
private static int MIN_MINUTE
          Mininum valid minute value.
private  long period
          Holds the period of how often the task will execute.
private  Date time
          Holds the first run time of the task.
 
Fields inherited from class org.sape.carbon.services.scheduler.AbstractTask
 
Constructor Summary
protected FixedRateTask(FixedRateTaskConfiguration taskConfiguration, ThreadPool threadPool)
          This constructor determines the starting time and date and the repeat period of the task.
 
Method Summary
private  boolean isWithinRange(int value, int min, int max)
          Checks if a value is in given range.
 void schedule(Timer timer)
          Method called to schedule this task on the given Timer.
private  void validate(String configName, String attributeName, Integer value, int minValue, int maxValue)
          Checks to make sure that value is within min and max values
 
Methods inherited from class org.sape.carbon.services.scheduler.AbstractTask
getTask
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private org.apache.commons.logging.Log log
Provides a handle to Apache-commons logger


MIN_MINUTE

private static final int MIN_MINUTE
Mininum valid minute value.

See Also:
Constant Field Values

MAX_MINUTE

private static final int MAX_MINUTE
Maximum valid minute value.

See Also:
Constant Field Values

MIN_HOUR

private static final int MIN_HOUR
Mininum valid hour value.

See Also:
Constant Field Values

MAX_HOUR

private static final int MAX_HOUR
Maximum valid hour value.

See Also:
Constant Field Values

MIN_DAY_OF_MONTH

private static final int MIN_DAY_OF_MONTH
Mininum valid day of month value.

See Also:
Constant Field Values

MAX_DAY_OF_MONTH

private static final int MAX_DAY_OF_MONTH
Maximum valid day of month value.

See Also:
Constant Field Values

EVERY_MINUTE

private static final long EVERY_MINUTE
Milliseconds for one minute.

See Also:
Constant Field Values

EVERY_HOUR

private static final long EVERY_HOUR
Milliseconds for one hour.

See Also:
Constant Field Values

EVERY_DAY

private static final long EVERY_DAY
Milliseconds for one day.

See Also:
Constant Field Values

EVERY_WEEK

private static final long EVERY_WEEK
Milliseconds for one week.

See Also:
Constant Field Values

EVERY_MONTH

private static final long EVERY_MONTH
Milliseconds for one month.

See Also:
Constant Field Values

EVERY_YEAR

private static final long EVERY_YEAR
Milliseconds for one year.

See Also:
Constant Field Values

period

private long period
Holds the period of how often the task will execute.


time

private Date time
Holds the first run time of the task.

Constructor Detail

FixedRateTask

protected FixedRateTask(FixedRateTaskConfiguration taskConfiguration,
                        ThreadPool threadPool)
This constructor determines the starting time and date and the repeat period of the task. See the class javadoc for FixedRateTaskConfiguration for valid configuration and related behavior.

Parameters:
taskConfiguration -
See Also:
FixedRateTaskConfiguration
Method Detail

schedule

public void schedule(Timer timer)
Description copied from class: AbstractTask
Method called to schedule this task on the given Timer. Implementations are responsible for determining when to schedule this task, its repeat period and how it is scheduled (fixed rate or delay). To this end, one of the schedule mehtods on timer should be called.

Specified by:
schedule in class AbstractTask
Parameters:
timer - Timer on which this task should be scheduled
See Also:
AbstractTask.schedule(Timer)

validate

private void validate(String configName,
                      String attributeName,
                      Integer value,
                      int minValue,
                      int maxValue)
Checks to make sure that value is within min and max values

Parameters:
configName - configuration the value being validated comes from
attributeName - name of attribute being validated
value - the value of the attribute
minValue - the minimum valid value
maxValue - the maximum valid value

isWithinRange

private boolean isWithinRange(int value,
                              int min,
                              int max)
Checks if a value is in given range.

Parameters:
value - the value to check
min - the mininum the value should be
max - the maximum the value should be
Returns:
if the value is with the range


Copyright 1999-2003 Sapient Corporation. All Rights Reserved.