org.apache.turbine.services.schedule

## Class AbstractJobEntry

- java.lang.Object
- - org.apache.turbine.services.schedule.AbstractJobEntry

- All Implemented Interfaces:
    Comparable<JobEntry>, JobEntry
  Direct Known Subclasses:
    BaseJobEntryTorque, JobEntryNonPersistent

      public abstract class AbstractJobEntry
      extends Object
      implements JobEntry

  This class provides the basic implementation of common features for a scheduled job entry.
  Author:
    Thomas Vandahl

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected static class` | `AbstractJobEntry.ScheduleType` schedule types

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static org.apache.commons.logging.Log` | `log` Logging

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractJobEntry()` Default constructor
    `AbstractJobEntry(int sec, int min, int hour, int wd, int day_mo, String task)` Constructor.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `calcRunTime()` Calculate how long before the next runtime.
    `int` | `compareTo(JobEntry je)` Used for ordering Jobentries Note: this comparator imposes orderings that are inconsistent with equals.
    `abstract int` | `getDayOfMonth()` Get the value of dayOfMonth.
    `abstract int` | `getHour()` Get the value of hour.
    `abstract int` | `getJobId()` Get the value of jobId.
    `abstract int` | `getMinute()` Get the value of minute.
    `String` | `getNextRunAsString()` Get the next runtime for this job as a String.
    `Date` | `getNextRunDate()` Gets the next runtime as a date
    `long` | `getNextRuntime()` Get the next runtime for this job as a long.
    `abstract int` | `getSecond()` Get the value of second.
    `abstract String` | `getTask()` Get the value of task.
    `abstract int` | `getWeekDay()` Get the value of weekDay.
    `boolean` | `isActive()` Check to see if job is currently active/running
    `void` | `setActive(boolean isActive)` Sets whether the job is running.
    `abstract void` | `setDayOfMonth(int v)` Set the value of dayOfMonth.
    `abstract void` | `setHour(int v)` Set the value of hour.
    `abstract void` | `setJobId(int v)` Set the value of jobId.
    `abstract void` | `setMinute(int v)` Set the value of minute.
    `abstract void` | `setSecond(int v)` Set the value of second.
    `abstract void` | `setTask(String v)` Set the value of task.
    `abstract void` | `setWeekDay(int v)` Set the value of weekDay.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.apache.turbine.services.schedule.JobEntry

      `isNew`

- - ### Field Detail

    - #### log

          protected static org.apache.commons.logging.Log log

      Logging

  - ### Constructor Detail

    - #### AbstractJobEntry

          public AbstractJobEntry()

      Default constructor

    - #### AbstractJobEntry

          public AbstractJobEntry(int sec,
                          int min,
                          int hour,
                          int wd,
                          int day_mo,
                          String task)
                           throws TurbineException

      Constructor. 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,-1,15,"DefaultScheduledJob");
      Example 2: Run the DefaultScheduledJob at 8:00am every day -
      JobEntry je = new JobEntry(0,0,8,-1,-1,"DefaultScheduledJob");
      Example 3: Run the DefaultScheduledJob every 2 hours. -
      JobEntry je = new JobEntry(0,120,-1,-1,-1,"DefaultScheduledJob");
      Example 4: Run the DefaultScheduledJob every 30 seconds. -
      JobEntry je = new JobEntry(30,-1,-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:
        `TurbineException` - a generic exception.

  - ### Method Detail

    - #### compareTo

          public int compareTo(JobEntry je)

      Used for ordering Jobentries Note: this comparator imposes orderings that are inconsistent with equals.
      Specified by:
        `compareTo` in interface `Comparable<JobEntry>`
      Parameters:
        `je` - The first `JobEntry` object.
      Returns:
        An `int` indicating the result of the comparison.

    - #### setActive

          public void setActive(boolean isActive)

      Sets whether the job is running.
      Specified by:
        `setActive` in interface `JobEntry`
      Parameters:
        `isActive` - Whether the job is running.

    - #### isActive

          public boolean isActive()

      Check to see if job is currently active/running
      Specified by:
        `isActive` in interface `JobEntry`
      Returns:
        true if job is currently queuing run by the worker thread, otherwise false

    - #### getNextRuntime

          public long getNextRuntime()

      Get the next runtime for this job as a long.
      Specified by:
        `getNextRuntime` in interface `JobEntry`
      Returns:
        The next run time as a long.

    - #### getNextRunDate

          public Date getNextRunDate()

      Gets the next runtime as a date
      Specified by:
        `getNextRunDate` in interface `JobEntry`
      Returns:
        Next run date

    - #### getNextRunAsString

          public String getNextRunAsString()

      Get the next runtime for this job as a String.
      Specified by:
        `getNextRunAsString` in interface `JobEntry`
      Returns:
        The next run time as a String.

    - #### calcRunTime

          public void calcRunTime()
                           throws TurbineException

      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.
      Specified by:
        `calcRunTime` in interface `JobEntry`
      Throws:
        `TurbineException` - a generic exception.

    - #### getJobId

          public abstract int getJobId()

      Get the value of jobId.
      Specified by:
        `getJobId` in interface `JobEntry`
      Returns:
        int

    - #### setJobId

          public abstract void setJobId(int v)

      Set the value of jobId.
      Specified by:
        `setJobId` in interface `JobEntry`
      Parameters:
        `v` - new value

    - #### getSecond

          public abstract int getSecond()

      Get the value of second.
      Returns:
        int

    - #### setSecond

          public abstract void setSecond(int v)

      Set the value of second.
      Parameters:
        `v` - new value

    - #### getMinute

          public abstract int getMinute()

      Get the value of minute.
      Returns:
        int

    - #### setMinute

          public abstract void setMinute(int v)

      Set the value of minute.
      Parameters:
        `v` - new value

    - #### getHour

          public abstract int getHour()

      Get the value of hour.
      Returns:
        int

    - #### setHour

          public abstract void setHour(int v)

      Set the value of hour.
      Parameters:
        `v` - new value

    - #### getWeekDay

          public abstract int getWeekDay()

      Get the value of weekDay.
      Returns:
        int

    - #### setWeekDay

          public abstract void setWeekDay(int v)

      Set the value of weekDay.
      Parameters:
        `v` - new value

    - #### getDayOfMonth

          public abstract int getDayOfMonth()

      Get the value of dayOfMonth.
      Returns:
        int

    - #### setDayOfMonth

          public abstract void setDayOfMonth(int v)

      Set the value of dayOfMonth.
      Parameters:
        `v` - new value

    - #### getTask

          public abstract String getTask()

      Get the value of task.
      Specified by:
        `getTask` in interface `JobEntry`
      Returns:
        String

    - #### setTask

          public abstract void setTask(String v)

      Set the value of task.
      Specified by:
        `setTask` in interface `JobEntry`
      Parameters:
        `v` - new value

Copyright © 2000-2015 The Apache Software Foundation. All Rights Reserved.