|
|||||||||||
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_0.dtd" or "job_scheduling_data_1_1.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. |
Field Summary | |
protected java.util.List |
calsToSchedule
|
protected org.apache.commons.digester.Digester |
digester
|
protected static java.lang.String |
DTD_DATE_FORMAT
Legacy DTD version 1.0 date format. |
protected java.util.List |
jobsToSchedule
|
static java.lang.String |
QUARTZ_DTD
|
static java.lang.String |
QUARTZ_NS
|
static java.lang.String |
QUARTZ_PUBLIC_ID
|
static java.lang.String |
QUARTZ_SCHEMA
|
static java.lang.String |
QUARTZ_SYSTEM_ID
|
static java.lang.String |
QUARTZ_SYSTEM_ID_DIR_PROP
|
static java.lang.String |
QUARTZ_SYSTEM_ID_PREFIX
|
static java.lang.String |
QUARTZ_XML_FILE_NAME
|
static java.lang.String |
QUARTZ_XSD
|
protected java.util.Map |
scheduledJobs
|
protected static java.lang.String |
TAG_ALLOWS_TRANSIENT_DATA
|
protected static java.lang.String |
TAG_BASE_CALENDAR
|
protected static java.lang.String |
TAG_CALENDAR
|
protected static java.lang.String |
TAG_CALENDAR_NAME
|
protected static java.lang.String |
TAG_CLASS_NAME
|
protected static java.lang.String |
TAG_CRON
|
protected static java.lang.String |
TAG_CRON_EXPRESSION
|
protected static java.lang.String |
TAG_DESCRIPTION
|
protected static java.lang.String |
TAG_DURABILITY
|
protected static java.lang.String |
TAG_END_TIME
|
protected static java.lang.String |
TAG_ENTRY
|
protected static java.lang.String |
TAG_GROUP
|
protected static java.lang.String |
TAG_JOB
|
protected static java.lang.String |
TAG_JOB_CLASS
|
protected static java.lang.String |
TAG_JOB_DATA_MAP
|
protected static java.lang.String |
TAG_JOB_DETAIL
|
protected static java.lang.String |
TAG_JOB_GROUP
|
protected static java.lang.String |
TAG_JOB_NAME
|
protected static java.lang.String |
TAG_KEY
|
protected static java.lang.String |
TAG_MISFIRE_INSTRUCTION
|
protected static java.lang.String |
TAG_NAME
|
protected static java.lang.String |
TAG_OVERWRITE_EXISTING_JOBS
|
protected static java.lang.String |
TAG_QUARTZ
|
protected static java.lang.String |
TAG_RECOVER
|
protected static java.lang.String |
TAG_REPEAT_COUNT
|
protected static java.lang.String |
TAG_REPEAT_INTERVAL
|
protected static java.lang.String |
TAG_SIMPLE
|
protected static java.lang.String |
TAG_START_TIME
|
protected static java.lang.String |
TAG_TIME_ZONE
|
protected static java.lang.String |
TAG_TRIGGER
|
protected static java.lang.String |
TAG_VALUE
|
protected static java.lang.String |
TAG_VOLATILITY
|
protected java.util.Collection |
validationExceptions
|
protected static java.lang.String |
XSD_DATE_FORMAT
XML Schema dateTime datatype format. |
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)
|
void |
addJobToSchedule(JobSchedulingBundle job)
|
protected void |
addScheduledJob(JobSchedulingBundle job)
Adds a scheduled job. |
protected void |
addValidationException(org.xml.sax.SAXException e)
Adds a detected validation exception. |
protected void |
clearValidationExceptions()
Resets the the number of detected validation exceptions. |
void |
error(org.xml.sax.SAXParseException e)
ErrorHandler interface. |
void |
fatalError(org.xml.sax.SAXParseException e)
ErrorHandler interface. |
protected java.io.InputStream |
getInputStream(java.lang.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(java.lang.String name)
Returns a JobSchedulingBundle for the job name. |
java.util.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(java.lang.String fileName)
Process the xml file named fileName . |
void |
processFile(java.lang.String fileName,
java.lang.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(java.lang.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(java.lang.String fileName,
java.lang.String systemId,
Scheduler sched,
boolean overWriteExistingJobs)
Process the xml file in the given location, and schedule all of the jobs defined within it. |
org.xml.sax.InputSource |
resolveEntity(java.lang.String publicId,
java.lang.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(java.util.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(org.xml.sax.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 java.lang.String QUARTZ_PUBLIC_ID
public static final java.lang.String QUARTZ_SYSTEM_ID
public static final java.lang.String QUARTZ_DTD
public static final java.lang.String QUARTZ_NS
public static final java.lang.String QUARTZ_SCHEMA
public static final java.lang.String QUARTZ_XSD
public static final java.lang.String QUARTZ_SYSTEM_ID_DIR_PROP
public static final java.lang.String QUARTZ_XML_FILE_NAME
public static final java.lang.String QUARTZ_SYSTEM_ID_PREFIX
protected static final java.lang.String TAG_QUARTZ
protected static final java.lang.String TAG_OVERWRITE_EXISTING_JOBS
protected static final java.lang.String TAG_CALENDAR
protected static final java.lang.String TAG_CLASS_NAME
protected static final java.lang.String TAG_DESCRIPTION
protected static final java.lang.String TAG_BASE_CALENDAR
protected static final java.lang.String TAG_MISFIRE_INSTRUCTION
protected static final java.lang.String TAG_CALENDAR_NAME
protected static final java.lang.String TAG_JOB
protected static final java.lang.String TAG_JOB_DETAIL
protected static final java.lang.String TAG_NAME
protected static final java.lang.String TAG_GROUP
protected static final java.lang.String TAG_JOB_CLASS
protected static final java.lang.String TAG_VOLATILITY
protected static final java.lang.String TAG_DURABILITY
protected static final java.lang.String TAG_RECOVER
protected static final java.lang.String TAG_JOB_DATA_MAP
protected static final java.lang.String TAG_ENTRY
protected static final java.lang.String TAG_KEY
protected static final java.lang.String TAG_ALLOWS_TRANSIENT_DATA
protected static final java.lang.String TAG_VALUE
protected static final java.lang.String TAG_TRIGGER
protected static final java.lang.String TAG_SIMPLE
protected static final java.lang.String TAG_CRON
protected static final java.lang.String TAG_JOB_NAME
protected static final java.lang.String TAG_JOB_GROUP
protected static final java.lang.String TAG_START_TIME
protected static final java.lang.String TAG_END_TIME
protected static final java.lang.String TAG_REPEAT_COUNT
protected static final java.lang.String TAG_REPEAT_INTERVAL
protected static final java.lang.String TAG_CRON_EXPRESSION
protected static final java.lang.String TAG_TIME_ZONE
protected static final java.lang.String XSD_DATE_FORMAT
See http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/#dateTime
protected static final java.lang.String DTD_DATE_FORMAT
protected java.util.Map scheduledJobs
protected java.util.List jobsToSchedule
protected java.util.List calsToSchedule
protected java.util.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 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 java.lang.Exception
java.lang.Exception
public void processFile(java.lang.String fileName) throws java.lang.Exception
fileName
.
fileName
- meta data file name.
java.lang.Exception
public void processFile(java.lang.String fileName, java.lang.String systemId) throws ValidationException, javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException, SchedulerException, java.lang.ClassNotFoundException, java.text.ParseException
fileName
with the given system
ID.
fileName
- meta data file name.systemId
- system ID.
ValidationException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
java.io.IOException
SchedulerException
java.lang.ClassNotFoundException
java.text.ParseException
public void processFileAndScheduleJobs(Scheduler sched, boolean overWriteExistingJobs) throws SchedulerException, java.lang.Exception
SchedulerException
java.lang.Exception
public void processFileAndScheduleJobs(java.lang.String fileName, Scheduler sched, boolean overWriteExistingJobs) throws java.lang.Exception
fileName
- meta data file name.
java.lang.Exception
public void processFileAndScheduleJobs(java.lang.String fileName, java.lang.String systemId, Scheduler sched, boolean overWriteExistingJobs) throws java.lang.Exception
fileName
- meta data file name.
java.lang.Exception
public void scheduleJobs(java.util.Map jobBundles, Scheduler sched, boolean overWriteExistingJobs) throws java.lang.Exception
JobSchedulingBundle
s to the given scheduler.
jobBundles
- sched
- overWriteExistingJobs
-
java.lang.Exception
public java.util.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(java.lang.String name)
JobSchedulingBundle
for the job name.
name
- job name.
JobSchedulingBundle
for the job name.protected java.io.InputStream getInputStream(java.lang.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 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 org.xml.sax.InputSource resolveEntity(java.lang.String publicId, java.lang.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.
org.xml.sax.SAXException
- Any SAX exception, possibly wrapping another exception.
java.io.IOException
- A Java-specific IO exception, possibly the result of
creating a new InputStream or Reader for the InputSource.public void warning(org.xml.sax.SAXParseException e) throws org.xml.sax.SAXException
org.xml.sax.SAXException
- Any SAX exception, possibly wrapping another exception.public void error(org.xml.sax.SAXParseException e) throws org.xml.sax.SAXException
org.xml.sax.SAXException
- Any SAX exception, possibly wrapping another exception.public void fatalError(org.xml.sax.SAXParseException e) throws org.xml.sax.SAXException
org.xml.sax.SAXException
- Any SAX exception, possibly wrapping another exception.protected void addValidationException(org.xml.sax.SAXException e)
protected void clearValidationExceptions()
protected void maybeThrowValidationException() throws ValidationException
ValidationException
- DTD validation exception.
|
Quartz Project Page | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |