KickJava   Java API By Example, From Geeks To Geeks.

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


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.turbine.services.TurbineServices;
22 import org.apache.turbine.util.TurbineException;
23
24 /**
25  * This is a fascade class to provide easy access to the Scheduler
26  * service. All access methods are static and act upon the current
27  * instance of the scheduler service.
28  *
29  * @author <a HREF="mailto:quintonm@bellsouth.net">Quinton McCombs</a>
30  * @version $Id: TurbineScheduler.java,v 1.5.2.2 2004/05/20 03:06:49 seade Exp $
31  * @see org.apache.turbine.services.schedule.ScheduleService
32  */

33 public abstract class TurbineScheduler
34 {
35     /**
36      * Get a specific Job from Storage.
37      *
38      * @param oid The int id for the job.
39      * @return A JobEntry.
40      * @exception TurbineException job could not be retrieved
41      */

42     public static JobEntry getJob(int oid)
43             throws TurbineException
44     {
45         return getService().getJob(oid);
46     }
47
48     /**
49      * Add a new job to the queue.
50      *
51      * @param je A JobEntry with the job to add.
52      * @exception TurbineException job could not be added
53      */

54     public static void addJob(JobEntry je)
55             throws TurbineException
56     {
57         getService().addJob(je);
58     }
59
60     /**
61      * Add or update a job
62      *
63      * @param je A JobEntry with the job to modify
64      * @exception TurbineException job could not be updated
65      */

66     public static void updateJob(JobEntry je)
67             throws TurbineException
68     {
69         getService().updateJob(je);
70     }
71
72     /**
73      * Remove a job from the queue.
74      *
75      * @param je A JobEntry with the job to remove.
76      * @exception TurbineException job could not be removed
77      */

78     public static void removeJob(JobEntry je)
79             throws TurbineException
80     {
81         getService().removeJob(je);
82     }
83
84     /**
85      * List jobs in the queue. This is used by the scheduler UI.
86      *
87      * @return A Vector of jobs.
88      */

89     public static List JavaDoc listJobs()
90     {
91         return getService().listJobs();
92     }
93
94     /**
95      * Determines if the scheduler service is currently active.
96      *
97      * @return Status of the scheduler service.
98      */

99     public static boolean isEnabled()
100     {
101         return getService().isEnabled();
102     }
103
104     /**
105      * Starts the scheduler if not already running.
106      */

107     public static void startScheduler()
108     {
109         getService().startScheduler();
110     }
111
112     /**
113      * Stops the scheduler if ti is currently running.
114      */

115     public static void stopScheduler()
116     {
117         getService().stopScheduler();
118     }
119
120     /**
121      * Utility method for accessing the service
122      * implementation
123      *
124      * @return a ScheduleService implementation instance
125      */

126     private static ScheduleService getService()
127     {
128         return (ScheduleService) TurbineServices
129                 .getInstance().getService(ScheduleService.SERVICE_NAME);
130     }
131
132 }
133
Popular Tags