KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > components > cron > JobScheduler


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.cocoon.components.cron;
17
18 import java.util.Date JavaDoc;
19 import java.util.Map JavaDoc;
20 import java.util.NoSuchElementException JavaDoc;
21
22 import org.apache.avalon.framework.CascadingException;
23 import org.apache.avalon.framework.parameters.Parameters;
24
25 /**
26  * This component schedules jobs.
27  *
28  * @author <a HREF="mailto:giacomo@apache.org">Giacomo Pati</a>
29  * @version CVS $Id: JobScheduler.java 56042 2004-10-30 16:14:17Z giacomo $
30  *
31  * @since 2.1.1
32  */

33 public interface JobScheduler {
34     /** The role of a JobScheduler */
35     String JavaDoc ROLE = JobScheduler.class.getName();
36
37     /**
38      * Get the names of all scheduled jobs.
39      *
40      * @return state of execution successfullness
41      */

42     String JavaDoc[] getJobNames();
43
44     /**
45      * Get the JobSchedulerEntry for a scheduled job
46      *
47      * @return the entry
48      */

49     JobSchedulerEntry getJobSchedulerEntry(String JavaDoc jobname);
50
51     /**
52      * Schedule a time based job. Note that if a job with the same name has already beed added it is overwritten.
53      *
54      * @param name the name of the job
55      * @param jobrole The Avalon components role name of the job itself
56      * @param schedulingExpression the time specification using a scheduling expression
57      * @param canRunConcurrently whether this job can run even previous scheduled runs are still running
58      */

59     void addJob(String JavaDoc name, String JavaDoc jobrole, String JavaDoc schedulingExpression, boolean canRunConcurrently)
60     throws CascadingException;
61
62     /**
63      * Schedule a time based job. Note that if a job with the same name has already beed added it is overwritten.
64      *
65      * @param name the name of the job
66      * @param jobrole The Avalon components role name of the job itself
67      * @param schedulingExpression the time specification using a scheduling expression
68      * @param canRunConcurrently whether this job can run even previous scheduled runs are still running
69      * @param params Additional Parameters to setup CronJob
70      * @param objects A Map with additional object to setup CronJob
71      */

72     void addJob(String JavaDoc name, String JavaDoc jobrole, String JavaDoc schedulingExpression, boolean canRunConcurrently, Parameters params, Map JavaDoc objects)
73     throws CascadingException;
74
75     /**
76      * Schedule a time based job. Note that if a job with the same name has already beed added it is overwritten.
77      *
78      * @param name the name of the job
79      * @param job The job object itself. It must implement either CronJob, Runnable or might also be an implementation
80      * specific class (i.e. org.quartz.Job)
81      * @param schedulingExpression the time specification using a scheduling expression
82      * @param canRunConcurrently whether this job can run even previous scheduled runs are still running
83      */

84     void addJob(String JavaDoc name, Object JavaDoc job, String JavaDoc schedulingExpression, boolean canRunConcurrently)
85     throws CascadingException;
86
87     /**
88      * Schedule a job. Note that if a job with the same name has already beed added it is overwritten.
89      *
90      * @param name the name of the job
91      * @param job The job object itself. It must implement either CronJob, Runnable or might also be an implementation
92      * specific class (i.e. org.quartz.Job)
93      * @param schedulingExpression the time specification using a scheduling expression
94      * @param canRunConcurrently whether this job can run even previous scheduled runs are still running
95      * @param params Additional Parameters to setup CronJob
96      * @param objects A Map with additional object to setup CronJob
97      */

98     void addJob(String JavaDoc name, Object JavaDoc job, String JavaDoc schedulingExpression, boolean canRunConcurrently, Parameters params, Map JavaDoc objects)
99     throws CascadingException;
100
101     /**
102      * Schedule a periodic job. The job is started the first time when the period has passed. Note that if a job with
103      * the same name has already beed added it is overwritten.
104      *
105      * @param name the name of the job
106      * @param jobrole The Avalon components role name of the job itself
107      * @param period Every period seconds this job is started
108      * @param canRunConcurrently whether this job can run even previous scheduled runs are still running
109      * @param params Additional Parameters to setup CronJob
110      * @param objects A Map with additional object to setup CronJob
111      */

112     void addPeriodicJob(String JavaDoc name, String JavaDoc jobrole, long period, boolean canRunConcurrently, Parameters params,
113                         Map JavaDoc objects)
114     throws CascadingException;
115     
116     /**
117      * Schedule a periodic job. The job is started the first time when the period has passed. Note that if a job with
118      * the same name has already beed added it is overwritten.
119      *
120      * @param name the name of the job
121      * @param job The job object itself. It must implement either CronJob, Runnable or might also be an implementation
122      * specific class (i.e. org.quartz.Job)
123      * @param period Every period seconds this job is started
124      * @param canRunConcurrently whether this job can run even previous scheduled runs are still running
125      * @param params Additional Parameters to setup CronJob
126      * @param objects A Map with additional object to setup CronJob
127      */

128     void addPeriodicJob(String JavaDoc name, Object JavaDoc job, long period, boolean canRunConcurrently, Parameters params,
129                         Map JavaDoc objects)
130     throws CascadingException;
131
132     /**
133      * Fire a job once immediately
134      *
135      * @param jobrole The Avalon components role name of the job itself
136      *
137      * @return success state adding the job
138      */

139     boolean fireJob(String JavaDoc jobrole);
140
141     /**
142      * Fire a CronJob once immediately
143      *
144      * @param job The job object itself. It must implement either CronJob, Runnable or might also be an implementation
145      * specific class (i.e. org.quartz.Job)
146      *
147      * @return whether the job has been successfully started
148      */

149     boolean fireJob(Object JavaDoc job);
150
151     /**
152      * Fire a job once immediately
153      *
154      * @param jobrole The Avalon components role name of the job itself
155      * @param params Additional Parameters to setup CronJob
156      * @param objects A Map with additional object to setup CronJob
157      *
158      * @return whether the job has been successfully started
159      */

160     boolean fireJob(String JavaDoc jobrole, Parameters params, Map JavaDoc objects)
161     throws CascadingException;
162
163     /**
164      * Fire a job once immediately
165      *
166      * @param job The job object itself. It must implement either CronJob, Runnable or might also be an implementation
167      * specific class (i.e. org.quartz.Job)
168      * @param params Additional Parameters to setup CronJob
169      * @param objects A Map with additional object to setup CronJob
170      *
171      * @return whether the job has been successfully started
172      */

173     boolean fireJob(Object JavaDoc job, Parameters params, Map JavaDoc objects)
174     throws CascadingException;
175
176     /**
177      * Fire a job once at a specific date Note that if a job with the same name has already beed added it is
178      * overwritten.
179      *
180      * @param date The date this job should be scheduled
181      * @param name the name of the job
182      * @param jobrole The Avalon components role name of the job itself
183      */

184     void fireJobAt(Date JavaDoc date, String JavaDoc name, String JavaDoc jobrole)
185     throws CascadingException;
186
187     /**
188      * Fire a job once at a specific date Note that if a job with the same name has already beed added it is
189      * overwritten.
190      *
191      * @param date The date this job should be scheduled
192      * @param name the name of the job
193      * @param jobrole The Avalon components role name of the job itself
194      * @param params Additional Parameters to setup CronJob
195      * @param objects A Map with additional object to setup CronJob
196      */

197     void fireJobAt(Date JavaDoc date, String JavaDoc name, String JavaDoc jobrole, Parameters params, Map JavaDoc objects)
198     throws CascadingException;
199
200     /**
201      * Fire a job once at a specific date Note that if a job with the same name has already beed added it is
202      * overwritten.
203      *
204      * @param date The date this job should be scheduled
205      * @param name the name of the job
206      * @param job The job object itself. It must implement either CronJob, Runnable or might also be an implementation
207      * specific class (i.e. org.quartz.Job)
208      */

209     void fireJobAt(Date JavaDoc date, String JavaDoc name, Object JavaDoc job)
210     throws CascadingException;
211
212     /**
213      * Fire a job once at a specific date Note that if a job with the same name has already beed added it is
214      * overwritten.
215      *
216      * @param date The date this job should be scheduled
217      * @param name the name of the job
218      * @param job The job object itself. It must implement either CronJob, Runnable or might also be an implementation
219      * specific class (i.e. org.quartz.Job)
220      * @param params Additional Parameters to setup CronJob
221      * @param objects A Map with additional object to setup CronJob
222      */

223     void fireJobAt(Date JavaDoc date, String JavaDoc name, Object JavaDoc job, Parameters params, Map JavaDoc objects)
224     throws CascadingException;
225
226     /**
227      * Remove a scheduled job by name.
228      *
229      * @param name the name of the job
230      */

231     void removeJob(String JavaDoc name)
232     throws NoSuchElementException JavaDoc;
233 }
234
Popular Tags