|
||||||||||
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_2_0.xsd" The same instance can be used again and again, however a single instance is not thread-safe.
Field Summary | |
---|---|
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 Summary | |
---|---|
XMLSchedulingDataProcessor(ClassLoadHelper clh)
Constructor for JobSchedulingDataLoader. |
Method Summary | |
---|---|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
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<String> jobGroupsToDelete
protected List<String> triggerGroupsToDelete
protected List<JobKey> jobsToDelete
protected List<TriggerKey> triggersToDelete
protected List<JobDetail> loadedJobs
protected List<MutableTrigger> loadedTriggers
protected Collection<Exception> validationExceptions
protected ClassLoadHelper classLoadHelper
protected List<String> jobGroupsToNeverDelete
protected List<String> triggerGroupsToNeverDelete
Constructor Detail |
---|
public XMLSchedulingDataProcessor(ClassLoadHelper clh) throws ParserConfigurationException
clh
- class-loader helper to share with digester.
ParserConfigurationException
- if the XML parser cannot be configured as needed.Method Detail |
---|
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.
getURL(String)
,
processFile()
,
processFile(String)
,
processFileAndScheduleJobs(Scheduler, boolean)
,
processFileAndScheduleJobs(String, org.quartz.Scheduler)
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
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.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |