org.apache.jetspeed.scheduler
Class JobEntry

java.lang.Object
  extended by org.apache.jetspeed.scheduler.BaseJobEntry
      extended by org.apache.jetspeed.scheduler.JobEntry
All Implemented Interfaces:
java.lang.Comparable

public class JobEntry
extends BaseJobEntry
implements java.lang.Comparable

This is a wrapper for a scheduled job. It is modeled after the Unix scheduler cron.

Version:
$Id: JobEntry.java 516448 2007-03-09 16:25:47Z ate $
Author:
Dave Bryson

Field Summary
 
Fields inherited from class org.apache.jetspeed.scheduler.BaseJobEntry
dayOfMonth, email, jobHour, jobId, jobMinute, jobSecond, task, weekDay
 
Constructor Summary
JobEntry()
          default constructor
JobEntry(int sec, int min, int hour, int wd, int day_mo, java.lang.String task)
          Constuctor.
 
Method Summary
 void calcRunTime()
          Calculate how long before the next runtime.
The runtime determines it's position in the job queue.
 int compareTo(java.lang.Object je)
          Compares one JobEntry to another JobEntry based on the JobId
 java.lang.String getNextRunAsString()
          Get the next runtime for this job as a String.
 long getNextRuntime()
          Get the next runtime for this job as a long.
 boolean isActive()
          Check to see if job is currently active/running
 void setActive(boolean isActive)
          Sets whether the job is running.
 
Methods inherited from class org.apache.jetspeed.scheduler.BaseJobEntry
getDayOfMonth, getEmail, getHour, getJobId, getMinute, getSecond, getTask, getWeekDay, setDayOfMonth, setEmail, setHour, setJobId, setMinute, setSecond, setTask, setWeekDay
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JobEntry

public JobEntry()
default constructor


JobEntry

public JobEntry(int sec,
                int min,
                int hour,
                int wd,
                int day_mo,
                java.lang.String task)
         throws java.lang.Exception
Constuctor. Schedule a job to run on a certain point of time.
Example 1: Run the DefaultScheduledJob at 8:00am every 15th of the month -
JobEntry je = new JobEntry(0,0,8,15,"DefaultScheduledJob");
Example 2: Run the DefaultScheduledJob at 8:00am every day -
JobEntry je = new JobEntry(0,0,8,-1,"DefaultScheduledJob");
Example 3: Run the DefaultScheduledJob every 2 hours. -
JobEntry je = new JobEntry(0,120,-1,-1,"DefaultScheduledJob");
Example 4: Run the DefaultScheduledJob every 30 seconds. -
JobEntry je = new JobEntry(30,-1,-1,-1,"DefaultScheduledJob");

Parameters:
sec - Value for entry "seconds".
min - Value for entry "minutes".
hour - Value for entry "hours".
wd - Value for entry "week days".
day_mo - Value for entry "month days".
task - Task to execute.
Throws:
Exception, - a generic exception.
java.lang.Exception
Method Detail

compareTo

public int compareTo(java.lang.Object je)
Compares one JobEntry to another JobEntry based on the JobId

Specified by:
compareTo in interface java.lang.Comparable

setActive

public void setActive(boolean isActive)
Sets whether the job is running.

Parameters:
isActive - Whether the job is running.

isActive

public boolean isActive()
Check to see if job is currently active/running

Returns:
true if job is currently geing run by the workerthread, otherwise false

getNextRuntime

public long getNextRuntime()
Get the next runtime for this job as a long.

Returns:
The next run time as a long.

getNextRunAsString

public java.lang.String getNextRunAsString()
Get the next runtime for this job as a String.

Returns:
The next run time as a String.

calcRunTime

public void calcRunTime()
                 throws java.lang.Exception
Calculate how long before the next runtime.
The runtime determines it's position in the job queue. Here's the logic:
1. Create a date the represents when this job is to run.
2. If this date has expired, them "roll" appropriate date fields forward to the next date.
3. Calculate the diff in time between the current time and the next run time.

Throws:
Exception, - a generic exception.
java.lang.Exception


Copyright © 1999-2009 Apache Software Foundation. All Rights Reserved.