Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
TurbineScheduler |
|
| 1.0;1 |
1 | package org.apache.turbine.services.schedule; | |
2 | ||
3 | ||
4 | /* | |
5 | * Licensed to the Apache Software Foundation (ASF) under one | |
6 | * or more contributor license agreements. See the NOTICE file | |
7 | * distributed with this work for additional information | |
8 | * regarding copyright ownership. The ASF licenses this file | |
9 | * to you under the Apache License, Version 2.0 (the | |
10 | * "License"); you may not use this file except in compliance | |
11 | * with the License. You may obtain a copy of the License at | |
12 | * | |
13 | * http://www.apache.org/licenses/LICENSE-2.0 | |
14 | * | |
15 | * Unless required by applicable law or agreed to in writing, | |
16 | * software distributed under the License is distributed on an | |
17 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
18 | * KIND, either express or implied. See the License for the | |
19 | * specific language governing permissions and limitations | |
20 | * under the License. | |
21 | */ | |
22 | ||
23 | ||
24 | import java.util.List; | |
25 | ||
26 | import org.apache.turbine.services.TurbineServices; | |
27 | import org.apache.turbine.util.TurbineException; | |
28 | ||
29 | /** | |
30 | * This is a fascade class to provide easy access to the Scheduler | |
31 | * service. All access methods are static and act upon the current | |
32 | * instance of the scheduler service. | |
33 | * | |
34 | * @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a> | |
35 | * @version $Id: TurbineScheduler.java 1066938 2011-02-03 20:14:53Z ludwig $ | |
36 | * @see org.apache.turbine.services.schedule.ScheduleService | |
37 | */ | |
38 | 0 | public abstract class TurbineScheduler |
39 | { | |
40 | /** | |
41 | * Get a specific Job from Storage. | |
42 | * | |
43 | * @param oid The int id for the job. | |
44 | * @return A JobEntry. | |
45 | * @exception TurbineException job could not be retrieved | |
46 | */ | |
47 | public static JobEntry getJob(int oid) | |
48 | throws TurbineException | |
49 | { | |
50 | 2 | return getService().getJob(oid); |
51 | } | |
52 | ||
53 | /** | |
54 | * Add a new job to the queue. | |
55 | * | |
56 | * @param je A JobEntry with the job to add. | |
57 | * @exception TurbineException job could not be added | |
58 | */ | |
59 | public static void addJob(JobEntry je) | |
60 | throws TurbineException | |
61 | { | |
62 | 2 | getService().addJob(je); |
63 | 2 | } |
64 | ||
65 | /** | |
66 | * Add or update a job | |
67 | * | |
68 | * @param je A JobEntry with the job to modify | |
69 | * @exception TurbineException job could not be updated | |
70 | */ | |
71 | public static void updateJob(JobEntry je) | |
72 | throws TurbineException | |
73 | { | |
74 | 0 | getService().updateJob(je); |
75 | 0 | } |
76 | ||
77 | /** | |
78 | * Remove a job from the queue. | |
79 | * | |
80 | * @param je A JobEntry with the job to remove. | |
81 | * @exception TurbineException job could not be removed | |
82 | */ | |
83 | public static void removeJob(JobEntry je) | |
84 | throws TurbineException | |
85 | { | |
86 | 2 | getService().removeJob(je); |
87 | 2 | } |
88 | ||
89 | /** | |
90 | * List jobs in the queue. This is used by the scheduler UI. | |
91 | * | |
92 | * @return A Vector of jobs. | |
93 | */ | |
94 | public static List<JobEntry> listJobs() | |
95 | { | |
96 | 6 | return getService().listJobs(); |
97 | } | |
98 | ||
99 | /** | |
100 | * Determines if the scheduler service is currently active. | |
101 | * | |
102 | * @return Status of the scheduler service. | |
103 | */ | |
104 | public static boolean isEnabled() | |
105 | { | |
106 | 4 | return getService().isEnabled(); |
107 | } | |
108 | ||
109 | /** | |
110 | * Starts the scheduler if not already running. | |
111 | */ | |
112 | public static void startScheduler() | |
113 | { | |
114 | 2 | getService().startScheduler(); |
115 | 2 | } |
116 | ||
117 | /** | |
118 | * Stops the scheduler if ti is currently running. | |
119 | */ | |
120 | public static void stopScheduler() | |
121 | { | |
122 | 2 | getService().stopScheduler(); |
123 | 2 | } |
124 | ||
125 | /** | |
126 | * Utility method for accessing the service | |
127 | * implementation | |
128 | * | |
129 | * @return a ScheduleService implementation instance | |
130 | */ | |
131 | private static ScheduleService getService() | |
132 | { | |
133 | 20 | return (ScheduleService) TurbineServices |
134 | .getInstance().getService(ScheduleService.SERVICE_NAME); | |
135 | } | |
136 | ||
137 | } |