1 package org.apache.turbine.services.schedule;
2
3
4 /*
5 * Licensed to the Apache Software Foundation (ASF) under one
6 * or more contributor license agreements. See the NOTICE file
7 * distributed with this work for additional information
8 * regarding copyright ownership. The ASF licenses this file
9 * to you under the Apache License, Version 2.0 (the
10 * "License"); you may not use this file except in compliance
11 * with the License. You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing,
16 * software distributed under the License is distributed on an
17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 * KIND, either express or implied. See the License for the
19 * specific language governing permissions and limitations
20 * under the License.
21 */
22
23
24 import java.util.List;
25
26 import org.apache.turbine.services.Service;
27 import org.apache.turbine.util.TurbineException;
28
29 /**
30 * ScheduleService interface.
31 *
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: ScheduleService.java 1692651 2015-07-25 20:33:08Z tv $
35 */
36 public interface ScheduleService
37 extends Service
38 {
39 /** Name of service */
40 String SERVICE_NAME = "SchedulerService";
41
42 /** TR.props key for initially activating the scheduler thread */
43 String INTIALLY_ACTIVE = "enabled";
44
45 /** TR.props key for the logger */
46 String LOGGER_NAME = "scheduler";
47
48 /**
49 * Factory method for a new Job
50 *
51 * Schedule a job to run on a certain point of time.<br>
52 *
53 * Example 1: Run the DefaultScheduledJob at 8:00am every 15th of
54 * the month - <br>
55 *
56 * JobEntry je = newJob(0,0,8,-1,15,"DefaultScheduledJob");<br>
57 *
58 * Example 2: Run the DefaultScheduledJob at 8:00am every day -
59 * <br>
60 *
61 * JobEntry je = newJob(0,0,8,-1,-1,"DefaultScheduledJob");<br>
62 *
63 * Example 3: Run the DefaultScheduledJob every 2 hours. - <br>
64 *
65 * JobEntry je = newJob(0,120,-1,-1,-1,"DefaultScheduledJob");<br>
66 *
67 * Example 4: Run the DefaultScheduledJob every 30 seconds. - <br>
68 *
69 * JobEntry je = newJob(30,-1,-1,-1,-1,"DefaultScheduledJob");<br>
70 *
71 * @param sec Value for entry "seconds".
72 * @param min Value for entry "minutes".
73 * @param hour Value for entry "hours".
74 * @param wd Value for entry "week days".
75 * @param day_mo Value for entry "month days".
76 * @param task Task to execute.
77 *
78 * @return A JobEntry.
79 * @exception TurbineException could not create job
80 */
81 JobEntry newJob(int sec,
82 int min,
83 int hour,
84 int wd,
85 int day_mo,
86 String task) throws TurbineException;
87
88 /**
89 * Get a specific Job from Storage.
90 *
91 * @param oid The int id for the job.
92 * @return A JobEntry.
93 * @exception TurbineException could not retrieve job
94 */
95 JobEntry getJob(int oid)
96 throws TurbineException;
97
98 /**
99 * Add a new job to the queue.
100 *
101 * @param je A JobEntry with the job to add.
102 * @throws TurbineException job could not be added
103 */
104 void addJob(JobEntry je)
105 throws TurbineException;
106
107 /**
108 * Modify a Job.
109 *
110 * @param je A JobEntry with the job to modify
111 * @throws TurbineException job could not be updated
112 */
113 void updateJob(JobEntry je)
114 throws TurbineException;
115
116 /**
117 * Remove a job from the queue.
118 *
119 * @param je A JobEntry with the job to remove.
120 * @exception TurbineException job could not be removed
121 */
122 void removeJob(JobEntry je)
123 throws TurbineException;
124
125 /**
126 * List jobs in the queue. This is used by the scheduler UI.
127 *
128 * @return A List of jobs.
129 */
130 List<? extends JobEntry> listJobs();
131
132 /**
133 * Determines if the scheduler service is currently active.
134 *
135 * @return Status of the scheduler service.
136 */
137 boolean isEnabled();
138
139 /**
140 * Starts the scheduler if not already running.
141 */
142 void startScheduler();
143
144 /**
145 * Stops the scheduler if ti is currently running.
146 */
147 void stopScheduler();
148
149 }