1 package org.apache.turbine.services.schedule;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.List;
23
24 import org.apache.turbine.services.TurbineServices;
25 import org.apache.turbine.util.TurbineException;
26
27 /***
28 * This is a fascade class to provide easy access to the Scheduler
29 * service. All access methods are static and act upon the current
30 * instance of the scheduler service.
31 *
32 * @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a>
33 * @version $Id: TurbineScheduler.java 534527 2007-05-02 16:10:59Z tv $
34 * @see org.apache.turbine.services.schedule.ScheduleService
35 */
36 public abstract class TurbineScheduler
37 {
38 /***
39 * Get a specific Job from Storage.
40 *
41 * @param oid The int id for the job.
42 * @return A JobEntry.
43 * @exception TurbineException job could not be retrieved
44 */
45 public static JobEntry getJob(int oid)
46 throws TurbineException
47 {
48 return getService().getJob(oid);
49 }
50
51 /***
52 * Add a new job to the queue.
53 *
54 * @param je A JobEntry with the job to add.
55 * @exception TurbineException job could not be added
56 */
57 public static void addJob(JobEntry je)
58 throws TurbineException
59 {
60 getService().addJob(je);
61 }
62
63 /***
64 * Add or update a job
65 *
66 * @param je A JobEntry with the job to modify
67 * @exception TurbineException job could not be updated
68 */
69 public static void updateJob(JobEntry je)
70 throws TurbineException
71 {
72 getService().updateJob(je);
73 }
74
75 /***
76 * Remove a job from the queue.
77 *
78 * @param je A JobEntry with the job to remove.
79 * @exception TurbineException job could not be removed
80 */
81 public static void removeJob(JobEntry je)
82 throws TurbineException
83 {
84 getService().removeJob(je);
85 }
86
87 /***
88 * List jobs in the queue. This is used by the scheduler UI.
89 *
90 * @return A Vector of jobs.
91 */
92 public static List listJobs()
93 {
94 return getService().listJobs();
95 }
96
97 /***
98 * Determines if the scheduler service is currently active.
99 *
100 * @return Status of the scheduler service.
101 */
102 public static boolean isEnabled()
103 {
104 return getService().isEnabled();
105 }
106
107 /***
108 * Starts the scheduler if not already running.
109 */
110 public static void startScheduler()
111 {
112 getService().startScheduler();
113 }
114
115 /***
116 * Stops the scheduler if ti is currently running.
117 */
118 public static void stopScheduler()
119 {
120 getService().stopScheduler();
121 }
122
123 /***
124 * Utility method for accessing the service
125 * implementation
126 *
127 * @return a ScheduleService implementation instance
128 */
129 private static ScheduleService getService()
130 {
131 return (ScheduleService) TurbineServices
132 .getInstance().getService(ScheduleService.SERVICE_NAME);
133 }
134
135 }