📄 jobstore.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.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.SchedulerException;
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
* @author Eric Mueller
*/
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>
*/
void initialize(ClassLoadHelper loadHelper,
SchedulerSignaler signaler) throws SchedulerConfigException;
/**
* <p>
* Called by the QuartzScheduler to inform the <code>JobStore</code> that
* the scheduler has started.
* </p>
*/
void schedulerStarted() throws SchedulerException ;
/**
* <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>
*/
void shutdown();
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.
*/
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.
*/
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.
*/
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.
*/
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)
*/
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.
*/
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.
*/
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.
*/
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.
*/
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.
*/
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.
*/
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>
*/
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 + -