|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.quartz.xml.XMLSchedulingDataProcessor
public class XMLSchedulingDataProcessor
Parses an XML file that declares Jobs and their schedules (Triggers), and processes the related data. The xml document must conform to the format defined in "job_scheduling_data_1_8.xsd" The same instance can be used again and again, however a single instance is not thread-safe.
Field Summary | |
---|---|
protected ClassLoadHelper |
classLoadHelper
|
protected static java.text.SimpleDateFormat |
dateFormat
|
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<Trigger> |
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 |
validationExceptions
|
protected static java.lang.String |
XSD_DATE_FORMAT
XML Schema dateTime datatype format. |
Constructor Summary | |
---|---|
XMLSchedulingDataProcessor(ClassLoadHelper clh)
Constructor for JobSchedulingDataLoader. |
Method Summary | |
---|---|
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(Trigger 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 xpath,
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<Trigger> |
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 xpath,
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. |
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_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 static final java.lang.String XSD_DATE_FORMAT
See http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/#dateTime
protected static final java.text.SimpleDateFormat dateFormat
protected java.util.List<java.lang.String> jobGroupsToDelete
protected java.util.List<java.lang.String> triggerGroupsToDelete
protected java.util.List<JobKey> jobsToDelete
protected java.util.List<TriggerKey> triggersToDelete
protected java.util.List<JobDetail> loadedJobs
protected java.util.List<Trigger> loadedTriggers
protected java.util.Collection validationExceptions
protected ClassLoadHelper classLoadHelper
protected java.util.List<java.lang.String> jobGroupsToNeverDelete
protected java.util.List<java.lang.String> triggerGroupsToNeverDelete
Constructor Detail |
---|
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.Method Detail |
---|
protected void initDocumentParser() throws javax.xml.parsers.ParserConfigurationException
javax.xml.parsers.ParserConfigurationException
protected 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)
group
- public boolean removeJobGroupToNeverDelete(java.lang.String group)
group
- public java.util.List<java.lang.String> getJobGroupsToNeverDelete()
group
- public void addTriggerGroupToNeverDelete(java.lang.String group)
group
- public boolean removeTriggerGroupToNeverDelete(java.lang.String group)
group
- public java.util.List<java.lang.String> getTriggerGroupsToNeverDelete()
group
- protected void processFile() throws java.lang.Exception
java.lang.Exception
protected void processFile(java.lang.String fileName) throws java.lang.Exception
fileName
.
fileName
- meta data file name.
java.lang.Exception
protected java.lang.String getSystemIdForFileName(java.lang.String fileName)
fileName
, attempt to expand it to its full path
for use as a system id.
getURL(String)
,
processFile()
,
processFile(String)
,
processFileAndScheduleJobs(Scheduler, boolean)
,
#processFileAndScheduleJobs(String, Scheduler, boolean)
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.
ValidationException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
java.io.IOException
SchedulerException
java.lang.ClassNotFoundException
java.text.ParseException
javax.xml.xpath.XPathException
public 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.
ValidationException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
javax.xml.xpath.XPathException
java.io.IOException
SchedulerException
java.lang.ClassNotFoundException
java.text.ParseException
protected 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.SAXException
java.io.IOException
java.text.ParseException
javax.xml.xpath.XPathException
java.lang.ClassNotFoundException
protected java.lang.String getTrimmedToNullString(javax.xml.xpath.XPath xpath, java.lang.String elementName, org.w3c.dom.Node parentNode) throws javax.xml.xpath.XPathExpressionException
javax.xml.xpath.XPathExpressionException
protected java.lang.Boolean getBoolean(javax.xml.xpath.XPath xpath, java.lang.String elementName, org.w3c.dom.Document document) throws javax.xml.xpath.XPathExpressionException
javax.xml.xpath.XPathExpressionException
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) 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) throws java.lang.Exception
fileName
- meta data file name.
java.lang.Exception
protected java.util.List<JobDetail> getLoadedJobs()
List
of jobs loaded from the xml file.
List
of jobs.protected java.util.List<Trigger> 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(Trigger 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(org.xml.sax.SAXParseException e) throws org.xml.sax.SAXException
warning
in interface org.xml.sax.ErrorHandler
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
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
e
- 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.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |