📄 stdscheduler.java
字号:
/*
* Copyright 2004-2005 OpenSymphony
*
* 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.
*
*/
/*
* Previously Copyright (c) 2001-2004 James House
*/
package org.quartz.impl;
import java.util.Date;
import java.util.List;
import java.util.Set;
import org.quartz.Calendar;
import org.quartz.JobDataMap;
import org.quartz.JobDetail;
import org.quartz.JobListener;
import org.quartz.Scheduler;
import org.quartz.SchedulerContext;
import org.quartz.SchedulerException;
import org.quartz.SchedulerListener;
import org.quartz.SchedulerMetaData;
import org.quartz.Trigger;
import org.quartz.TriggerListener;
import org.quartz.UnableToInterruptJobException;
import org.quartz.core.QuartzScheduler;
import org.quartz.core.SchedulingContext;
import org.quartz.spi.JobFactory;
/**
* <p>
* An implementation of the <code>Scheduler</code> interface that directly
* proxies all method calls to the equivalent call on a given <code>QuartzScheduler</code>
* instance.
* </p>
*
* @see org.quartz.Scheduler
* @see org.quartz.core.QuartzScheduler
* @see org.quartz.core.SchedulingContext
*
* @author James House
*/
public class StdScheduler implements Scheduler {
/*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
* Data members.
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
private QuartzScheduler sched;
private SchedulingContext schedCtxt;
/*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
* Constructors.
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
/**
* <p>
* Construct a <code>StdScheduler</code> instance to proxy the given
* <code>QuartzScheduler</code> instance, and with the given <code>SchedulingContext</code>.
* </p>
*/
public StdScheduler(QuartzScheduler sched, SchedulingContext schedCtxt) {
this.sched = sched;
this.schedCtxt = schedCtxt;
}
/*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
* Interface.
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
/**
* <p>
* Returns the name of the <code>Scheduler</code>.
* </p>
*/
public String getSchedulerName() {
return sched.getSchedulerName();
}
/**
* <p>
* Returns the instance Id of the <code>Scheduler</code>.
* </p>
*/
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.getThreadPoolClass(),
sched.getThreadPoolSize(), sched.getVersion());
}
/**
* <p>
* Returns the <code>SchedulerContext</code> of the <code>Scheduler</code>.
* </p>
*/
public SchedulerContext getContext() throws SchedulerException {
return sched.getSchedulerContext();
}
///////////////////////////////////////////////////////////////////////////
///
/// Schedululer State Management Methods
///
///////////////////////////////////////////////////////////////////////////
/**
* <p>
* Calls the equivalent method on the 'proxied' <code>QuartzScheduler</code>.
* </p>
*/
public void start() throws SchedulerException {
sched.start();
}
/**
* <p>
* Calls the equivalent method on the 'proxied' <code>QuartzScheduler</code>.
* </p>
*/
public void startDelayed(int seconds) throws SchedulerException {
sched.startDelayed(seconds);
}
/**
* <p>
* Calls the equivalent method on the 'proxied' <code>QuartzScheduler</code>.
* </p>
*
* @deprecated
* @see #standby()
*/
public void pause() {
this.standby();
}
/**
* <p>
* Calls the equivalent method on the 'proxied' <code>QuartzScheduler</code>.
* </p>
*/
public void standby() {
sched.standby();
}
/**
* Whether the scheduler has been started.
*
* <p>
* Note: This only reflects whether <code>{@link #start()}</code> has ever
* been called on this Scheduler, so it will return <code>true</code> even
* if the <code>Scheduler</code> is currently in standby mode or has been
* since shutdown.
* </p>
*
* @see #start()
* @see #isShutdown()
* @see #isInStandbyMode()
*/
public boolean isStarted() {
return (sched.runningSince() != null);
}
/**
* <p>
* Calls the equivalent method on the 'proxied' <code>QuartzScheduler</code>.
* </p>
*/
public boolean isInStandbyMode() {
return sched.isInStandbyMode();
}
/**
* @deprecated
*/
public boolean isPaused() {
return isInStandbyMode();
}
/**
* <p>
* Calls the equivalent method on the 'proxied' <code>QuartzScheduler</code>.
* </p>
*/
public void shutdown() {
sched.shutdown();
}
/**
* <p>
* Calls the equivalent method on the 'proxied' <code>QuartzScheduler</code>.
* </p>
*/
public void shutdown(boolean waitForJobsToComplete) {
sched.shutdown(waitForJobsToComplete);
}
/**
* <p>
* Calls the equivalent method on the 'proxied' <code>QuartzScheduler</code>.
* </p>
*/
public boolean isShutdown() {
return sched.isShutdown();
}
/**
* <p>
* Calls the equivalent method on the 'proxied' <code>QuartzScheduler</code>.
* </p>
*/
public List getCurrentlyExecutingJobs() {
return sched.getCurrentlyExecutingJobs();
}
///////////////////////////////////////////////////////////////////////////
///
/// Scheduling-related Methods
///
///////////////////////////////////////////////////////////////////////////
/**
* <p>
* Calls the equivalent method on the 'proxied' <code>QuartzScheduler</code>,
* passing the <code>SchedulingContext</code> associated with this
* instance.
* </p>
*/
public Date scheduleJob(JobDetail jobDetail, Trigger trigger)
throws SchedulerException {
return sched.scheduleJob(schedCtxt, jobDetail, trigger);
}
/**
* <p>
* Calls the equivalent method on the 'proxied' <code>QuartzScheduler</code>,
* passing the <code>SchedulingContext</code> associated with this
* instance.
* </p>
*/
public Date scheduleJob(Trigger trigger) throws SchedulerException {
return sched.scheduleJob(schedCtxt, trigger);
}
/**
* <p>
* Calls the equivalent method on the 'proxied' <code>QuartzScheduler</code>,
* passing the <code>SchedulingContext</code> associated with this
* instance.
* </p>
*/
public void addJob(JobDetail jobDetail, boolean replace)
throws SchedulerException {
sched.addJob(schedCtxt, jobDetail, replace);
}
/**
* <p>
* Calls the equivalent method on the 'proxied' <code>QuartzScheduler</code>,
* passing the <code>SchedulingContext</code> associated with this
* instance.
* </p>
*/
public boolean deleteJob(String jobName, String groupName)
throws SchedulerException {
return sched.deleteJob(schedCtxt, jobName, groupName);
}
/**
* <p>
* Calls the equivalent method on the 'proxied' <code>QuartzScheduler</code>,
* passing the <code>SchedulingContext</code> associated with this
* instance.
* </p>
*/
public boolean unscheduleJob(String triggerName, String groupName)
throws SchedulerException {
return sched.unscheduleJob(schedCtxt, triggerName, groupName);
}
/**
* <p>
* Calls the equivalent method on the 'proxied' <code>QuartzScheduler</code>,
* passing the <code>SchedulingContext</code> associated with this
* instance.
* </p>
*/
public Date rescheduleJob(String triggerName,
String groupName, Trigger newTrigger) throws SchedulerException {
return sched.rescheduleJob(schedCtxt, triggerName, groupName, newTrigger);
}
/**
* <p>
* Calls the equivalent method on the 'proxied' <code>QuartzScheduler</code>,
* passing the <code>SchedulingContext</code> associated with this
* instance.
* </p>
*/
public void triggerJob(String jobName, String groupName)
throws SchedulerException {
triggerJob(jobName, groupName, null);
}
/**
* <p>
* Calls the equivalent method on the 'proxied' <code>QuartzScheduler</code>,
* passing the <code>SchedulingContext</code> associated with this
* instance.
* </p>
*/
public void triggerJob(String jobName, String groupName, JobDataMap data)
throws SchedulerException {
sched.triggerJob(schedCtxt, jobName, groupName, data);
}
/**
* <p>
* Calls the equivalent method on the 'proxied' <code>QuartzScheduler</code>,
* passing the <code>SchedulingContext</code> associated with this
* instance.
* </p>
*/
public void triggerJobWithVolatileTrigger(String jobName, String groupName)
throws SchedulerException {
triggerJobWithVolatileTrigger(jobName, groupName, null);
}
/**
* <p>
* Calls the equivalent method on the 'proxied' <code>QuartzScheduler</code>,
* passing the <code>SchedulingContext</code> associated with this
* instance.
* </p>
*/
public void triggerJobWithVolatileTrigger(String jobName, String groupName, JobDataMap data)
throws SchedulerException {
sched.triggerJobWithVolatileTrigger(schedCtxt, jobName, groupName, data);
}
/**
* <p>
* Calls the equivalent method on the 'proxied' <code>QuartzScheduler</code>,
* passing the <code>SchedulingContext</code> associated with this
* instance.
* </p>
*/
public void pauseTrigger(String triggerName, String groupName)
throws SchedulerException {
sched.pauseTrigger(schedCtxt, triggerName, groupName);
}
/**
* <p>
* Calls the equivalent method on the 'proxied' <code>QuartzScheduler</code>,
* passing the <code>SchedulingContext</code> associated with this
* instance.
* </p>
*/
public void pauseTriggerGroup(String groupName) throws SchedulerException {
sched.pauseTriggerGroup(schedCtxt, groupName);
}
/**
* <p>
* Calls the equivalent method on the 'proxied' <code>QuartzScheduler</code>,
* passing the <code>SchedulingContext</code> associated with this
* instance.
* </p>
*/
public void pauseJob(String jobName, String groupName)
throws SchedulerException {
sched.pauseJob(schedCtxt, jobName, groupName);
}
/**
* @see org.quartz.Scheduler#getPausedTriggerGroups()
*/
public Set getPausedTriggerGroups() throws SchedulerException {
return sched.getPausedTriggerGroups(schedCtxt);
}
/**
* <p>
* Calls the equivalent method on the 'proxied' <code>QuartzScheduler</code>,
* passing the <code>SchedulingContext</code> associated with this
* instance.
* </p>
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -