KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > turbine > services > schedule > SchedulerTool


1 package org.apache.turbine.services.schedule;
2
3 /*
4  * Copyright 2001-2004 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License")
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 import java.util.List JavaDoc;
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,v 1.4.2.2 2004/05/20 03:06:49 seade Exp $
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 JavaDoc 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 JavaDoc 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 JavaDoc 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 }
99
Popular Tags