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.commons.logging.Log;
25 import org.apache.commons.logging.LogFactory;
26 import org.apache.turbine.services.TurbineServices;
27 import org.apache.turbine.services.pull.ApplicationTool;
28 import org.apache.turbine.util.TurbineException;
29
30 /***
31 * This tool is used to retrieve information about the job scheduler.
32 *
33 * @author <a href="mailto:qmccombs@nequalsone.com">Quinton McCombs</a>
34 * @version $Id: SchedulerTool.java 534527 2007-05-02 16:10:59Z tv $
35 */
36 public class SchedulerTool implements ApplicationTool
37 {
38 /*** Used for logging */
39 private static Log log = LogFactory.getLog(ScheduleService.LOGGER_NAME);
40
41 /***
42 * Initialize the pull tool
43 */
44 public void init(Object data)
45 {
46 if (!TurbineServices.getInstance().isRegistered(
47 ScheduleService.SERVICE_NAME))
48 {
49 log.error("You can not use the SchedulerTool unless you enable "
50 +"the Scheduler Service!!!!");
51 }
52 }
53
54 /***
55 * Does nothing
56 */
57 public void refresh()
58 {
59 }
60
61 /***
62 * Gets the list of scheduled jobs.
63 *
64 * @return List of JobEntry objects.
65 */
66 public List getScheduledJobs()
67 {
68 return TurbineScheduler.listJobs();
69 }
70
71 /***
72 * Determines if the scheduler service is currently enabled.
73 */
74 public boolean isEnabled()
75 {
76 return TurbineScheduler.isEnabled();
77 }
78
79 /***
80 * Gets the job identified by the jobId.
81 *
82 * @param jobId Id of the job to retreive.
83 * @return The job. Null if the jobId is not found.
84 */
85 public JobEntry getJob(String jobId)
86 {
87 JobEntry je = null;
88
89 try
90 {
91 je = TurbineScheduler.getJob(Integer.parseInt(jobId));
92 }
93 catch (TurbineException e)
94 {
95 log.error("Could not retreive job id #" + jobId, e);
96 }
97
98 return je;
99 }
100
101 }