public class XMLSchedulingDataProcessor extends Object implements ErrorHandler
Modifier and Type | Field and Description |
---|---|
protected ClassLoadHelper |
classLoadHelper |
protected List<String> |
jobGroupsToDelete |
protected List<String> |
jobGroupsToNeverDelete |
protected List<JobKey> |
jobsToDelete |
protected List<JobDetail> |
loadedJobs |
protected List<MutableTrigger> |
loadedTriggers |
static String |
QUARTZ_NS |
static String |
QUARTZ_SCHEMA_WEB_URL |
static String |
QUARTZ_SYSTEM_ID_JAR_PREFIX |
static String |
QUARTZ_XML_DEFAULT_FILE_NAME |
static String |
QUARTZ_XSD_PATH_IN_JAR |
protected List<String> |
triggerGroupsToDelete |
protected List<String> |
triggerGroupsToNeverDelete |
protected List<TriggerKey> |
triggersToDelete |
protected Collection<Exception> |
validationExceptions |
Constructor and Description |
---|
XMLSchedulingDataProcessor(ClassLoadHelper clh)
Constructor for JobSchedulingDataLoader.
|
Modifier and Type | Method and Description |
---|---|
void |
addJobGroupToNeverDelete(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(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(SAXException e)
Adds a detected validation exception.
|
protected void |
clearValidationExceptions()
Resets the the number of detected validation exceptions.
|
void |
error(SAXParseException e)
ErrorHandler interface.
|
protected void |
executePreProcessCommands(Scheduler scheduler) |
void |
fatalError(SAXParseException e)
ErrorHandler interface.
|
protected Boolean |
getBoolean(XPath xpathToElement,
String elementName,
Document document) |
protected InputStream |
getInputStream(String fileName)
Returns an
InputStream from the fileName as a resource. |
List<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 List<JobDetail> |
getLoadedJobs()
Returns a
List of jobs loaded from the xml file. |
protected List<MutableTrigger> |
getLoadedTriggers()
Returns a
List of triggers loaded from the xml file. |
protected String |
getSystemIdForFileName(String fileName)
For the given
fileName , attempt to expand it to its full path
for use as a system id. |
List<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 String |
getTrimmedToNullString(XPath xpathToElement,
String elementName,
Node parentNode) |
protected URL |
getURL(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(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(String fileName)
Process the xml file named
fileName . |
protected 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)
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)
Process the xml file in the given location, and schedule all of the
jobs defined within it.
|
void |
processStreamAndScheduleJobs(InputStream stream,
String systemId,
Scheduler sched)
Process the xmlfile named
fileName with the given system
ID. |
boolean |
removeJobGroupToNeverDelete(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(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 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(SAXParseException e)
ErrorHandler interface.
|
public static final String QUARTZ_NS
public static final String QUARTZ_SCHEMA_WEB_URL
public static final String QUARTZ_XSD_PATH_IN_JAR
public static final String QUARTZ_XML_DEFAULT_FILE_NAME
public static final String QUARTZ_SYSTEM_ID_JAR_PREFIX
protected List<TriggerKey> triggersToDelete
protected List<MutableTrigger> loadedTriggers
protected Collection<Exception> validationExceptions
protected ClassLoadHelper classLoadHelper
public XMLSchedulingDataProcessor(ClassLoadHelper clh) throws ParserConfigurationException
clh
- class-loader helper to share with digester.ParserConfigurationException
- if the XML parser cannot be configured as needed.protected void initDocumentParser() throws ParserConfigurationException
ParserConfigurationException
protected 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(String group)
public boolean removeJobGroupToNeverDelete(String group)
public List<String> getJobGroupsToNeverDelete()
public void addTriggerGroupToNeverDelete(String group)
public boolean removeTriggerGroupToNeverDelete(String group)
public List<String> getTriggerGroupsToNeverDelete()
protected void processFile() throws Exception
Exception
protected void processFile(String fileName) throws Exception
fileName
.fileName
- meta data file name.Exception
protected String getSystemIdForFileName(String fileName)
fileName
, attempt to expand it to its full path
for use as a system id.protected URL getURL(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(String fileName, String systemId) throws ValidationException, ParserConfigurationException, SAXException, IOException, SchedulerException, ClassNotFoundException, ParseException, XPathException
fileName
with the given system
ID.fileName
- meta data file name.systemId
- system ID.ValidationException
ParserConfigurationException
SAXException
IOException
SchedulerException
ClassNotFoundException
ParseException
XPathException
public void processStreamAndScheduleJobs(InputStream stream, String systemId, Scheduler sched) throws ValidationException, ParserConfigurationException, SAXException, XPathException, IOException, SchedulerException, ClassNotFoundException, ParseException
fileName
with the given system
ID.stream
- an input stream containing the xml content.systemId
- system ID.ValidationException
ParserConfigurationException
SAXException
XPathException
IOException
SchedulerException
ClassNotFoundException
ParseException
protected void process(InputSource is) throws SAXException, IOException, ParseException, XPathException, ClassNotFoundException
protected String getTrimmedToNullString(XPath xpathToElement, String elementName, Node parentNode) throws XPathExpressionException
XPathExpressionException
protected Boolean getBoolean(XPath xpathToElement, String elementName, Document document) throws XPathExpressionException
XPathExpressionException
public void processFileAndScheduleJobs(Scheduler sched, boolean overWriteExistingJobs) throws Exception
Note that we will set overWriteExistingJobs after the default xml is parsed.
Exception
public void processFileAndScheduleJobs(String fileName, Scheduler sched) throws Exception
fileName
- meta data file name.Exception
public void processFileAndScheduleJobs(String fileName, String systemId, Scheduler sched) throws Exception
fileName
- meta data file name.Exception
protected List<JobDetail> getLoadedJobs()
List
of jobs loaded from the xml file.
List
of jobs.protected List<MutableTrigger> getLoadedTriggers()
List
of triggers loaded from the xml file.
List
of triggers.protected InputStream getInputStream(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
SchedulerException
protected 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(SAXParseException e) throws SAXException
warning
in interface ErrorHandler
e
- The error information encapsulated in a SAX parse exception.SAXException
- Any SAX exception, possibly wrapping another exception.public void error(SAXParseException e) throws SAXException
error
in interface ErrorHandler
e
- The error information encapsulated in a SAX parse exception.SAXException
- Any SAX exception, possibly wrapping another exception.public void fatalError(SAXParseException e) throws SAXException
fatalError
in interface ErrorHandler
e
- The error information encapsulated in a SAX parse exception.SAXException
- Any SAX exception, possibly wrapping another exception.protected void addValidationException(SAXException e)
e
- SAX exception.protected void clearValidationExceptions()
protected void maybeThrowValidationException() throws ValidationException
ValidationException
- DTD validation exception.Copyright 2001-2019, Terracotta, Inc.