All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.quartz.impl.StdScheduler Maven / Gradle / Ivy

There is a newer version: 2.3.2_1
Show newest version
/* 
 * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 
 * use this file except in compliance with the License. You may obtain a copy 
 * of the License at 
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0 
 *   
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 
 * License for the specific language governing permissions and limitations 
 * under the License.
 * 
 */

package org.quartz.impl;

import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.quartz.Calendar;
import org.quartz.JobDataMap;
import org.quartz.JobDetail;
import org.quartz.JobExecutionContext;
import org.quartz.JobKey;
import org.quartz.ListenerManager;
import org.quartz.Scheduler;
import org.quartz.SchedulerContext;
import org.quartz.SchedulerException;
import org.quartz.SchedulerMetaData;
import org.quartz.Trigger;
import org.quartz.TriggerKey;
import org.quartz.UnableToInterruptJobException;
import org.quartz.Trigger.TriggerState;
import org.quartz.core.QuartzScheduler;
import org.quartz.impl.matchers.GroupMatcher;
import org.quartz.spi.JobFactory;

/**
 * 

* An implementation of the Scheduler interface that directly * proxies all method calls to the equivalent call on a given QuartzScheduler * instance. *

* * @see org.quartz.Scheduler * @see org.quartz.core.QuartzScheduler * * @author James House */ public class StdScheduler implements Scheduler { /* * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * * Data members. * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ private QuartzScheduler sched; /* * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * * Constructors. * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ /** *

* Construct a StdScheduler instance to proxy the given * QuartzScheduler instance, and with the given SchedulingContext. *

*/ public StdScheduler(QuartzScheduler sched) { this.sched = sched; } /* * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * * Interface. * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ /** *

* Returns the name of the Scheduler. *

*/ public String getSchedulerName() { return sched.getSchedulerName(); } /** *

* Returns the instance Id of the Scheduler. *

*/ public String getSchedulerInstanceId() { return sched.getSchedulerInstanceId(); } public SchedulerMetaData getMetaData() { return new SchedulerMetaData(getSchedulerName(), getSchedulerInstanceId(), getClass(), false, isStarted(), isInStandbyMode(), isShutdown(), sched.runningSince(), sched.numJobsExecuted(), sched.getJobStoreClass(), sched.supportsPersistence(), sched.isClustered(), sched.getThreadPoolClass(), sched.getThreadPoolSize(), sched.getVersion()); } /** *

* Returns the SchedulerContext of the Scheduler. *

*/ public SchedulerContext getContext() throws SchedulerException { return sched.getSchedulerContext(); } /////////////////////////////////////////////////////////////////////////// /// /// Schedululer State Management Methods /// /////////////////////////////////////////////////////////////////////////// /** *

* Calls the equivalent method on the 'proxied' QuartzScheduler. *

*/ public void start() throws SchedulerException { sched.start(); } /** *

* Calls the equivalent method on the 'proxied' QuartzScheduler. *

*/ public void startDelayed(int seconds) throws SchedulerException { sched.startDelayed(seconds); } /** *

* Calls the equivalent method on the 'proxied' QuartzScheduler. *

*/ public void standby() { sched.standby(); } /** * Whether the scheduler has been started. * *

* Note: This only reflects whether {@link #start()} has ever * been called on this Scheduler, so it will return true even * if the Scheduler is currently in standby mode or has been * since shutdown. *

* * @see #start() * @see #isShutdown() * @see #isInStandbyMode() */ public boolean isStarted() { return (sched.runningSince() != null); } /** *

* Calls the equivalent method on the 'proxied' QuartzScheduler. *

*/ public boolean isInStandbyMode() { return sched.isInStandbyMode(); } /** *

* Calls the equivalent method on the 'proxied' QuartzScheduler. *

*/ public void shutdown() { sched.shutdown(); } /** *

* Calls the equivalent method on the 'proxied' QuartzScheduler. *

*/ public void shutdown(boolean waitForJobsToComplete) { sched.shutdown(waitForJobsToComplete); } /** *

* Calls the equivalent method on the 'proxied' QuartzScheduler. *

*/ public boolean isShutdown() { return sched.isShutdown(); } /** *

* Calls the equivalent method on the 'proxied' QuartzScheduler. *

*/ public List getCurrentlyExecutingJobs() { return sched.getCurrentlyExecutingJobs(); } /////////////////////////////////////////////////////////////////////////// /// /// Scheduling-related Methods /// /////////////////////////////////////////////////////////////////////////// /** *

* Calls the equivalent method on the 'proxied' QuartzScheduler. *

*/ public void clear() throws SchedulerException { sched.clear(); } /** *

* Calls the equivalent method on the 'proxied' QuartzScheduler. *

*/ public Date scheduleJob(JobDetail jobDetail, Trigger trigger) throws SchedulerException { return sched.scheduleJob(jobDetail, trigger); } /** *

* Calls the equivalent method on the 'proxied' QuartzScheduler. *

*/ public Date scheduleJob(Trigger trigger) throws SchedulerException { return sched.scheduleJob(trigger); } /** *

* Calls the equivalent method on the 'proxied' QuartzScheduler. *

*/ public void addJob(JobDetail jobDetail, boolean replace) throws SchedulerException { sched.addJob(jobDetail, replace); } public void addJob(JobDetail jobDetail, boolean replace, boolean storeNonDurableWhileAwaitingScheduling) throws SchedulerException { sched.addJob(jobDetail, replace, storeNonDurableWhileAwaitingScheduling); } public boolean deleteJobs(List jobKeys) throws SchedulerException { return sched.deleteJobs(jobKeys); } public void scheduleJobs(Map> triggersAndJobs, boolean replace) throws SchedulerException { sched.scheduleJobs(triggersAndJobs, replace); } public void scheduleJob(JobDetail jobDetail, Set triggersForJob, boolean replace) throws SchedulerException { sched.scheduleJob(jobDetail, triggersForJob, replace); } public boolean unscheduleJobs(List triggerKeys) throws SchedulerException { return sched.unscheduleJobs(triggerKeys); } /** *

* Calls the equivalent method on the 'proxied' QuartzScheduler. *

*/ public boolean deleteJob(JobKey jobKey) throws SchedulerException { return sched.deleteJob(jobKey); } /** *

* Calls the equivalent method on the 'proxied' QuartzScheduler. *

*/ public boolean unscheduleJob(TriggerKey triggerKey) throws SchedulerException { return sched.unscheduleJob(triggerKey); } /** *

* Calls the equivalent method on the 'proxied' QuartzScheduler. *

*/ public Date rescheduleJob(TriggerKey triggerKey, Trigger newTrigger) throws SchedulerException { return sched.rescheduleJob(triggerKey, newTrigger); } /** *

* Calls the equivalent method on the 'proxied' QuartzScheduler. *

*/ public void triggerJob(JobKey jobKey) throws SchedulerException { triggerJob(jobKey, null); } /** *

* Calls the equivalent method on the 'proxied' QuartzScheduler. *

*/ public void triggerJob(JobKey jobKey, JobDataMap data) throws SchedulerException { sched.triggerJob(jobKey, data); } /** *

* Calls the equivalent method on the 'proxied' QuartzScheduler. *

*/ public void pauseTrigger(TriggerKey triggerKey) throws SchedulerException { sched.pauseTrigger(triggerKey); } /** *

* Calls the equivalent method on the 'proxied' QuartzScheduler. *

*/ public void pauseTriggers(GroupMatcher matcher) throws SchedulerException { sched.pauseTriggers(matcher); } /** *

* Calls the equivalent method on the 'proxied' QuartzScheduler. *

*/ public void pauseJob(JobKey jobKey) throws SchedulerException { sched.pauseJob(jobKey); } /** * @see org.quartz.Scheduler#getPausedTriggerGroups() */ public Set getPausedTriggerGroups() throws SchedulerException { return sched.getPausedTriggerGroups(); } /** *

* Calls the equivalent method on the 'proxied' QuartzScheduler. *

*/ public void pauseJobs(GroupMatcher matcher) throws SchedulerException { sched.pauseJobs(matcher); } /** *

* Calls the equivalent method on the 'proxied' QuartzScheduler. *

*/ public void resumeTrigger(TriggerKey triggerKey) throws SchedulerException { sched.resumeTrigger(triggerKey); } /** *

* Calls the equivalent method on the 'proxied' QuartzScheduler. *

*/ public void resumeTriggers(GroupMatcher matcher) throws SchedulerException { sched.resumeTriggers(matcher); } /** *

* Calls the equivalent method on the 'proxied' QuartzScheduler. *

*/ public void resumeJob(JobKey jobKey) throws SchedulerException { sched.resumeJob(jobKey); } /** *

* Calls the equivalent method on the 'proxied' QuartzScheduler. *

*/ public void resumeJobs(GroupMatcher matcher) throws SchedulerException { sched.resumeJobs(matcher); } /** *

* Calls the equivalent method on the 'proxied' QuartzScheduler. *

*/ public void pauseAll() throws SchedulerException { sched.pauseAll(); } /** *

* Calls the equivalent method on the 'proxied' QuartzScheduler. *

*/ public void resumeAll() throws SchedulerException { sched.resumeAll(); } /** *

* Calls the equivalent method on the 'proxied' QuartzScheduler. *

*/ public List getJobGroupNames() throws SchedulerException { return sched.getJobGroupNames(); } /** *

* Calls the equivalent method on the 'proxied' QuartzScheduler. *

*/ public List getTriggersOfJob(JobKey jobKey) throws SchedulerException { return sched.getTriggersOfJob(jobKey); } /** *

* Calls the equivalent method on the 'proxied' QuartzScheduler. *

*/ public Set getJobKeys(GroupMatcher matcher) throws SchedulerException { return sched.getJobKeys(matcher); } /** *

* Calls the equivalent method on the 'proxied' QuartzScheduler. *

*/ public List getTriggerGroupNames() throws SchedulerException { return sched.getTriggerGroupNames(); } /** *

* Calls the equivalent method on the 'proxied' QuartzScheduler. *

*/ public Set getTriggerKeys(GroupMatcher matcher) throws SchedulerException { return sched.getTriggerKeys(matcher); } /** *

* Calls the equivalent method on the 'proxied' QuartzScheduler. *

*/ public JobDetail getJobDetail(JobKey jobKey) throws SchedulerException { return sched.getJobDetail(jobKey); } /** *

* Calls the equivalent method on the 'proxied' QuartzScheduler. *

*/ public Trigger getTrigger(TriggerKey triggerKey) throws SchedulerException { return sched.getTrigger(triggerKey); } /** *

* Calls the equivalent method on the 'proxied' QuartzScheduler. *

*/ public TriggerState getTriggerState(TriggerKey triggerKey) throws SchedulerException { return sched.getTriggerState(triggerKey); } /** * Reset the current state of the identified {@link Trigger} * from {@link TriggerState#ERROR} to {@link TriggerState#NORMAL} or * {@link TriggerState#PAUSED} as appropriate. * *

Only affects triggers that are in ERROR state - if identified trigger is not * in that state then the result is a no-op.

* *

The result will be the trigger returning to the normal, waiting to * be fired state, unless the trigger's group has been paused, in which * case it will go into the PAUSED state.

* * @see Trigger.TriggerState */ public void resetTriggerFromErrorState(TriggerKey triggerKey) throws SchedulerException { sched.resetTriggerFromErrorState(triggerKey); } /** *

* Calls the equivalent method on the 'proxied' QuartzScheduler. *

*/ public void addCalendar(String calName, Calendar calendar, boolean replace, boolean updateTriggers) throws SchedulerException { sched.addCalendar(calName, calendar, replace, updateTriggers); } /** *

* Calls the equivalent method on the 'proxied' QuartzScheduler. *

*/ public boolean deleteCalendar(String calName) throws SchedulerException { return sched.deleteCalendar(calName); } /** *

* Calls the equivalent method on the 'proxied' QuartzScheduler. *

*/ public Calendar getCalendar(String calName) throws SchedulerException { return sched.getCalendar(calName); } /** *

* Calls the equivalent method on the 'proxied' QuartzScheduler. *

*/ public List getCalendarNames() throws SchedulerException { return sched.getCalendarNames(); } /** *

* Calls the equivalent method on the 'proxied' QuartzScheduler. *

*/ public boolean checkExists(JobKey jobKey) throws SchedulerException { return sched.checkExists(jobKey); } /** *

* Calls the equivalent method on the 'proxied' QuartzScheduler. *

*/ public boolean checkExists(TriggerKey triggerKey) throws SchedulerException { return sched.checkExists(triggerKey); } /////////////////////////////////////////////////////////////////////////// /// /// Other Methods /// /////////////////////////////////////////////////////////////////////////// /** * @see org.quartz.Scheduler#setJobFactory(org.quartz.spi.JobFactory) */ public void setJobFactory(JobFactory factory) throws SchedulerException { sched.setJobFactory(factory); } /** * @see org.quartz.Scheduler#getListenerManager() */ public ListenerManager getListenerManager() throws SchedulerException { return sched.getListenerManager(); } public boolean interrupt(JobKey jobKey) throws UnableToInterruptJobException { return sched.interrupt(jobKey); } public boolean interrupt(String fireInstanceId) throws UnableToInterruptJobException { return sched.interrupt(fireInstanceId); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy