KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > quartz > impl > jdbcjobstore > DriverDelegate


1 /*
2  * Copyright 2004-2005 OpenSymphony
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy
6  * 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, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations
14  * under the License.
15  *
16  */

17
18 /*
19  * Previously Copyright (c) 2001-2004 James House
20  */

21 package org.quartz.impl.jdbcjobstore;
22
23 import java.io.IOException JavaDoc;
24 import java.sql.Connection JavaDoc;
25 import java.sql.SQLException JavaDoc;
26 import java.util.List JavaDoc;
27 import java.util.Set JavaDoc;
28
29 import org.quartz.Calendar;
30 import org.quartz.CronTrigger;
31 import org.quartz.JobDataMap;
32 import org.quartz.JobDetail;
33 import org.quartz.SimpleTrigger;
34 import org.quartz.Trigger;
35 import org.quartz.spi.ClassLoadHelper;
36 import org.quartz.utils.Key;
37 import org.quartz.utils.TriggerStatus;
38
39 /**
40  * <p>
41  * This is the base interface for all driver delegate classes.
42  * </p>
43  *
44  * <p>
45  * This interface is very similar to the <code>{@link
46  * org.quartz.spi.JobStore}</code>
47  * interface except each method has an additional <code>{@link java.sql.Connection}</code>
48  * parameter.
49  * </p>
50  *
51  * <p>
52  * Unless a database driver has some <strong>extremely-DB-specific</strong>
53  * requirements, any DriverDelegate implementation classes should extend the
54  * <code>{@link org.quartz.impl.jdbcjobstore.StdJDBCDelegate}</code> class.
55  * </p>
56  *
57  * @author <a HREF="mailto:jeff@binaryfeed.org">Jeffrey Wescott</a>
58  * @author James House
59  */

60 interface DriverDelegate {
61
62     /*
63      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
64      *
65      * Interface.
66      *
67      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
68      */

69
70     //---------------------------------------------------------------------------
71
// startup / recovery
72
//---------------------------------------------------------------------------
73
/**
74      * <p>
75      * Update all triggers having one of the two given states, to the given new
76      * state.
77      * </p>
78      *
79      * @param conn
80      * the DB Connection
81      * @param newState
82      * the new state for the triggers
83      * @param oldState1
84      * the first old state to update
85      * @param oldState2
86      * the second old state to update
87      * @return number of rows updated
88      */

89     int updateTriggerStatesFromOtherStates(Connection JavaDoc conn,
90         String JavaDoc newState, String JavaDoc oldState1, String JavaDoc oldState2)
91         throws SQLException JavaDoc;
92
93     /**
94      * <p>
95      * Get the names of all of the triggers that have misfired - according to
96      * the given timestamp.
97      * </p>
98      *
99      * @param conn
100      * the DB Connection
101      * @return an array of <code>{@link
102      * org.quartz.utils.Key}</code> objects
103      */

104     Key[] selectMisfiredTriggers(Connection JavaDoc conn, long ts)
105         throws SQLException JavaDoc;
106
107     /**
108      * <p>
109      * Get the names of all of the triggers in the given state that have
110      * misfired - according to the given timestamp.
111      * </p>
112      *
113      * @param conn
114      * the DB Connection
115      * @return an array of <code>{@link
116      * org.quartz.utils.Key}</code> objects
117      */

118     Key[] selectMisfiredTriggersInState(Connection JavaDoc conn, String JavaDoc state,
119         long ts) throws SQLException JavaDoc;
120     
121     /**
122      * <p>
123      * Get the names of all of the triggers in the given states that have
124      * misfired - according to the given timestamp. No more than count will
125      * be returned.
126      * </p>
127      *
128      * @param conn the DB Connection
129      * @param count the most misfired triggers to return, negative for all
130      * @param resultList Output parameter. A List of
131      * <code>{@link org.quartz.utils.Key}</code> objects. Must not be null.
132      *
133      * @return Whether there are more misfired triggers left to find beyond
134      * the given count.
135      */

136     boolean selectMisfiredTriggersInStates(Connection JavaDoc conn, String JavaDoc state1, String JavaDoc state2,
137         long ts, int count, List JavaDoc resultList) throws SQLException JavaDoc;
138     
139     /**
140      * <p>
141      * Get the number of triggers in the given states that have
142      * misfired - according to the given timestamp.
143      * </p>
144      *
145      * @param conn the DB Connection
146      */

147     int countMisfiredTriggersInStates(
148         Connection JavaDoc conn, String JavaDoc state1, String JavaDoc state2, long ts) throws SQLException JavaDoc;
149
150     /**
151      * <p>
152      * Get the names of all of the triggers in the given group and state that
153      * have misfired - according to the given timestamp.
154      * </p>
155      *
156      * @param conn
157      * the DB Connection
158      * @return an array of <code>{@link
159      * org.quartz.utils.Key}</code> objects
160      */

161     Key[] selectMisfiredTriggersInGroupInState(Connection JavaDoc conn,
162         String JavaDoc groupName, String JavaDoc state, long ts) throws SQLException JavaDoc;
163     
164
165     /**
166      * <p>
167      * Select all of the triggers for jobs that are requesting recovery. The
168      * returned trigger objects will have unique "recoverXXX" trigger names and
169      * will be in the <code>{@link
170      * org.quartz.Scheduler}.DEFAULT_RECOVERY_GROUP</code>
171      * trigger group.
172      * </p>
173      *
174      * <p>
175      * In order to preserve the ordering of the triggers, the fire time will be
176      * set from the <code>COL_FIRED_TIME</code> column in the <code>TABLE_FIRED_TRIGGERS</code>
177      * table. The caller is responsible for calling <code>computeFirstFireTime</code>
178      * on each returned trigger. It is also up to the caller to insert the
179      * returned triggers to ensure that they are fired.
180      * </p>
181      *
182      * @param conn
183      * the DB Connection
184      * @return an array of <code>{@link org.quartz.Trigger}</code> objects
185      */

186     Trigger[] selectTriggersForRecoveringJobs(Connection JavaDoc conn)
187         throws SQLException JavaDoc, IOException JavaDoc, ClassNotFoundException JavaDoc;
188
189     /**
190      * <p>
191      * Delete all fired triggers.
192      * </p>
193      *
194      * @param conn
195      * the DB Connection
196      * @return the number of rows deleted
197      */

198     int deleteFiredTriggers(Connection JavaDoc conn) throws SQLException JavaDoc;
199
200     /**
201      * <p>
202      * Delete all fired triggers of the given instance.
203      * </p>
204      *
205      * @param conn
206      * the DB Connection
207      * @return the number of rows deleted
208      */

209     int deleteFiredTriggers(Connection JavaDoc conn, String JavaDoc instanceId)
210         throws SQLException JavaDoc;
211
212     /**
213      * <p>
214      * Delete all volatile fired triggers.
215      * </p>
216      *
217      * @param conn
218      * the DB Connection
219      * @return the number of rows deleted
220      */

221     int deleteVolatileFiredTriggers(Connection JavaDoc conn) throws SQLException JavaDoc;
222
223     /**
224      * <p>
225      * Get the names of all of the triggers that are volatile.
226      * </p>
227      *
228      * @param conn
229      * the DB Connection
230      * @return an array of <code>{@link
231      * org.quartz.utils.Key}</code> objects
232      */

233     Key[] selectVolatileTriggers(Connection JavaDoc conn) throws SQLException JavaDoc;
234
235     /**
236      * <p>
237      * Get the names of all of the jobs that are volatile.
238      * </p>
239      *
240      * @param conn
241      * the DB Connection
242      * @return an array of <code>{@link
243      * org.quartz.utils.Key}</code> objects
244      */

245     Key[] selectVolatileJobs(Connection JavaDoc conn) throws SQLException JavaDoc;
246
247     //---------------------------------------------------------------------------
248
// jobs
249
//---------------------------------------------------------------------------
250

251     /**
252      * <p>
253      * Insert the job detail record.
254      * </p>
255      *
256      * @param conn
257      * the DB Connection
258      * @param job
259      * the job to insert
260      * @return number of rows inserted
261      * @throws IOException
262      * if there were problems serializing the JobDataMap
263      */

264     int insertJobDetail(Connection JavaDoc conn, JobDetail job)
265         throws IOException JavaDoc, SQLException JavaDoc;
266
267     /**
268      * <p>
269      * Update the job detail record.
270      * </p>
271      *
272      * @param conn
273      * the DB Connection
274      * @param job
275      * the job to update
276      * @return number of rows updated
277      * @throws IOException
278      * if there were problems serializing the JobDataMap
279      */

280     int updateJobDetail(Connection JavaDoc conn, JobDetail job)
281         throws IOException JavaDoc, SQLException JavaDoc;
282
283     /**
284      * <p>
285      * Get the names of all of the triggers associated with the given job.
286      * </p>
287      *
288      * @param conn
289      * the DB Connection
290      * @param jobName
291      * the job name
292      * @param groupName
293      * the job group
294      * @return an array of <code>{@link
295      * org.quartz.utils.Key}</code> objects
296      */

297     Key[] selectTriggerNamesForJob(Connection JavaDoc conn, String JavaDoc jobName,
298         String JavaDoc groupName) throws SQLException JavaDoc;
299
300     /**
301      * <p>
302      * Delete all job listeners for the given job.
303      * </p>
304      *
305      * @param conn
306      * the DB Connection
307      * @param jobName
308      * the name of the job
309      * @param groupName
310      * the group containing the job
311      * @return the number of rows deleted
312      */

313     int deleteJobListeners(Connection JavaDoc conn, String JavaDoc jobName,
314         String JavaDoc groupName) throws SQLException JavaDoc;
315
316     /**
317      * <p>
318      * Delete the job detail record for the given job.
319      * </p>
320      *
321      * @param conn
322      * the DB Connection
323      * @param jobName
324      * the name of the job
325      * @param groupName
326      * the group containing the job
327      * @return the number of rows deleted
328      */

329     int deleteJobDetail(Connection JavaDoc conn, String JavaDoc jobName, String JavaDoc groupName)
330         throws SQLException JavaDoc;
331
332     /**
333      * <p>
334      * Check whether or not the given job is stateful.
335      * </p>
336      *
337      * @param conn
338      * the DB Connection
339      * @param jobName
340      * the name of the job
341      * @param groupName
342      * the group containing the job
343      * @return true if the job exists and is stateful, false otherwise
344      */

345     boolean isJobStateful(Connection JavaDoc conn, String JavaDoc jobName,
346         String JavaDoc groupName) throws SQLException JavaDoc;
347
348     /**
349      * <p>
350      * Check whether or not the given job exists.
351      * </p>
352      *
353      * @param conn
354      * the DB Connection
355      * @param jobName
356      * the name of the job
357      * @param groupName
358      * the group containing the job
359      * @return true if the job exists, false otherwise
360      */

361     boolean jobExists(Connection JavaDoc conn, String JavaDoc jobName, String JavaDoc groupName)
362         throws SQLException JavaDoc;
363
364     /**
365      * <p>
366      * Update the job data map for the given job.
367      * </p>
368      *
369      * @param conn
370      * the DB Connection
371      * @param job
372      * the job to update
373      * @return the number of rows updated
374      * @throws IOException
375      * if there were problems serializing the JobDataMap
376      */

377     int updateJobData(Connection JavaDoc conn, JobDetail job)
378         throws IOException JavaDoc, SQLException JavaDoc;
379
380     /**
381      * <p>
382      * Associate a listener with a job.
383      * </p>
384      *
385      * @param conn
386      * the DB Connection
387      * @param job
388      * the job to associate with the listener
389      * @param listener
390      * the listener to insert
391      * @return the number of rows inserted
392      */

393     int insertJobListener(Connection JavaDoc conn, JobDetail job, String JavaDoc listener)
394         throws SQLException JavaDoc;
395
396     /**
397      * <p>
398      * Get all of the listeners for a given job.
399      * </p>
400      *
401      * @param conn
402      * the DB Connection
403      * @param jobName
404      * the job name whose listeners are wanted
405      * @param groupName
406      * the group containing the job
407      * @return array of <code>String</code> listener names
408      */

409     String JavaDoc[] selectJobListeners(Connection JavaDoc conn, String JavaDoc jobName,
410         String JavaDoc groupName) throws SQLException JavaDoc;
411
412     /**
413      * <p>
414      * Select the JobDetail object for a given job name / group name.
415      * </p>
416      *
417      * @param conn
418      * the DB Connection
419      * @param jobName
420      * the job name whose listeners are wanted
421      * @param groupName
422      * the group containing the job
423      * @return the populated JobDetail object
424      * @throws ClassNotFoundException
425      * if a class found during deserialization cannot be found or if
426      * the job class could not be found
427      * @throws IOException
428      * if deserialization causes an error
429      */

430     JobDetail selectJobDetail(Connection JavaDoc conn, String JavaDoc jobName,
431         String JavaDoc groupName, ClassLoadHelper loadHelper)
432         throws ClassNotFoundException JavaDoc, IOException JavaDoc, SQLException JavaDoc;
433
434     /**
435      * <p>
436      * Select the total number of jobs stored.
437      * </p>
438      *
439      * @param conn
440      * the DB Connection
441      * @return the total number of jobs stored
442      */

443     int selectNumJobs(Connection JavaDoc conn) throws SQLException JavaDoc;
444
445     /**
446      * <p>
447      * Select all of the job group names that are stored.
448      * </p>
449      *
450      * @param conn
451      * the DB Connection
452      * @return an array of <code>String</code> group names
453      */

454     String JavaDoc[] selectJobGroups(Connection JavaDoc conn) throws SQLException JavaDoc;
455
456     /**
457      * <p>
458      * Select all of the jobs contained in a given group.
459      * </p>
460      *
461      * @param conn
462      * the DB Connection
463      * @param groupName
464      * the group containing the jobs
465      * @return an array of <code>String</code> job names
466      */

467     String JavaDoc[] selectJobsInGroup(Connection JavaDoc conn, String JavaDoc groupName)
468         throws SQLException JavaDoc;
469
470     //---------------------------------------------------------------------------
471
// triggers
472
//---------------------------------------------------------------------------
473

474     /**
475      * <p>
476      * Insert the base trigger data.
477      * </p>
478      *
479      * @param conn
480      * the DB Connection
481      * @param trigger
482      * the trigger to insert
483      * @param state
484      * the state that the trigger should be stored in
485      * @return the number of rows inserted
486      */

487     int insertTrigger(Connection JavaDoc conn, Trigger trigger, String JavaDoc state,
488         JobDetail jobDetail) throws SQLException JavaDoc, IOException JavaDoc;
489
490     /**
491      * <p>
492      * Insert the simple trigger data.
493      * </p>
494      *
495      * @param conn
496      * the DB Connection
497      * @param trigger
498      * the trigger to insert
499      * @return the number of rows inserted
500      */

501     int insertSimpleTrigger(Connection JavaDoc conn, SimpleTrigger trigger)
502         throws SQLException JavaDoc;
503
504     /**
505      * <p>
506      * Insert the blob trigger data.
507      * </p>
508      *
509      * @param conn
510      * the DB Connection
511      * @param trigger
512      * the trigger to insert
513      * @return the number of rows inserted
514      */

515     int insertBlobTrigger(Connection JavaDoc conn, Trigger trigger)
516         throws SQLException JavaDoc, IOException JavaDoc;
517
518     /**
519      * <p>
520      * Insert the cron trigger data.
521      * </p>
522      *
523      * @param conn
524      * the DB Connection
525      * @param trigger
526      * the trigger to insert
527      * @return the number of rows inserted
528      */

529     int insertCronTrigger(Connection JavaDoc conn, CronTrigger trigger)
530         throws SQLException JavaDoc;
531
532     /**
533      * <p>
534      * Update the base trigger data.
535      * </p>
536      *
537      * @param conn
538      * the DB Connection
539      * @param trigger
540      * the trigger to insert
541      * @param state
542      * the state that the trigger should be stored in
543      * @return the number of rows updated
544      */

545     int updateTrigger(Connection JavaDoc conn, Trigger trigger, String JavaDoc state,
546         JobDetail jobDetail) throws SQLException JavaDoc, IOException JavaDoc;
547
548     /**
549      * <p>
550      * Update the simple trigger data.
551      * </p>
552      *
553      * @param conn
554      * the DB Connection
555      * @param trigger
556      * the trigger to insert
557      * @return the number of rows updated
558      */

559     int updateSimpleTrigger(Connection JavaDoc conn, SimpleTrigger trigger)
560         throws SQLException JavaDoc;
561
562     /**
563      * <p>
564      * Update the cron trigger data.
565      * </p>
566      *
567      * @param conn
568      * the DB Connection
569      * @param trigger
570      * the trigger to insert
571      * @return the number of rows updated
572      */

573     int updateCronTrigger(Connection JavaDoc conn, CronTrigger trigger)
574         throws SQLException JavaDoc;
575
576     /**
577      * <p>
578      * Update the blob trigger data.
579      * </p>
580      *
581      * @param conn
582      * the DB Connection
583      * @param trigger
584      * the trigger to insert
585      * @return the number of rows updated
586      */

587     int updateBlobTrigger(Connection JavaDoc conn, Trigger trigger)
588         throws SQLException JavaDoc, IOException JavaDoc;
589
590     /**
591      * <p>
592      * Check whether or not a trigger exists.
593      * </p>
594      *
595      * @param conn
596      * the DB Connection
597      * @param triggerName
598      * the name of the trigger
599      * @param groupName
600      * the group containing the trigger
601      * @return the number of rows updated
602      */

603     boolean triggerExists(Connection JavaDoc conn, String JavaDoc triggerName,
604         String JavaDoc groupName) throws SQLException JavaDoc;
605
606     /**
607      * <p>
608      * Update the state for a given trigger.
609      * </p>
610      *
611      * @param conn
612      * the DB Connection
613      * @param triggerName
614      * the name of the trigger
615      * @param groupName
616      * the group containing the trigger
617      * @param state
618      * the new state for the trigger
619      * @return the number of rows updated
620      */

621     int updateTriggerState(Connection JavaDoc conn, String JavaDoc triggerName,
622         String JavaDoc groupName, String JavaDoc state) throws SQLException JavaDoc;
623
624     /**
625      * <p>
626      * Update the given trigger to the given new state, if it is in the given
627      * old state.
628      * </p>
629      *
630      * @param conn
631      * the DB connection
632      * @param triggerName
633      * the name of the trigger
634      * @param groupName
635      * the group containing the trigger
636      * @param newState
637      * the new state for the trigger
638      * @param oldState
639      * the old state the trigger must be in
640      * @return int the number of rows updated
641      * @throws SQLException
642      */

643     int updateTriggerStateFromOtherState(Connection JavaDoc conn,
644         String JavaDoc triggerName, String JavaDoc groupName, String JavaDoc newState,
645         String JavaDoc oldState) throws SQLException JavaDoc;
646
647     /**
648      * <p>
649      * Update the given trigger to the given new state, if it is one of the
650      * given old states.
651      * </p>
652      *
653      * @param conn
654      * the DB connection
655      * @param triggerName
656      * the name of the trigger
657      * @param groupName
658      * the group containing the trigger
659      * @param newState
660      * the new state for the trigger
661      * @param oldState1
662      * one of the old state the trigger must be in
663      * @param oldState2
664      * one of the old state the trigger must be in
665      * @param oldState3
666      * one of the old state the trigger must be in
667      * @return int the number of rows updated
668      * @throws SQLException
669      */

670     int updateTriggerStateFromOtherStates(Connection JavaDoc conn,
671         String JavaDoc triggerName, String JavaDoc groupName, String JavaDoc newState,
672         String JavaDoc oldState1, String JavaDoc oldState2, String JavaDoc oldState3)
673         throws SQLException JavaDoc;
674
675     /**
676      * <p>
677      * Update the all triggers to the given new state, if they are in one of
678      * the given old states AND its next fire time is before the given time.
679      * </p>
680      *
681      * @param conn
682      * the DB connection
683      * @param newState
684      * the new state for the trigger
685      * @param oldState1
686      * one of the old state the trigger must be in
687      * @param oldState2
688      * one of the old state the trigger must be in
689      * @param time
690      * the time before which the trigger's next fire time must be
691      * @return int the number of rows updated
692      * @throws SQLException
693      */

694     int updateTriggerStateFromOtherStatesBeforeTime(Connection JavaDoc conn,
695         String JavaDoc newState, String JavaDoc oldState1, String JavaDoc oldState2, long time)
696         throws SQLException JavaDoc;
697
698     /**
699      * <p>
700      * Update all triggers in the given group to the given new state, if they
701      * are in one of the given old states.
702      * </p>
703      *
704      * @param conn
705      * the DB connection
706      * @param groupName
707      * the group containing the trigger
708      * @param newState
709      * the new state for the trigger
710      * @param oldState1
711      * one of the old state the trigger must be in
712      * @param oldState2
713      * one of the old state the trigger must be in
714      * @param oldState3
715      * one of the old state the trigger must be in
716      * @return int the number of rows updated
717      * @throws SQLException
718      */

719     int updateTriggerGroupStateFromOtherStates(Connection JavaDoc conn,
720         String JavaDoc groupName, String JavaDoc newState, String JavaDoc oldState1,
721         String JavaDoc oldState2, String JavaDoc oldState3) throws SQLException JavaDoc;
722
723     /**
724      * <p>
725      * Update all of the triggers of the given group to the given new state, if
726      * they are in the given old state.
727      * </p>
728      *
729      * @param conn
730      * the DB connection
731      * @param groupName
732      * the group containing the triggers
733      * @param newState
734      * the new state for the trigger group
735      * @param oldState
736      * the old state the triggers must be in
737      * @return int the number of rows updated
738      * @throws SQLException
739      */

740     int updateTriggerGroupStateFromOtherState(Connection JavaDoc conn,
741         String JavaDoc groupName, String JavaDoc newState, String JavaDoc oldState)
742         throws SQLException JavaDoc;
743
744     /**
745      * <p>
746      * Update the states of all triggers associated with the given job.
747      * </p>
748      *
749      * @param conn
750      * the DB Connection
751      * @param jobName
752      * the name of the job
753      * @param groupName
754      * the group containing the job
755      * @param state
756      * the new state for the triggers
757      * @return the number of rows updated
758      */

759     int updateTriggerStatesForJob(Connection JavaDoc conn, String JavaDoc jobName,
760         String JavaDoc groupName, String JavaDoc state) throws SQLException JavaDoc;
761
762     /**
763      * <p>
764      * Update the states of any triggers associated with the given job, that
765      * are the given current state.
766      * </p>
767      *
768      * @param conn
769      * the DB Connection
770      * @param jobName
771      * the name of the job
772      * @param groupName
773      * the group containing the job
774      * @param state
775      * the new state for the triggers
776      * @param oldState
777      * the old state of the triggers
778      * @return the number of rows updated
779      */

780     int updateTriggerStatesForJobFromOtherState(Connection JavaDoc conn,
781         String JavaDoc jobName, String JavaDoc groupName, String JavaDoc state, String JavaDoc oldState)
782         throws SQLException JavaDoc;
783
784     /**
785      * <p>
786      * Delete all of the listeners associated with a given trigger.
787      * </p>
788      *
789      * @param conn
790      * the DB Connection
791      * @param triggerName
792      * the name of the trigger whose listeners will be deleted
793      * @param groupName
794      * the name of the group containing the trigger
795      * @return the number of rows deleted
796      */

797     int deleteTriggerListeners(Connection JavaDoc conn, String JavaDoc triggerName,
798         String JavaDoc groupName) throws SQLException JavaDoc;
799
800     /**
801      * <p>
802      * Associate a listener with the given trigger.
803      * </p>
804      *
805      * @param conn
806      * the DB Connection
807      * @param trigger
808      * the trigger
809      * @param listener
810      * the name of the listener to associate with the trigger
811      * @return the number of rows inserted
812      */

813     int insertTriggerListener(Connection JavaDoc conn, Trigger trigger,
814         String JavaDoc listener) throws SQLException JavaDoc;
815
816     /**
817      * <p>
818      * Select the listeners associated with a given trigger.
819      * </p>
820      *
821      * @param conn
822      * the DB Connection
823      * @param triggerName
824      * the name of the trigger
825      * @param groupName
826      * the group containing the trigger
827      * @return array of <code>String</code> trigger listener names
828      */

829     String JavaDoc[] selectTriggerListeners(Connection JavaDoc conn, String JavaDoc triggerName,
830         String JavaDoc groupName) throws SQLException JavaDoc;
831
832     /**
833      * <p>
834      * Delete the simple trigger data for a trigger.
835      * </p>
836      *
837      * @param conn
838      * the DB Connection
839      * @param triggerName
840      * the name of the trigger
841      * @param groupName
842      * the group containing the trigger
843      * @return the number of rows deleted
844      */

845     int deleteSimpleTrigger(Connection JavaDoc conn, String JavaDoc triggerName,
846         String JavaDoc groupName) throws SQLException JavaDoc;
847
848     /**
849      * <p>
850      * Delete the BLOB trigger data for a trigger.
851      * </p>
852      *
853      * @param conn
854      * the DB Connection
855      * @param triggerName
856      * the name of the trigger
857      * @param groupName
858      * the group containing the trigger
859      * @return the number of rows deleted
860      */

861     int deleteBlobTrigger(Connection JavaDoc conn, String JavaDoc triggerName,
862         String JavaDoc groupName) throws SQLException JavaDoc;
863
864     /**
865      * <p>
866      * Delete the cron trigger data for a trigger.
867      * </p>
868      *
869      * @param conn
870      * the DB Connection
871      * @param triggerName
872      * the name of the trigger
873      * @param groupName
874      * the group containing the trigger
875      * @return the number of rows deleted
876      */

877     int deleteCronTrigger(Connection JavaDoc conn, String JavaDoc triggerName,
878         String JavaDoc groupName) throws SQLException JavaDoc;
879
880     /**
881      * <p>
882      * Delete the base trigger data for a trigger.
883      * </p>
884      *
885      * @param conn
886      * the DB Connection
887      * @param triggerName
888      * the name of the trigger
889      * @param groupName
890      * the group containing the trigger
891      * @return the number of rows deleted
892      */

893     int deleteTrigger(Connection JavaDoc conn, String JavaDoc triggerName,
894         String JavaDoc groupName) throws SQLException JavaDoc;
895
896     /**
897      * <p>
898      * Select the number of triggers associated with a given job.
899      * </p>
900      *
901      * @param conn
902      * the DB Connection
903      * @param jobName
904      * the name of the job
905      * @param groupName
906      * the group containing the job
907      * @return the number of triggers for the given job
908      */

909     int selectNumTriggersForJob(Connection JavaDoc conn, String JavaDoc jobName,
910         String JavaDoc groupName) throws SQLException JavaDoc;
911
912     /**
913      * <p>
914      * Select the job to which the trigger is associated.
915      * </p>
916      *
917      * @param conn
918      * the DB Connection
919      * @param triggerName
920      * the name of the trigger
921      * @param groupName
922      * the group containing the trigger
923      * @return the <code>{@link org.quartz.JobDetail}</code> object
924      * associated with the given trigger
925      */

926     JobDetail selectJobForTrigger(Connection JavaDoc conn, String JavaDoc triggerName,
927         String JavaDoc groupName, ClassLoadHelper loadHelper)
928         throws ClassNotFoundException JavaDoc, SQLException JavaDoc;
929
930     /**
931      * <p>
932      * Select the stateful jobs which are referenced by triggers in the given
933      * trigger group.
934      * </p>
935      *
936      * @param conn
937      * the DB Connection
938      * @param groupName
939      * the trigger group
940      * @return a List of Keys to jobs.
941      */

942     List JavaDoc selectStatefulJobsOfTriggerGroup(Connection JavaDoc conn,
943         String JavaDoc groupName) throws SQLException JavaDoc;
944
945     /**
946      * <p>
947      * Select the triggers for a job
948      * </p>
949      *
950      * @param conn
951      * the DB Connection
952      * @param jobName
953      * the name of the trigger
954      * @param groupName
955      * the group containing the trigger
956      * @return an array of <code>(@link org.quartz.Trigger)</code> objects
957      * associated with a given job.
958      * @throws SQLException
959      */

960     Trigger[] selectTriggersForJob(Connection JavaDoc conn, String JavaDoc jobName,
961         String JavaDoc groupName) throws SQLException JavaDoc, ClassNotFoundException JavaDoc,
962         IOException JavaDoc;
963
964     /**
965      * <p>
966      * Select the triggers for a calendar
967      * </p>
968      *
969      * @param conn
970      * the DB Connection
971      * @param calName
972      * the name of the calendar
973      * @return an array of <code>(@link org.quartz.Trigger)</code> objects
974      * associated with the given calendar.
975      * @throws SQLException
976      */

977     Trigger[] selectTriggersForCalendar(Connection JavaDoc conn, String JavaDoc calName)
978         throws SQLException JavaDoc, ClassNotFoundException JavaDoc, IOException JavaDoc;
979     /**
980      * <p>
981      * Select a trigger.
982      * </p>
983      *
984      * @param conn
985      * the DB Connection
986      * @param triggerName
987      * the name of the trigger
988      * @param groupName
989      * the group containing the trigger
990      * @return the <code>{@link org.quartz.Trigger}</code> object
991      */

992     Trigger selectTrigger(Connection JavaDoc conn, String JavaDoc triggerName,
993         String JavaDoc groupName) throws SQLException JavaDoc, ClassNotFoundException JavaDoc,
994         IOException JavaDoc;
995
996     /**
997      * <p>
998      * Select a trigger's JobDataMap.
999      * </p>
1000     *
1001     * @param conn
1002     * the DB Connection
1003     * @param triggerName
1004     * the name of the trigger
1005     * @param groupName
1006     * the group containing the trigger
1007     * @return the <code>{@link org.quartz.JobDataMap}</code> of the Trigger,
1008     * never null, but possibly empty.
1009     */

1010    JobDataMap selectTriggerJobDataMap(Connection JavaDoc conn, String JavaDoc triggerName,
1011        String JavaDoc groupName) throws SQLException JavaDoc, ClassNotFoundException JavaDoc,
1012        IOException JavaDoc;
1013
1014    /**
1015     * <p>
1016     * Select a trigger' state value.
1017     * </p>
1018     *
1019     * @param conn
1020     * the DB Connection
1021     * @param triggerName
1022     * the name of the trigger
1023     * @param groupName
1024     * the group containing the trigger
1025     * @return the <code>{@link org.quartz.Trigger}</code> object
1026     */

1027    String JavaDoc selectTriggerState(Connection JavaDoc conn, String JavaDoc triggerName,
1028        String JavaDoc groupName) throws SQLException JavaDoc;
1029
1030    /**
1031     * <p>
1032     * Select a trigger' status (state & next fire time).
1033     * </p>
1034     *
1035     * @param conn
1036     * the DB Connection
1037     * @param triggerName
1038     * the name of the trigger
1039     * @param groupName
1040     * the group containing the trigger
1041     * @return a <code>TriggerStatus</code> object, or null
1042     */

1043    TriggerStatus selectTriggerStatus(Connection JavaDoc conn,
1044        String JavaDoc triggerName, String JavaDoc groupName) throws SQLException JavaDoc;
1045
1046    /**
1047     * <p>
1048     * Select the total number of triggers stored.
1049     * </p>
1050     *
1051     * @param conn
1052     * the DB Connection
1053     * @return the total number of triggers stored
1054     */

1055    int selectNumTriggers(Connection JavaDoc conn) throws SQLException JavaDoc;
1056
1057    /**
1058     * <p>
1059     * Select all of the trigger group names that are stored.
1060     * </p>
1061     *
1062     * @param conn
1063     * the DB Connection
1064     * @return an array of <code>String</code> group names
1065     */

1066    String JavaDoc[] selectTriggerGroups(Connection JavaDoc conn) throws SQLException JavaDoc;
1067
1068    /**
1069     * <p>
1070     * Select all of the triggers contained in a given group.
1071     * </p>
1072     *
1073     * @param conn
1074     * the DB Connection
1075     * @param groupName
1076     * the group containing the triggers
1077     * @return an array of <code>String</code> trigger names
1078     */

1079    String JavaDoc[] selectTriggersInGroup(Connection JavaDoc conn, String JavaDoc groupName)
1080        throws SQLException JavaDoc;
1081
1082    /**
1083     * <p>
1084     * Select all of the triggers in a given state.
1085     * </p>
1086     *
1087     * @param conn
1088     * the DB Connection
1089     * @param state
1090     * the state the triggers must be in
1091     * @return an array of trigger <code>Key</code> s
1092     */

1093    Key[] selectTriggersInState(Connection JavaDoc conn, String JavaDoc state)
1094        throws SQLException JavaDoc;
1095
1096    int insertPausedTriggerGroup(Connection JavaDoc conn, String JavaDoc groupName)
1097        throws SQLException JavaDoc;
1098
1099    int deletePausedTriggerGroup(Connection JavaDoc conn, String JavaDoc groupName)
1100        throws SQLException JavaDoc;
1101
1102    int deleteAllPausedTriggerGroups(Connection JavaDoc conn)
1103        throws SQLException JavaDoc;
1104
1105    boolean isTriggerGroupPaused(Connection JavaDoc conn, String JavaDoc groupName)
1106        throws SQLException JavaDoc;
1107
1108    Set JavaDoc selectPausedTriggerGroups(Connection JavaDoc conn)
1109        throws SQLException JavaDoc;
1110    
1111    boolean isExistingTriggerGroup(Connection JavaDoc conn, String JavaDoc groupName)
1112        throws SQLException JavaDoc;
1113
1114    //---------------------------------------------------------------------------
1115
// calendars
1116
//---------------------------------------------------------------------------
1117

1118    /**
1119     * <p>
1120     * Insert a new calendar.
1121     * </p>
1122     *
1123     * @param conn
1124     * the DB Connection
1125     * @param calendarName
1126     * the name for the new calendar
1127     * @param calendar
1128     * the calendar
1129     * @return the number of rows inserted
1130     * @throws IOException
1131     * if there were problems serializing the calendar
1132     */

1133    int insertCalendar(Connection JavaDoc conn, String JavaDoc calendarName,
1134        Calendar calendar) throws IOException JavaDoc, SQLException JavaDoc;
1135
1136    /**
1137     * <p>
1138     * Update a calendar.
1139     * </p>
1140     *
1141     * @param conn
1142     * the DB Connection
1143     * @param calendarName
1144     * the name for the new calendar
1145     * @param calendar
1146     * the calendar
1147     * @return the number of rows updated
1148     * @throws IOException
1149     * if there were problems serializing the calendar
1150     */

1151    int updateCalendar(Connection JavaDoc conn, String JavaDoc calendarName,
1152        Calendar calendar) throws IOException JavaDoc, SQLException JavaDoc;
1153
1154    /**
1155     * <p>
1156     * Check whether or not a calendar exists.
1157     * </p>
1158     *
1159     * @param conn
1160     * the DB Connection
1161     * @param calendarName
1162     * the name of the calendar
1163     * @return true if the trigger exists, false otherwise
1164     */

1165    boolean calendarExists(Connection JavaDoc conn, String JavaDoc calendarName)
1166        throws SQLException JavaDoc;
1167
1168    /**
1169     * <p>
1170     * Select a calendar.
1171     * </p>
1172     *
1173     * @param conn
1174     * the DB Connection
1175     * @param calendarName
1176     * the name of the calendar
1177     * @return the Calendar
1178     * @throws ClassNotFoundException
1179     * if a class found during deserialization cannot be found be
1180     * found
1181     * @throws IOException
1182     * if there were problems deserializing the calendar
1183     */

1184    Calendar selectCalendar(Connection JavaDoc conn, String JavaDoc calendarName)
1185        throws ClassNotFoundException JavaDoc, IOException JavaDoc, SQLException JavaDoc;
1186
1187    /**
1188     * <p>
1189     * Check whether or not a calendar is referenced by any triggers.
1190     * </p>
1191     *
1192     * @param conn
1193     * the DB Connection
1194     * @param calendarName
1195     * the name of the calendar
1196     * @return true if any triggers reference the calendar, false otherwise
1197     */

1198    boolean calendarIsReferenced(Connection JavaDoc conn, String JavaDoc calendarName)
1199        throws SQLException JavaDoc;
1200
1201    /**
1202     * <p>
1203     * Delete a calendar.
1204     * </p>
1205     *
1206     * @param conn
1207     * the DB Connection
1208     * @param calendarName
1209     * the name of the trigger
1210     * @return the number of rows deleted
1211     */

1212    int deleteCalendar(Connection JavaDoc conn, String JavaDoc calendarName)
1213        throws SQLException JavaDoc;
1214
1215    /**
1216     * <p>
1217     * Select the total number of calendars stored.
1218     * </p>
1219     *
1220     * @param conn
1221     * the DB Connection
1222     * @return the total number of calendars stored
1223     */

1224    int selectNumCalendars(Connection JavaDoc conn) throws SQLException JavaDoc;
1225
1226    /**
1227     * <p>
1228     * Select all of the stored calendars.
1229     * </p>
1230     *
1231     * @param conn
1232     * the DB Connection
1233     * @return an array of <code>String</code> calendar names
1234     */

1235    String JavaDoc[] selectCalendars(Connection JavaDoc conn) throws SQLException JavaDoc;
1236
1237    //---------------------------------------------------------------------------
1238
// trigger firing
1239
//---------------------------------------------------------------------------
1240

1241    /**
1242     * <p>
1243     * Select the next time that a trigger will be fired.
1244     * </p>
1245     *
1246     * @param conn
1247     * the DB Connection
1248     * @return the next fire time, or 0 if no trigger will be fired
1249     *
1250     * @deprecated Does not account for misfires.
1251     */

1252    long selectNextFireTime(Connection JavaDoc conn) throws SQLException JavaDoc;
1253
1254    /**
1255     * <p>
1256     * Select the trigger that will be fired at the given fire time.
1257     * </p>
1258     *
1259     * @param conn
1260     * the DB Connection
1261     * @param fireTime
1262     * the time that the trigger will be fired
1263     * @return a <code>{@link org.quartz.utils.Key}</code> representing the
1264     * trigger that will be fired at the given fire time, or null if no
1265     * trigger will be fired at that time
1266     */

1267    Key selectTriggerForFireTime(Connection JavaDoc conn, long fireTime)
1268        throws SQLException JavaDoc;
1269
1270    /**
1271     * <p>
1272     * Select the next trigger which will fire to fire between the two given timestamps
1273     * in ascending order of fire time, and then descending by priority.
1274     * </p>
1275     *
1276     * @param conn
1277     * the DB Connection
1278     * @param noLaterThan
1279     * highest value of <code>getNextFireTime()</code> of the triggers (exclusive)
1280     * @param noEarlierThan
1281     * highest value of <code>getNextFireTime()</code> of the triggers (inclusive)
1282     *
1283     * @return The next identifier of the next trigger to be fired.
1284     */

1285    Key selectTriggerToAcquire(Connection JavaDoc conn, long noLaterThan, long noEarlierThan)
1286        throws SQLException JavaDoc;
1287
1288    /**
1289     * <p>
1290     * Insert a fired trigger.
1291     * </p>
1292     *
1293     * @param conn
1294     * the DB Connection
1295     * @param trigger
1296     * the trigger
1297     * @param state
1298     * the state that the trigger should be stored in
1299     * @return the number of rows inserted
1300     */

1301    int insertFiredTrigger(Connection JavaDoc conn, Trigger trigger,
1302        String JavaDoc state, JobDetail jobDetail) throws SQLException JavaDoc;
1303
1304    /**
1305     * <p>
1306     * Select the states of all fired-trigger records for a given trigger, or
1307     * trigger group if trigger name is <code>null</code>.
1308     * </p>
1309     *
1310     * @return a List of FiredTriggerRecord objects.
1311     */

1312    List JavaDoc selectFiredTriggerRecords(Connection JavaDoc conn, String JavaDoc triggerName,
1313        String JavaDoc groupName) throws SQLException JavaDoc;
1314
1315    /**
1316     * <p>
1317     * Select the states of all fired-trigger records for a given job, or job
1318     * group if job name is <code>null</code>.
1319     * </p>
1320     *
1321     * @return a List of FiredTriggerRecord objects.
1322     */

1323    List JavaDoc selectFiredTriggerRecordsByJob(Connection JavaDoc conn, String JavaDoc jobName,
1324        String JavaDoc groupName) throws SQLException JavaDoc;
1325
1326    /**
1327     * <p>
1328     * Select the states of all fired-trigger records for a given scheduler
1329     * instance.
1330     * </p>
1331     *
1332     * @return a List of FiredTriggerRecord objects.
1333     */

1334    List JavaDoc selectInstancesFiredTriggerRecords(Connection JavaDoc conn,
1335        String JavaDoc instanceName) throws SQLException JavaDoc;
1336
1337    
1338    /**
1339     * <p>
1340     * Select the distinct instance names of all fired-trigger records.
1341     * </p>
1342     *
1343     * <p>
1344     * This is useful when trying to identify orphaned fired triggers (a
1345     * fired trigger without a scheduler state record.)
1346     * </p>
1347     *
1348     * @return a Set of String objects.
1349     */

1350    Set JavaDoc selectFiredTriggerInstanceNames(Connection JavaDoc conn)
1351        throws SQLException JavaDoc;
1352    
1353    /**
1354     * <p>
1355     * Delete a fired trigger.
1356     * </p>
1357     *
1358     * @param conn
1359     * the DB Connection
1360     * @param entryId
1361     * the fired trigger entry to delete
1362     * @return the number of rows deleted
1363     */

1364    int deleteFiredTrigger(Connection JavaDoc conn, String JavaDoc entryId)
1365        throws SQLException JavaDoc;
1366
1367    /**
1368     * <p>
1369     * Get the number instances of the identified job currently executing.
1370     * </p>
1371     *
1372     * @param conn
1373     * the DB Connection
1374     * @return the number instances of the identified job currently executing.
1375     */

1376    int selectJobExecutionCount(Connection JavaDoc conn, String JavaDoc jobName,
1377        String JavaDoc jobGroup) throws SQLException JavaDoc;
1378
1379    /**
1380     * <p>
1381     * Insert a scheduler-instance state record.
1382     * </p>
1383     *
1384     * @param conn
1385     * the DB Connection
1386     * @return the number of inserted rows.
1387     */

1388    int insertSchedulerState(Connection JavaDoc conn, String JavaDoc instanceId,
1389        long checkInTime, long interval)
1390        throws SQLException JavaDoc;
1391
1392    /**
1393     * <p>
1394     * Delete a scheduler-instance state record.
1395     * </p>
1396     *
1397     * @param conn
1398     * the DB Connection
1399     * @return the number of deleted rows.
1400     */

1401    int deleteSchedulerState(Connection JavaDoc conn, String JavaDoc instanceId)
1402        throws SQLException JavaDoc;
1403
1404    
1405    /**
1406     * <p>
1407     * Update a scheduler-instance state record.
1408     * </p>
1409     *
1410     * @param conn
1411     * the DB Connection
1412     * @return the number of updated rows.
1413     */

1414    int updateSchedulerState(Connection JavaDoc conn, String JavaDoc instanceId, long checkInTime)
1415        throws SQLException JavaDoc;
1416    
1417    /**
1418     * <p>
1419     * A List of all current <code>SchedulerStateRecords</code>.
1420     * </p>
1421     *
1422     * <p>
1423     * If instanceId is not null, then only the record for the identified
1424     * instance will be returned.
1425     * </p>
1426     *
1427     * @param conn
1428     * the DB Connection
1429     */

1430    List JavaDoc selectSchedulerStateRecords(Connection JavaDoc conn, String JavaDoc instanceId)
1431        throws SQLException JavaDoc;
1432
1433}
1434
1435// EOF
1436
Popular Tags