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