001: package org.apache.turbine.services.schedule;
002:
003: /*
004: * Licensed to the Apache Software Foundation (ASF) under one
005: * or more contributor license agreements. See the NOTICE file
006: * distributed with this work for additional information
007: * regarding copyright ownership. The ASF licenses this file
008: * to you under the Apache License, Version 2.0 (the
009: * "License"); you may not use this file except in compliance
010: * with the License. You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing,
015: * software distributed under the License is distributed on an
016: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017: * KIND, either express or implied. See the License for the
018: * specific language governing permissions and limitations
019: * under the License.
020: */
021:
022: import java.util.List;
023:
024: import org.apache.turbine.services.TurbineServices;
025: import org.apache.turbine.util.TurbineException;
026:
027: /**
028: * This is a fascade class to provide easy access to the Scheduler
029: * service. All access methods are static and act upon the current
030: * instance of the scheduler service.
031: *
032: * @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a>
033: * @version $Id: TurbineScheduler.java 534527 2007-05-02 16:10:59Z tv $
034: * @see org.apache.turbine.services.schedule.ScheduleService
035: */
036: public abstract class TurbineScheduler {
037: /**
038: * Get a specific Job from Storage.
039: *
040: * @param oid The int id for the job.
041: * @return A JobEntry.
042: * @exception TurbineException job could not be retrieved
043: */
044: public static JobEntry getJob(int oid) throws TurbineException {
045: return getService().getJob(oid);
046: }
047:
048: /**
049: * Add a new job to the queue.
050: *
051: * @param je A JobEntry with the job to add.
052: * @exception TurbineException job could not be added
053: */
054: public static void addJob(JobEntry je) throws TurbineException {
055: getService().addJob(je);
056: }
057:
058: /**
059: * Add or update a job
060: *
061: * @param je A JobEntry with the job to modify
062: * @exception TurbineException job could not be updated
063: */
064: public static void updateJob(JobEntry je) throws TurbineException {
065: getService().updateJob(je);
066: }
067:
068: /**
069: * Remove a job from the queue.
070: *
071: * @param je A JobEntry with the job to remove.
072: * @exception TurbineException job could not be removed
073: */
074: public static void removeJob(JobEntry je) throws TurbineException {
075: getService().removeJob(je);
076: }
077:
078: /**
079: * List jobs in the queue. This is used by the scheduler UI.
080: *
081: * @return A Vector of jobs.
082: */
083: public static List listJobs() {
084: return getService().listJobs();
085: }
086:
087: /**
088: * Determines if the scheduler service is currently active.
089: *
090: * @return Status of the scheduler service.
091: */
092: public static boolean isEnabled() {
093: return getService().isEnabled();
094: }
095:
096: /**
097: * Starts the scheduler if not already running.
098: */
099: public static void startScheduler() {
100: getService().startScheduler();
101: }
102:
103: /**
104: * Stops the scheduler if ti is currently running.
105: */
106: public static void stopScheduler() {
107: getService().stopScheduler();
108: }
109:
110: /**
111: * Utility method for accessing the service
112: * implementation
113: *
114: * @return a ScheduleService implementation instance
115: */
116: private static ScheduleService getService() {
117: return (ScheduleService) TurbineServices.getInstance()
118: .getService(ScheduleService.SERVICE_NAME);
119: }
120:
121: }
|