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
23
24 import java.util.List;
25
26 import org.apache.logging.log4j.LogManager;
27 import org.apache.logging.log4j.Logger;
28 import org.apache.turbine.annotation.TurbineService;
29 import org.apache.turbine.services.pull.ApplicationTool;
30 import org.apache.turbine.util.TurbineException;
31
32
33
34
35
36
37
38 public class SchedulerTool implements ApplicationTool
39 {
40
41 private static final Logger log = LogManager.getLogger(ScheduleService.LOGGER_NAME);
42
43
44
45
46 @TurbineService
47 private ScheduleService schedulerService;
48
49
50
51
52 @Override
53 public void init(Object data)
54 {
55
56 if (schedulerService == null)
57 {
58 log.error("You can not use the SchedulerTool unless you enable "
59 +"the Scheduler Service!!!!");
60 }
61 }
62
63
64
65
66 @Override
67 public void refresh()
68 {
69
70 }
71
72
73
74
75
76
77 public List<? extends JobEntry> getScheduledJobs()
78 {
79 return schedulerService.listJobs();
80 }
81
82
83
84
85
86 public boolean isEnabled()
87 {
88 return schedulerService.isEnabled();
89 }
90
91
92
93
94
95
96
97 public JobEntry getJob(String jobId)
98 {
99 JobEntry je = null;
100
101 try
102 {
103 je = schedulerService.getJob(Integer.parseInt(jobId));
104 }
105 catch (TurbineException e)
106 {
107 log.error("Could not retreive job id #{}", jobId, e);
108 }
109
110 return je;
111 }
112
113 }