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