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
23 import java.util.Date;
24
25 import org.apache.torque.om.Persistent;
26 import org.apache.turbine.util.TurbineException;
27
28 /**
29 * This is a interface for a scheduled job. It does not specify how to
30 * configure when to run, that is left to subclasses. See the JobEntryTorque
31 * for an example of a JobEntry backed by Torque objects.
32 *
33 * @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
34 * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
35 * @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a>
36 * @version $Id: JobEntryInterface.java 1066938 2011-02-03 20:14:53Z ludwig $
37 */
38 public interface JobEntryInterface extends Comparable<JobEntry>, Persistent
39 {
40
41 /**
42 * Used for ordering Jobentries Note: this comparator imposes orderings
43 * that are inconsistent with equals.
44 *
45 * @param je The first <code>JobEntry</code> object.
46 * @return An <code>int</code> indicating the result of the comparison.
47 */
48 public int compareTo(Object je);
49
50 /**
51 * Sets whether the job is running.
52 *
53 * @param isActive Whether the job is running.
54 */
55 public void setActive(boolean isActive);
56
57 /**
58 * Check to see if job is currently active/running
59 *
60 * @return true if job is currently being run by the workerthread,
61 * otherwise false
62 */
63 public boolean isActive();
64
65
66 /**
67 * Get the Task
68 *
69 * @return String
70 */
71 public String getTask();
72
73 /**
74 * Set the value of Task
75 *
76 * @param v new value
77 */
78 public void setTask(String v);
79 /**
80 * Get the next runtime for this job as a long.
81 *
82 * @return The next run time as a long.
83 */
84 public long getNextRuntime();
85
86 /**
87 * Gets the next runtime as a date
88 *
89 * @return Next run date
90 */
91 public Date getNextRunDate();
92
93 /**
94 * Get the next runtime for this job as a String.
95 *
96 * @return The next run time as a String.
97 */
98 public String getNextRunAsString();
99
100 /**
101 * Calculate how long before the next runtime. <br>
102 *
103 * The runtime determines it's position in the job queue. Here's the logic:
104 * <br>
105 * 1. Create a date the represents when this job is to run. <br>
106 * 2. If this date has expired, them "roll" appropriate date fields
107 * forward to the next date. <br>
108 * 3. Calculate the diff in time between the current time and the next run
109 * time. <br>
110 *
111 * @exception TurbineException a generic exception.
112 */
113 public void calcRunTime() throws TurbineException;
114
115 }