public class JobSchedulingDataProcessor
extends org.xml.sax.helpers.DefaultHandler
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.Modifier and Type | Class and Description |
---|---|
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.
|
Modifier and Type | Field and Description |
---|---|
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 |
Constructor and Description |
---|
JobSchedulingDataProcessor(ClassLoadHelper clh,
boolean validating,
boolean validatingSchema)
Constructor for QuartzMetaDataProcessor.
|
Modifier and Type | Method and Description |
---|---|
void |
addCalendar(Scheduler sched,
CalendarBundle calendarBundle)
Adds a calendar.
|
void |
addCalendarToSchedule(CalendarBundle cal) |
void |
addJobToSchedule(JobSchedulingBundle job) |
void |
addListenerToSchedule(JobListener listener) |
void |
error(org.xml.sax.SAXParseException e)
ErrorHandler interface.
|
void |
fatalError(org.xml.sax.SAXParseException e)
ErrorHandler interface.
|
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.
|
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.
|
void |
processStream(java.io.InputStream stream,
java.lang.String systemId)
Process the xmlfile named
fileName with the given system
ID. |
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.
|
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
public JobSchedulingDataProcessor(ClassLoadHelper clh, boolean validating, boolean validatingSchema)
clh
- class-loader helper to share with digester.validating
- whether or not to validate XML.validatingSchema
- whether or not to validate XML schema.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 processStream(java.io.InputStream stream, 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.stream
- an input stream containing the xml content.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.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.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.resolveEntity
in interface org.xml.sax.EntityResolver
resolveEntity
in class org.xml.sax.helpers.DefaultHandler
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
warning
in interface org.xml.sax.ErrorHandler
warning
in class org.xml.sax.helpers.DefaultHandler
e
- The error information encapsulated in a SAX parse exception.org.xml.sax.SAXException
- Any SAX exception, possibly wrapping another exception.public void error(org.xml.sax.SAXParseException e) throws org.xml.sax.SAXException
error
in interface org.xml.sax.ErrorHandler
error
in class org.xml.sax.helpers.DefaultHandler
e
- The error information encapsulated in a SAX parse exception.org.xml.sax.SAXException
- Any SAX exception, possibly wrapping another exception.public void fatalError(org.xml.sax.SAXParseException e) throws org.xml.sax.SAXException
fatalError
in interface org.xml.sax.ErrorHandler
fatalError
in class org.xml.sax.helpers.DefaultHandler
e
- The error information encapsulated in a SAX parse exception.org.xml.sax.SAXException
- Any SAX exception, possibly wrapping another exception.