org.apache.turbine.services.schedule
Class JobEntry

java.lang.Object
  |
  +--org.apache.turbine.om.BaseObject
        |
        +--org.apache.turbine.services.schedule.JobEntry
All Implemented Interfaces:
Persistent, java.io.Serializable

public class JobEntry
extends BaseObject

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

Version:
$Id: JobEntry.java,v 1.11.10.5 2001/06/01 01:34:20 jvanzyl Exp $
Author:
Dave Bryson
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.apache.turbine.om.BaseObject
NEW_ID
 
Constructor Summary
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.
 boolean equals(java.lang.Object je)
          Compare this Job with another.
 int getDay_of_month()
          Get the value of day_of_month.
 java.lang.String getEmail()
          Return the e-mail address for notification.
 int getHour()
          Get the value of hour.
 int getMinute()
          Get the value of minute.
 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.
 java.util.Hashtable getProperty()
          Get extra job properties
 int getSecond()
          Get the value of second.
 java.lang.String getTask()
          Return the task for this job.
 int getWeekday()
          Get the value of weekday.
 boolean isActive()
          Check to see if job is currently active/running
 void save()
          Self-preservation.
 void setActive(boolean isActive)
          Sets whether the job is running.
 void setDay_of_month(int v)
          Set the value of day_of_month.
 void setEmail(java.lang.String mail)
          The address to send mail notifications to.
 void setHour(int v)
          Set the value of hour.
 void setMinute(int v)
          Set the value of minute.
 void setProperty(java.util.Hashtable prop)
          Set job properties
 void setSecond(int v)
          Set the value of second.
 void setTask(java.lang.String task)
          Set the task name for this job.
 void setWeekday(int v)
          Set the value of weekday.
 
Methods inherited from class org.apache.turbine.om.BaseObject
equals, getByName, getByPeerName, getByPosition, getPrimaryKey, getPrimaryKeyAsBigDecimal, getPrimaryKeyAsInt, getPrimaryKeyAsLong, getPrimaryKeyAsString, hashCode, isModified, isNew, resetModified, setModified, setNew, setPrimaryKey, setPrimaryKey, setPrimaryKey, setPrimaryKey, setPrimaryKey
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

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

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

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.

setEmail

public void setEmail(java.lang.String mail)
The address to send mail notifications to. This just holds the address. The ScheduledJob should handle actually sending the mail.

Parameters:
mail - The email address.

getEmail

public java.lang.String getEmail()
Return the e-mail address for notification.

Returns:
The email address.

getTask

public java.lang.String getTask()
Return the task for this job. A task name is the Class name of the ScheduledJob created by the programmer.

Returns:
A String with the name of the scheduled job.

setTask

public void setTask(java.lang.String task)
Set the task name for this job. A task name is the Class name of the ScheduledJob created by the programmer.

Parameters:
task - A String with the name of the job.

getSecond

public int getSecond()
Get the value of second.

Returns:
Value of second.

setSecond

public void setSecond(int v)
Set the value of second.

Parameters:
v - Value to assign to second.

getMinute

public int getMinute()
Get the value of minute.

Returns:
Value of minute.

setMinute

public void setMinute(int v)
Set the value of minute.

Parameters:
v - Value to assign to minute.

getHour

public int getHour()
Get the value of hour.

Returns:
Value of hour.

setHour

public void setHour(int v)
Set the value of hour.

Parameters:
v - Value to assign to hour.

getWeekday

public int getWeekday()
Get the value of weekday.

Returns:
Value of weekday.

setWeekday

public void setWeekday(int v)
Set the value of weekday.

Parameters:
v - Value to assign to weekday.

getDay_of_month

public int getDay_of_month()
Get the value of day_of_month.

Returns:
Value of day_of_month.

setDay_of_month

public void setDay_of_month(int v)
Set the value of day_of_month.

Parameters:
v - Value to assign to day_of_month.

save

public void save()
          throws java.lang.Exception
Self-preservation.

Specified by:
save in interface Persistent
Overrides:
save in class BaseObject
Throws:
Exception, - a generic exception.
java.lang.Exception

equals

public boolean equals(java.lang.Object je)
Compare this Job with another.

Overrides:
equals in class BaseObject
Parameters:
je - The JobEntry object to compare to.
Returns:
True if they're the same.

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

setProperty

public void setProperty(java.util.Hashtable prop)
Set job properties


getProperty

public java.util.Hashtable getProperty()
Get extra job properties



Copyright © 2000-2003 Apache Software Foundation. All Rights Reserved.