public class XMLSchedulingDataProcessor
extends java.lang.Object
implements org.xml.sax.ErrorHandler
| Modifier and Type | Field and Description |
|---|---|
protected ClassLoadHelper |
classLoadHelper |
protected java.util.List<java.lang.String> |
jobGroupsToDelete |
protected java.util.List<java.lang.String> |
jobGroupsToNeverDelete |
protected java.util.List<JobKey> |
jobsToDelete |
protected java.util.List<JobDetail> |
loadedJobs |
protected java.util.List<MutableTrigger> |
loadedTriggers |
static java.lang.String |
QUARTZ_NS |
static java.lang.String |
QUARTZ_SCHEMA_WEB_URL |
static java.lang.String |
QUARTZ_SYSTEM_ID_JAR_PREFIX |
static java.lang.String |
QUARTZ_XML_DEFAULT_FILE_NAME |
static java.lang.String |
QUARTZ_XSD_PATH_IN_JAR |
protected java.util.List<java.lang.String> |
triggerGroupsToDelete |
protected java.util.List<java.lang.String> |
triggerGroupsToNeverDelete |
protected java.util.List<TriggerKey> |
triggersToDelete |
protected java.util.Collection<java.lang.Exception> |
validationExceptions |
| Constructor and Description |
|---|
XMLSchedulingDataProcessor(ClassLoadHelper clh)
Constructor for JobSchedulingDataLoader.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addJobGroupToNeverDelete(java.lang.String group)
Add the given group to the list of job groups that will never be
deleted by this processor, even if a pre-processing-command to
delete the group is encountered.
|
protected void |
addJobToSchedule(JobDetail job) |
void |
addTriggerGroupToNeverDelete(java.lang.String group)
Add the given group to the list of trigger groups that will never be
deleted by this processor, even if a pre-processing-command to
delete the group is encountered.
|
protected void |
addTriggerToSchedule(MutableTrigger trigger) |
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.
|
protected void |
executePreProcessCommands(Scheduler scheduler) |
void |
fatalError(org.xml.sax.SAXParseException e)
ErrorHandler interface.
|
protected java.lang.Boolean |
getBoolean(javax.xml.xpath.XPath xpathToElement,
java.lang.String elementName,
org.w3c.dom.Document document) |
protected java.io.InputStream |
getInputStream(java.lang.String fileName)
Returns an
InputStream from the fileName as a resource. |
java.util.List<java.lang.String> |
getJobGroupsToNeverDelete()
Get the (unmodifiable) list of job groups that will never be
deleted by this processor, even if a pre-processing-command to
delete the group is encountered.
|
protected java.util.List<JobDetail> |
getLoadedJobs()
Returns a
List of jobs loaded from the xml file. |
protected java.util.List<MutableTrigger> |
getLoadedTriggers()
Returns a
List of triggers loaded from the xml file. |
protected java.lang.String |
getSystemIdForFileName(java.lang.String fileName)
For the given
fileName, attempt to expand it to its full path
for use as a system id. |
java.util.List<java.lang.String> |
getTriggerGroupsToNeverDelete()
Get the (unmodifiable) list of trigger groups that will never be
deleted by this processor, even if a pre-processing-command to
delete the group is encountered.
|
protected java.lang.String |
getTrimmedToNullString(javax.xml.xpath.XPath xpathToElement,
java.lang.String elementName,
org.w3c.dom.Node parentNode) |
protected java.net.URL |
getURL(java.lang.String fileName)
Returns an
URL from the fileName as a resource. |
protected void |
initDocumentParser()
Initializes the XML parser.
|
boolean |
isIgnoreDuplicates()
If true (and
OverWriteExistingData is false) then any
job/triggers encountered in this file that have names that already exist
in the scheduler will be ignored, and no error will be produced. |
boolean |
isOverWriteExistingData()
Whether the existing scheduling data (with same identifiers) will be
overwritten.
|
protected void |
maybeThrowValidationException()
Throws a ValidationException if the number of validationExceptions
detected is greater than zero.
|
protected void |
prepForProcessing() |
protected void |
process(org.xml.sax.InputSource is) |
protected void |
processFile()
Process the xml file in the default location (a file named
"quartz_jobs.xml" in the current working directory).
|
protected void |
processFile(java.lang.String fileName)
Process the xml file named
fileName. |
protected 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)
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)
Process the xml file in the given location, and schedule all of the
jobs defined within it.
|
void |
processStreamAndScheduleJobs(java.io.InputStream stream,
java.lang.String systemId,
Scheduler sched)
Process the xmlfile named
fileName with the given system
ID. |
boolean |
removeJobGroupToNeverDelete(java.lang.String group)
Remove the given group to the list of job groups that will never be
deleted by this processor, even if a pre-processing-command to
delete the group is encountered.
|
boolean |
removeTriggerGroupToNeverDelete(java.lang.String group)
Remove the given group to the list of trigger groups that will never be
deleted by this processor, even if a pre-processing-command to
delete the group is encountered.
|
protected java.lang.Object |
resolveSchemaSource() |
protected void |
scheduleJobs(Scheduler sched)
Schedules the given sets of jobs and triggers.
|
void |
setIgnoreDuplicates(boolean ignoreDuplicates)
If true (and
OverWriteExistingData is false) then any
job/triggers encountered in this file that have names that already exist
in the scheduler will be ignored, and no error will be produced. |
protected void |
setOverWriteExistingData(boolean overWriteExistingData)
Whether the existing scheduling data (with same identifiers) will be
overwritten.
|
void |
warning(org.xml.sax.SAXParseException e)
ErrorHandler interface.
|
public static final java.lang.String QUARTZ_NS
public static final java.lang.String QUARTZ_SCHEMA_WEB_URL
public static final java.lang.String QUARTZ_XSD_PATH_IN_JAR
public static final java.lang.String QUARTZ_XML_DEFAULT_FILE_NAME
public static final java.lang.String QUARTZ_SYSTEM_ID_JAR_PREFIX
protected final java.util.List<java.lang.String> jobGroupsToDelete
protected final java.util.List<java.lang.String> triggerGroupsToDelete
protected final java.util.List<JobKey> jobsToDelete
protected final java.util.List<TriggerKey> triggersToDelete
protected final java.util.List<JobDetail> loadedJobs
protected final java.util.List<MutableTrigger> loadedTriggers
protected final java.util.Collection<java.lang.Exception> validationExceptions
protected final ClassLoadHelper classLoadHelper
protected final java.util.List<java.lang.String> jobGroupsToNeverDelete
protected final java.util.List<java.lang.String> triggerGroupsToNeverDelete
public XMLSchedulingDataProcessor(ClassLoadHelper clh) throws javax.xml.parsers.ParserConfigurationException
clh - class-loader helper to share with digester.javax.xml.parsers.ParserConfigurationException - if the XML parser cannot be configured as needed.protected void initDocumentParser()
throws javax.xml.parsers.ParserConfigurationException
javax.xml.parsers.ParserConfigurationExceptionprotected java.lang.Object resolveSchemaSource()
public boolean isOverWriteExistingData()
IgnoreDuplicates is not false, and jobs or
triggers with the same names already exist as those in the file, an
error will occur.isIgnoreDuplicates()protected void setOverWriteExistingData(boolean overWriteExistingData)
IgnoreDuplicates is not false, and jobs or
triggers with the same names already exist as those in the file, an
error will occur.setIgnoreDuplicates(boolean)public boolean isIgnoreDuplicates()
OverWriteExistingData is false) then any
job/triggers encountered in this file that have names that already exist
in the scheduler will be ignored, and no error will be produced.isOverWriteExistingData()public void setIgnoreDuplicates(boolean ignoreDuplicates)
OverWriteExistingData is false) then any
job/triggers encountered in this file that have names that already exist
in the scheduler will be ignored, and no error will be produced.setOverWriteExistingData(boolean)public void addJobGroupToNeverDelete(java.lang.String group)
public boolean removeJobGroupToNeverDelete(java.lang.String group)
public java.util.List<java.lang.String> getJobGroupsToNeverDelete()
public void addTriggerGroupToNeverDelete(java.lang.String group)
public boolean removeTriggerGroupToNeverDelete(java.lang.String group)
public java.util.List<java.lang.String> getTriggerGroupsToNeverDelete()
protected void processFile()
throws java.lang.Exception
java.lang.Exceptionprotected void processFile(java.lang.String fileName)
throws java.lang.Exception
fileName.fileName - meta data file name.java.lang.Exceptionprotected java.lang.String getSystemIdForFileName(java.lang.String fileName)
fileName, attempt to expand it to its full path
for use as a system id.protected java.net.URL getURL(java.lang.String fileName)
URL from the fileName as a resource.fileName - file name.URL from the fileName as a resource.protected void prepForProcessing()
protected 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,
javax.xml.xpath.XPathException
fileName with the given system
ID.fileName - meta data file name.systemId - system ID.ValidationExceptionjavax.xml.parsers.ParserConfigurationExceptionorg.xml.sax.SAXExceptionjava.io.IOExceptionSchedulerExceptionjava.lang.ClassNotFoundExceptionjava.text.ParseExceptionjavax.xml.xpath.XPathExceptionpublic void processStreamAndScheduleJobs(java.io.InputStream stream,
java.lang.String systemId,
Scheduler sched)
throws ValidationException,
javax.xml.parsers.ParserConfigurationException,
org.xml.sax.SAXException,
javax.xml.xpath.XPathException,
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.ValidationExceptionjavax.xml.parsers.ParserConfigurationExceptionorg.xml.sax.SAXExceptionjavax.xml.xpath.XPathExceptionjava.io.IOExceptionSchedulerExceptionjava.lang.ClassNotFoundExceptionjava.text.ParseExceptionprotected void process(org.xml.sax.InputSource is)
throws org.xml.sax.SAXException,
java.io.IOException,
java.text.ParseException,
javax.xml.xpath.XPathException,
java.lang.ClassNotFoundException
org.xml.sax.SAXExceptionjava.io.IOExceptionjava.text.ParseExceptionjavax.xml.xpath.XPathExceptionjava.lang.ClassNotFoundExceptionprotected java.lang.String getTrimmedToNullString(javax.xml.xpath.XPath xpathToElement,
java.lang.String elementName,
org.w3c.dom.Node parentNode)
throws javax.xml.xpath.XPathExpressionException
javax.xml.xpath.XPathExpressionExceptionprotected java.lang.Boolean getBoolean(javax.xml.xpath.XPath xpathToElement,
java.lang.String elementName,
org.w3c.dom.Document document)
throws javax.xml.xpath.XPathExpressionException
javax.xml.xpath.XPathExpressionExceptionpublic void processFileAndScheduleJobs(Scheduler sched, boolean overWriteExistingJobs) throws java.lang.Exception
Note that we will set overWriteExistingJobs after the default xml is parsed.
java.lang.Exceptionpublic void processFileAndScheduleJobs(java.lang.String fileName,
Scheduler sched)
throws java.lang.Exception
fileName - meta data file name.java.lang.Exceptionpublic void processFileAndScheduleJobs(java.lang.String fileName,
java.lang.String systemId,
Scheduler sched)
throws java.lang.Exception
fileName - meta data file name.java.lang.Exceptionprotected java.util.List<JobDetail> getLoadedJobs()
List of jobs loaded from the xml file.List of jobs.protected java.util.List<MutableTrigger> getLoadedTriggers()
List of triggers loaded from the xml file.List of triggers.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.protected void addJobToSchedule(JobDetail job)
protected void addTriggerToSchedule(MutableTrigger trigger)
protected void executePreProcessCommands(Scheduler scheduler) throws SchedulerException
SchedulerExceptionprotected void scheduleJobs(Scheduler sched) throws SchedulerException
sched - job scheduler.SchedulerException - if the Job or Trigger cannot be added to the Scheduler, or
there is an internal Scheduler error.public void warning(org.xml.sax.SAXParseException e)
throws org.xml.sax.SAXException
warning in interface org.xml.sax.ErrorHandlere - 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.ErrorHandlere - 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.ErrorHandlere - The error information encapsulated in a SAX parse exception.org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.protected void addValidationException(org.xml.sax.SAXException e)
e - SAX exception.protected void clearValidationExceptions()
protected void maybeThrowValidationException()
throws ValidationException
ValidationException - DTD validation exception.Copyright IBM Corp. 2024, 2025