1 package org.apache.turbine.services.schedule;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22 import java.util.Date;
23
24 import org.apache.turbine.util.TurbineException;
25
26 /**
27 * This is a interface for a scheduled job. It does not specify how to configure
28 * when to run, that is left to subclasses. See the JobEntryTorque for an
29 * example of a JobEntry backed by Torque objects.
30 *
31 * @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
32 * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
33 * @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a>
34 * @version $Id: JobEntry.java 1692637 2015-07-25 19:22:57Z tv $
35 */
36 public interface JobEntry extends Comparable<JobEntry>
37 {
38 /**
39 * Sets whether the job is running.
40 *
41 * @param isActive
42 * Whether the job is running.
43 */
44 void setActive(boolean isActive);
45
46 /**
47 * Check to see if job is currently active/running
48 *
49 * @return true if job is currently being run by the worker thread, otherwise
50 * false
51 */
52 boolean isActive();
53
54 /**
55 * Check to see if job is new
56 *
57 * @return true if job is not yet saved, otherwise
58 * false
59 */
60 boolean isNew();
61
62 /**
63 * Get the value of jobId.
64 *
65 * @return int
66 */
67 int getJobId();
68
69 /**
70 * Set the value of jobId.
71 *
72 * @param v new value
73 */
74 void setJobId(int v);
75
76 /**
77 * Get the Task
78 *
79 * @return String
80 */
81 String getTask();
82
83 /**
84 * Set the value of Task
85 *
86 * @param v new value
87 */
88 void setTask(String v);
89
90 /**
91 * Get the next runtime for this job as a long.
92 *
93 * @return The next run time as a long.
94 */
95 long getNextRuntime();
96
97 /**
98 * Gets the next runtime as a date
99 *
100 * @return Next run date
101 */
102 Date getNextRunDate();
103
104 /**
105 * Get the next runtime for this job as a String.
106 *
107 * @return The next run time as a String.
108 */
109 String getNextRunAsString();
110
111 /**
112 * Calculate how long before the next runtime. <br>
113 *
114 * The runtime determines it's position in the job queue. Here's the logic: <br>
115 * 1. Create a date the represents when this job is to run. <br>
116 * 2. If this date has expired, them "roll" appropriate date fields forward
117 * to the next date. <br>
118 * 3. Calculate the diff in time between the current time and the next run
119 * time. <br>
120 *
121 * @exception TurbineException
122 * a generic exception.
123 */
124 void calcRunTime() throws TurbineException;
125
126 }