|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.xml.sax.helpers.DefaultHandler
org.quartz.xml.JobSchedulingDataProcessor
Parses an XML file that declares Jobs and their schedules (Triggers).
The xml document must conform to the format defined in
"job_scheduling_data_1_2.dtd" or "job_scheduling_data_1_2.xsd"
After creating an instance of this class, you should call one of the processFile()
functions, after which you may call the getScheduledJobs()
function to get a handle to the defined Jobs and Triggers, which can then be
scheduled with the Scheduler
. Alternatively, you could call
the processFileAndScheduleJobs()
function to do all of this
in one step.
The same instance can be used again and again, with the list of defined Jobs
being cleared each time you call a processFile
method,
however a single instance is not thread-safe.
Nested Class Summary | |
class |
JobSchedulingDataProcessor.CalendarRuleSet
RuleSet for common Calendar tags. |
class |
JobSchedulingDataProcessor.DateConverter
Standard Converter implementation that converts an incoming
String into a java.util.Date object, optionally using a
default value or throwing a ConversionException if a conversion
error occurs. |
class |
JobSchedulingDataProcessor.MisfireInstructionRule
This rule translates the trigger misfire instruction constant name into its corresponding value. |
class |
JobSchedulingDataProcessor.SimpleConverterRule
This rule is needed to fix QUARTZ-153. |
class |
JobSchedulingDataProcessor.TimeZoneConverter
Standard Converter implementation that converts an incoming
String into a java.util.TimeZone object throwing a
ConversionException if a conversion error occurs. |
class |
JobSchedulingDataProcessor.TriggerRuleSet
RuleSet for common Trigger tags. |
Constructor Summary | |
JobSchedulingDataProcessor()
Constructor for QuartzMetaDataProcessor. |
|
JobSchedulingDataProcessor(boolean useContextClassLoader,
boolean validating,
boolean validatingSchema)
Constructor for QuartzMetaDataProcessor. |
Method Summary | |
void |
addCalendar(Scheduler sched,
CalendarBundle calendarBundle)
Adds a calendar. |
void |
addCalendarToSchedule(CalendarBundle cal)
|
protected boolean |
addCustomDigesterRules(org.apache.commons.digester.Digester digester)
Template method provided as a hook for those who wish to extend this class and add more functionality. |
protected void |
addDefaultDigesterRules(org.apache.commons.digester.Digester digester)
Add the default set of digest rules |
void |
addJobToSchedule(JobSchedulingBundle job)
|
void |
addListenerToSchedule(JobListener listener)
|
protected void |
addScheduledJob(JobSchedulingBundle job)
Adds a scheduled job. |
protected void |
addValidationException(SAXException e)
Adds a detected validation exception. |
protected void |
clearValidationExceptions()
Resets the the number of detected validation exceptions. |
void |
error(SAXParseException e)
ErrorHandler interface. |
void |
fatalError(SAXParseException e)
ErrorHandler interface. |
protected InputStream |
getInputStream(String fileName)
Returns an InputStream from the fileName as a resource. |
protected static org.apache.commons.logging.Log |
getLog()
|
boolean |
getOverWriteExistingJobs()
Returns whether to overwrite existing jobs. |
JobSchedulingBundle |
getScheduledJob(String name)
Returns a JobSchedulingBundle for the job name. |
Map |
getScheduledJobs()
Returns a Map of scheduled jobs. |
boolean |
getUseContextClassLoader()
Returns whether to use the context class loader. |
protected void |
initDigester(boolean useContextClassLoader,
boolean validating,
boolean validatingSchema)
Initializes the digester. |
protected void |
initSchemaValidation(boolean validatingSchema)
Initializes the digester for XML Schema validation. |
protected void |
maybeThrowValidationException()
Throws a ValidationException if the number of validationExceptions detected is greater than zero. |
void |
processFile()
Process the xml file in the default location (a file named "quartz_jobs.xml" in the current working directory). |
void |
processFile(String fileName)
Process the xml file named fileName . |
void |
processFile(String fileName,
String systemId)
Process the xmlfile named fileName with the given system
ID. |
void |
processFileAndScheduleJobs(Scheduler sched,
boolean overWriteExistingJobs)
Process the xml file in the default location, and schedule all of the jobs defined within it. |
void |
processFileAndScheduleJobs(String fileName,
Scheduler sched,
boolean overWriteExistingJobs)
Process the xml file in the given location, and schedule all of the jobs defined within it. |
void |
processFileAndScheduleJobs(String fileName,
String systemId,
Scheduler sched,
boolean overWriteExistingJobs)
Process the xml file in the given location, and schedule all of the jobs defined within it. |
void |
processStream(InputStream stream,
String systemId)
Process the xmlfile named fileName with the given system
ID. |
InputSource |
resolveEntity(String publicId,
String systemId)
EntityResolver interface. |
void |
scheduleJob(JobSchedulingBundle job)
Schedules a given job and trigger (both wrapped by a JobSchedulingBundle ). |
void |
scheduleJob(JobSchedulingBundle job,
Scheduler sched,
boolean localOverWriteExistingJobs)
Schedules a given job and trigger (both wrapped by a JobSchedulingBundle ). |
void |
scheduleJobs(Map jobBundles,
Scheduler sched,
boolean overWriteExistingJobs)
Add the Jobs and Triggers defined in the given map of JobSchedulingBundle
s to the given scheduler. |
void |
setOverWriteExistingJobs(boolean overWriteExistingJobs)
Sets whether to overwrite existing jobs. |
void |
setUseContextClassLoader(boolean useContextClassLoader)
Sets whether to use the context class loader. |
void |
warning(SAXParseException e)
ErrorHandler interface. |
Methods inherited from class org.xml.sax.helpers.DefaultHandler |
characters, endDocument, endElement, endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startElement, startPrefixMapping, unparsedEntityDecl |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String QUARTZ_PUBLIC_ID
public static final String QUARTZ_SYSTEM_ID
public static final String QUARTZ_DTD
public static final String QUARTZ_NS
public static final String QUARTZ_SCHEMA
public static final String QUARTZ_XSD
public static final String QUARTZ_SYSTEM_ID_DIR_PROP
public static final String QUARTZ_XML_FILE_NAME
public static final String QUARTZ_SYSTEM_ID_PREFIX
protected static final String TAG_QUARTZ
protected static final String TAG_OVERWRITE_EXISTING_JOBS
protected static final String TAG_JOB_LISTENER
protected static final String TAG_CALENDAR
protected static final String TAG_CLASS_NAME
protected static final String TAG_DESCRIPTION
protected static final String TAG_BASE_CALENDAR
protected static final String TAG_MISFIRE_INSTRUCTION
protected static final String TAG_CALENDAR_NAME
protected static final String TAG_JOB
protected static final String TAG_JOB_DETAIL
protected static final String TAG_NAME
protected static final String TAG_GROUP
protected static final String TAG_JOB_CLASS
protected static final String TAG_JOB_LISTENER_REF
protected static final String TAG_VOLATILITY
protected static final String TAG_DURABILITY
protected static final String TAG_RECOVER
protected static final String TAG_JOB_DATA_MAP
protected static final String TAG_ENTRY
protected static final String TAG_KEY
protected static final String TAG_ALLOWS_TRANSIENT_DATA
protected static final String TAG_VALUE
protected static final String TAG_TRIGGER
protected static final String TAG_SIMPLE
protected static final String TAG_CRON
protected static final String TAG_JOB_NAME
protected static final String TAG_JOB_GROUP
protected static final String TAG_START_TIME
protected static final String TAG_END_TIME
protected static final String TAG_REPEAT_COUNT
protected static final String TAG_REPEAT_INTERVAL
protected static final String TAG_CRON_EXPRESSION
protected static final String TAG_TIME_ZONE
protected static final String XSD_DATE_FORMAT
See http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/#dateTime
protected static final String DTD_DATE_FORMAT
protected Map scheduledJobs
protected List jobsToSchedule
protected List calsToSchedule
protected List listenersToSchedule
protected Collection validationExceptions
protected org.apache.commons.digester.Digester digester
Constructor Detail |
public JobSchedulingDataProcessor()
public JobSchedulingDataProcessor(boolean useContextClassLoader, boolean validating, boolean validatingSchema)
useContextClassLoader
- whether or not to use the context class loader.validating
- whether or not to validate XML.validatingSchema
- whether or not to validate XML schema.Method Detail |
protected void initDigester(boolean useContextClassLoader, boolean validating, boolean validatingSchema)
useContextClassLoader
- whether or not to use the context class loader.validating
- whether or not to validate XML.validatingSchema
- whether or not to validate XML schema.protected void addDefaultDigesterRules(org.apache.commons.digester.Digester digester)
protected boolean addCustomDigesterRules(org.apache.commons.digester.Digester digester)
digester
-
protected void initSchemaValidation(boolean validatingSchema)
protected static org.apache.commons.logging.Log getLog()
public boolean getUseContextClassLoader()
public void setUseContextClassLoader(boolean useContextClassLoader)
useContextClassLoader
- boolean.public boolean getOverWriteExistingJobs()
public void setOverWriteExistingJobs(boolean overWriteExistingJobs)
overWriteExistingJobs
- boolean.public void processFile() throws Exception
Exception
public void processFile(String fileName) throws Exception
fileName
.
fileName
- meta data file name.
Exception
public void processFile(String fileName, String systemId) throws ValidationException, ParserConfigurationException, SAXException, IOException, SchedulerException, ClassNotFoundException, ParseException
fileName
with the given system
ID.
fileName
- meta data file name.systemId
- system ID.
ValidationException
ParserConfigurationException
SAXException
IOException
SchedulerException
ClassNotFoundException
ParseException
public void processStream(InputStream stream, String systemId) throws ValidationException, ParserConfigurationException, SAXException, IOException, SchedulerException, ClassNotFoundException, ParseException
fileName
with the given system
ID.
stream
- an input stream containing the xml content.systemId
- system ID.
ValidationException
ParserConfigurationException
SAXException
IOException
SchedulerException
ClassNotFoundException
ParseException
public void processFileAndScheduleJobs(Scheduler sched, boolean overWriteExistingJobs) throws SchedulerException, Exception
SchedulerException
Exception
public void processFileAndScheduleJobs(String fileName, Scheduler sched, boolean overWriteExistingJobs) throws Exception
fileName
- meta data file name.
Exception
public void processFileAndScheduleJobs(String fileName, String systemId, Scheduler sched, boolean overWriteExistingJobs) throws Exception
fileName
- meta data file name.
Exception
public void scheduleJobs(Map jobBundles, Scheduler sched, boolean overWriteExistingJobs) throws Exception
JobSchedulingBundle
s to the given scheduler.
jobBundles
- sched
- overWriteExistingJobs
-
Exception
public Map getScheduledJobs()
Map
of scheduled jobs.
The key is the job name and the value is a JobSchedulingBundle
containing the JobDetail
and Trigger
.
Map
of scheduled jobs.public JobSchedulingBundle getScheduledJob(String name)
JobSchedulingBundle
for the job name.
name
- job name.
JobSchedulingBundle
for the job name.protected InputStream getInputStream(String fileName)
InputStream
from the fileName as a resource.
fileName
- file name.
InputStream
from the fileName as a resource.public void scheduleJob(JobSchedulingBundle job) throws SchedulerException
JobSchedulingBundle
).
job
- job wrapper.
SchedulerException
- if the Job or Trigger cannot be added to the Scheduler, or
there is an internal Scheduler error.public void addJobToSchedule(JobSchedulingBundle job)
public void addCalendarToSchedule(CalendarBundle cal)
public void addListenerToSchedule(JobListener listener)
public void scheduleJob(JobSchedulingBundle job, Scheduler sched, boolean localOverWriteExistingJobs) throws SchedulerException
JobSchedulingBundle
).
job
- job wrapper.sched
- job scheduler.localOverWriteExistingJobs
- locally overwrite existing jobs.
SchedulerException
- if the Job or Trigger cannot be added to the Scheduler, or
there is an internal Scheduler error.protected void addScheduledJob(JobSchedulingBundle job)
job
- job wrapper.public void addCalendar(Scheduler sched, CalendarBundle calendarBundle) throws SchedulerException
calendarBundle
- calendar bundle.
SchedulerException
- if the Calendar cannot be added to the Scheduler, or
there is an internal Scheduler error.public InputSource resolveEntity(String publicId, String systemId)
quartz.dtd
has a public ID, it must resolved as a
system ID. Here's the order of resolution (if one fails, continue to the
next).
systemId
with ClassLoader.getResourceAsStream(String)
.
systemId
starts with QUARTZ_SYSTEM_ID_PREFIX
,
then resolve the part after QUARTZ_SYSTEM_ID_PREFIX
with
ClassLoader.getResourceAsStream(String)
.systemId
as a URL.
systemId
has a colon in it, create a new URL
systemId
as a File
and
then call File.toURL()
.publicId
does exist, resolve it as a URL. If the
publicId
is the Quartz public ID, then resolve it locally.
publicId
- The public identifier of the external entity being referenced,
or null if none was supplied.systemId
- The system identifier of the external entity being referenced.
SAXException
- Any SAX exception, possibly wrapping another exception.
IOException
- A Java-specific IO exception, possibly the result of
creating a new InputStream or Reader for the InputSource.public void warning(SAXParseException e) throws SAXException
SAXException
- Any SAX exception, possibly wrapping another exception.public void error(SAXParseException e) throws SAXException
SAXException
- Any SAX exception, possibly wrapping another exception.public void fatalError(SAXParseException e) throws SAXException
SAXException
- Any SAX exception, possibly wrapping another exception.protected void addValidationException(SAXException e)
protected void clearValidationExceptions()
protected void maybeThrowValidationException() throws ValidationException
ValidationException
- DTD validation exception.
|
Quartz Enterprise Job Scheduler Project Page | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |