📄 jobstore.java
字号:
/* * Copyright James House (c) 2001-2004 * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: 1. * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. 2. Redistributions in * binary form must reproduce the above copyright notice, this list of * conditions and the following disclaimer in the documentation and/or other * materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */package org.quartz.spi;import java.util.Set;import org.quartz.Calendar;import org.quartz.JobDetail;import org.quartz.JobPersistenceException;import org.quartz.ObjectAlreadyExistsException;import org.quartz.SchedulerConfigException;import org.quartz.Trigger;import org.quartz.core.SchedulingContext;/** * <p> * The interface to be implemented by classes that want to provide a <code>{@link org.quartz.Job}</code> * and <code>{@link org.quartz.Trigger}</code> storage mechanism for the * <code>{@link org.quartz.core.QuartzScheduler}</code>'s use. * </p> * * <p> * Storage of <code>Job</code> s and <code>Trigger</code> s should be keyed * on the combination of their name and group for uniqueness. * </p> * * @see org.quartz.core.QuartzScheduler * @see org.quartz.Trigger * @see org.quartz.Job * @see org.quartz.JobDetail * @see org.quartz.JobDataMap * @see org.quartz.Calendar * * @author James House */public interface JobStore { /* * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * * Interface. * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ /** * <p> * Called by the QuartzScheduler before the <code>JobStore</code> is * used, in order to give the it a chance to initialize. * </p> */ public void initialize(ClassLoadHelper loadHelper, SchedulerSignaler signaler) throws SchedulerConfigException; /** * <p> * Called by the QuartzScheduler to inform the <code>JobStore</code> that * it should free up all of it's resources because the scheduler is * shutting down. * </p> */ public void shutdown(); public boolean supportsPersistence(); ///////////////////////////////////////////////////////////////////////////// // // Job & Trigger Storage methods // ///////////////////////////////////////////////////////////////////////////// /** * <p> * Store the given <code>{@link org.quartz.JobDetail}</code> and <code>{@link org.quartz.Trigger}</code>. * </p> * * @param newJob * The <code>JobDetail</code> to be stored. * @param newTrigger * The <code>Trigger</code> to be stored. * @throws ObjectAlreadyExistsException * if a <code>Job</code> with the same name/group already * exists. */ public void storeJobAndTrigger(SchedulingContext ctxt, JobDetail newJob, Trigger newTrigger) throws ObjectAlreadyExistsException, JobPersistenceException; /** * <p> * Store the given <code>{@link org.quartz.JobDetail}</code>. * </p> * * @param newJob * The <code>JobDetail</code> to be stored. * @param replaceExisting * If <code>true</code>, any <code>Job</code> existing in the * <code>JobStore</code> with the same name & group should be * over-written. * @throws ObjectAlreadyExistsException * if a <code>Job</code> with the same name/group already * exists, and replaceExisting is set to false. */ public void storeJob(SchedulingContext ctxt, JobDetail newJob, boolean replaceExisting) throws ObjectAlreadyExistsException, JobPersistenceException; /** * <p> * Remove (delete) the <code>{@link org.quartz.Job}</code> with the given * name, and any <code>{@link org.quartz.Trigger}</code> s that reference * it. * </p> * * <p> * If removal of the <code>Job</code> results in an empty group, the * group should be removed from the <code>JobStore</code>'s list of * known group names. * </p> * * @param jobName * The name of the <code>Job</code> to be removed. * @param groupName * The group name of the <code>Job</code> to be removed. * @return <code>true</code> if a <code>Job</code> with the given name & * group was found and removed from the store. */ public boolean removeJob(SchedulingContext ctxt, String jobName, String groupName) throws JobPersistenceException; /** * <p> * Retrieve the <code>{@link org.quartz.JobDetail}</code> for the given * <code>{@link org.quartz.Job}</code>. * </p> * * @param jobName * The name of the <code>Job</code> to be retrieved. * @param groupName * The group name of the <code>Job</code> to be retrieved. * @return The desired <code>Job</code>, or null if there is no match. */ public JobDetail retrieveJob(SchedulingContext ctxt, String jobName, String groupName) throws JobPersistenceException; /** * <p> * Store the given <code>{@link org.quartz.Trigger}</code>. * </p> * * @param newTrigger * The <code>Trigger</code> to be stored. * @param replaceExisting * If <code>true</code>, any <code>Trigger</code> existing in * the <code>JobStore</code> with the same name & group should * be over-written. * @throws ObjectAlreadyExistsException * if a <code>Trigger</code> with the same name/group already * exists, and replaceExisting is set to false. * * @see #pauseTriggerGroup(SchedulingContext, String) */ public void storeTrigger(SchedulingContext ctxt, Trigger newTrigger, boolean replaceExisting) throws ObjectAlreadyExistsException, JobPersistenceException; /** * <p> * Remove (delete) the <code>{@link org.quartz.Trigger}</code> with the * given name. * </p> * * <p> * If removal of the <code>Trigger</code> results in an empty group, the * group should be removed from the <code>JobStore</code>'s list of * known group names. * </p> * * <p> * If removal of the <code>Trigger</code> results in an 'orphaned' <code>Job</code> * that is not 'durable', then the <code>Job</code> should be deleted * also. * </p> * * @param triggerName * The name of the <code>Trigger</code> to be removed. * @param groupName * The group name of the <code>Trigger</code> to be removed. * @return <code>true</code> if a <code>Trigger</code> with the given * name & group was found and removed from the store. */ public boolean removeTrigger(SchedulingContext ctxt, String triggerName, String groupName) throws JobPersistenceException; /** * <p> * Remove (delete) the <code>{@link org.quartz.Trigger}</code> with the * given name, and store the new given one - which must be associated * with the same job. * </p> * * @param triggerName * The name of the <code>Trigger</code> to be removed. * @param groupName * The group name of the <code>Trigger</code> to be removed. * @param newTrigger * The new <code>Trigger</code> to be stored. * @return <code>true</code> if a <code>Trigger</code> with the given * name & group was found and removed from the store. */ public boolean replaceTrigger(SchedulingContext ctxt, String triggerName, String groupName, Trigger newTrigger) throws JobPersistenceException; /** * <p> * Retrieve the given <code>{@link org.quartz.Trigger}</code>. * </p> * * @param triggerName * The name of the <code>Trigger</code> to be retrieved. * @param groupName * The group name of the <code>Trigger</code> to be retrieved. * @return The desired <code>Trigger</code>, or null if there is no * match. */ public Trigger retrieveTrigger(SchedulingContext ctxt, String triggerName, String groupName) throws JobPersistenceException; /** * <p> * Store the given <code>{@link org.quartz.Calendar}</code>. * </p> * * @param calendar * The <code>Calendar</code> to be stored. * @param replaceExisting * If <code>true</code>, any <code>Calendar</code> existing * in the <code>JobStore</code> with the same name & group * should be over-written. * @param updateTriggers * If <code>true</code>, any <code>Trigger</code>s existing * in the <code>JobStore</code> that reference an existing * Calendar with the same name with have their next fire time * re-computed with the new <code>Calendar</code>. * @throws ObjectAlreadyExistsException * if a <code>Calendar</code> with the same name already * exists, and replaceExisting is set to false. */ public void storeCalendar(SchedulingContext ctxt, String name, Calendar calendar, boolean replaceExisting, boolean updateTriggers) throws ObjectAlreadyExistsException, JobPersistenceException; /** * <p> * Remove (delete) the <code>{@link org.quartz.Calendar}</code> with the * given name. * </p> * * <p> * If removal of the <code>Calendar</code> would result in * <code.Trigger</code>s pointing to non-existent calendars, then a * <code>JobPersistenceException</code> will be thrown.</p> * * * @param calName The name of the <code>Calendar</code> to be removed. * @return <code>true</code> if a <code>Calendar</code> with the given name * was found and removed from the store. */ public boolean removeCalendar(SchedulingContext ctxt, String calName) throws JobPersistenceException; /** * <p> * Retrieve the given <code>{@link org.quartz.Trigger}</code>. * </p> * * @param calName * The name of the <code>Calendar</code> to be retrieved. * @return The desired <code>Calendar</code>, or null if there is no * match. */ public Calendar retrieveCalendar(SchedulingContext ctxt, String calName) throws JobPersistenceException; ///////////////////////////////////////////////////////////////////////////// // // Informational methods // ///////////////////////////////////////////////////////////////////////////// /** * <p> * Get the number of <code>{@link org.quartz.Job}</code> s that are * stored in the <code>JobsStore</code>. * </p> */ public int getNumberOfJobs(SchedulingContext ctxt) throws JobPersistenceException; /** * <p> * Get the number of <code>{@link org.quartz.Trigger}</code> s that are * stored in the <code>JobsStore</code>. * </p> */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -