View Javadoc

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