Save This Page
Home » quartz-1.6.0 » org » quartz » xml » [javadoc | source]
org.quartz.xml
public class: JobSchedulingDataProcessor [javadoc | source]
java.lang.Object
   org.xml.sax.helpers.DefaultHandler
      org.quartz.xml.JobSchedulingDataProcessor

All Implemented Interfaces:
    ErrorHandler, EntityResolver, ContentHandler, DTDHandler

Parses an XML file that declares Jobs and their schedules (Triggers). The xml document must conform to the format defined in "job_scheduling_data_1_5.dtd" or "job_scheduling_data_1_5.xsd" After creating an instance of this class, you should call one of the 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.
Nested Class Summary:
public class  JobSchedulingDataProcessor.CalendarRuleSet  RuleSet for common Calendar tags. 
public class  JobSchedulingDataProcessor.TriggerRuleSet  RuleSet for common Trigger tags. 
public class  JobSchedulingDataProcessor.SimpleConverterRule  This rule is needed to fix QUARTZ-153.

Since the Jakarta Commons BeanUtils 1.6.x ConvertUtils class uses static utility methods, the DateConverter and TimeZoneConverter were overriding any previously registered converters for java.util.Date and java.util.TimeZone.

Jakarta Commons BeanUtils 1.7.x fixes this issue by internally using per-context-classloader pseudo-singletons (see http://jakarta.apache.org/commons/beanutils/commons-beanutils-1.7.0/RELEASE-NOTES.txt). This ensures web applications in the same JVM are using independent converters based on their classloaders. However, the environment for QUARTZ-153 started Quartz using the QuartzInitializationServlet which started JobInitializationPlugin. In this case, the web classloader instances would be the same.

To make sure the converters aren't overridden by the JobSchedulingDataProcessor, it's easier to just override BeanPropertySetterRule.end() to convert the body text to the specified class using the specified converter. 

public class  JobSchedulingDataProcessor.MisfireInstructionRule  This rule translates the trigger misfire instruction constant name into its corresponding value.

TODO Consider removing this class and using a org.apache.commons.digester.Substitutor strategy once Jakarta Commons Digester 1.6 is final.

 
public final class  JobSchedulingDataProcessor.DateConverter  

Standard {@link Converter} implementation that converts an incoming String into a java.util.Date object, optionally using a default value or throwing a {@link ConversionException} if a conversion error occurs.

 
public final class  JobSchedulingDataProcessor.TimeZoneConverter  

Standard {@link Converter} implementation that converts an incoming String into a java.util.TimeZone object throwing a {@link ConversionException} if a conversion error occurs.

 
Field Summary
public static final  String QUARTZ_PUBLIC_ID     
public static final  String QUARTZ_SYSTEM_ID     
public static final  String QUARTZ_DTD     
public static final  String QUARTZ_NS     
public static final  String QUARTZ_SCHEMA     
public static final  String QUARTZ_XSD     
public static final  String QUARTZ_SYSTEM_ID_DIR_PROP     
public static final  String QUARTZ_XML_FILE_NAME     
public static final  String QUARTZ_SYSTEM_ID_PREFIX     
protected static final  String TAG_QUARTZ     
protected static final  String TAG_OVERWRITE_EXISTING_JOBS     
protected static final  String TAG_JOB_LISTENER     
protected static final  String TAG_CALENDAR     
protected static final  String TAG_CLASS_NAME     
protected static final  String TAG_DESCRIPTION     
protected static final  String TAG_BASE_CALENDAR     
protected static final  String TAG_MISFIRE_INSTRUCTION     
protected static final  String TAG_CALENDAR_NAME     
protected static final  String TAG_JOB     
protected static final  String TAG_JOB_DETAIL     
protected static final  String TAG_NAME     
protected static final  String TAG_GROUP     
protected static final  String TAG_JOB_CLASS     
protected static final  String TAG_JOB_LISTENER_REF     
protected static final  String TAG_VOLATILITY     
protected static final  String TAG_DURABILITY     
protected static final  String TAG_RECOVER     
protected static final  String TAG_JOB_DATA_MAP     
protected static final  String TAG_ENTRY     
protected static final  String TAG_KEY     
protected static final  String TAG_ALLOWS_TRANSIENT_DATA     
protected static final  String TAG_VALUE     
protected static final  String TAG_TRIGGER     
protected static final  String TAG_SIMPLE     
protected static final  String TAG_CRON     
protected static final  String TAG_JOB_NAME     
protected static final  String TAG_JOB_GROUP     
protected static final  String TAG_START_TIME     
protected static final  String TAG_END_TIME     
protected static final  String TAG_REPEAT_COUNT     
protected static final  String TAG_REPEAT_INTERVAL     
protected static final  String TAG_CRON_EXPRESSION     
protected static final  String TAG_TIME_ZONE     
protected static final  String XSD_DATE_FORMAT    XML Schema dateTime datatype format.

See http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/#dateTime 

protected static final  String DTD_DATE_FORMAT    Legacy DTD version 1.0 date format. 
protected  Map scheduledJobs     
protected  List jobsToSchedule     
protected  List calsToSchedule     
protected  List listenersToSchedule     
protected  Collection validationExceptions     
protected  Digester digester     
Constructor:
 public JobSchedulingDataProcessor() 
 public JobSchedulingDataProcessor(boolean useContextClassLoader,
    boolean validating,
    boolean validatingSchema) 
Method from org.quartz.xml.JobSchedulingDataProcessor Summary:
addCalendar,   addCalendarToSchedule,   addCustomDigesterRules,   addDefaultDigesterRules,   addJobToSchedule,   addListenerToSchedule,   addScheduledJob,   addValidationException,   clearValidationExceptions,   error,   fatalError,   getInputStream,   getLog,   getOverWriteExistingJobs,   getScheduledJob,   getScheduledJobs,   getSystemIdForFileName,   getURL,   getUseContextClassLoader,   initDigester,   initSchemaValidation,   maybeThrowValidationException,   processFile,   processFile,   processFile,   processFileAndScheduleJobs,   processFileAndScheduleJobs,   processFileAndScheduleJobs,   processStream,   resolveEntity,   scheduleJob,   scheduleJob,   scheduleJobs,   setOverWriteExistingJobs,   setUseContextClassLoader,   warning
Methods from org.xml.sax.helpers.DefaultHandler:
characters,   endDocument,   endElement,   endPrefixMapping,   error,   fatalError,   ignorableWhitespace,   notationDecl,   processingInstruction,   resolveEntity,   setDocumentLocator,   skippedEntity,   startDocument,   startElement,   startPrefixMapping,   unparsedEntityDecl,   warning
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.quartz.xml.JobSchedulingDataProcessor Detail:
 public  void addCalendar(Scheduler sched,
    CalendarBundle calendarBundle) throws SchedulerException 
    Adds a calendar.
 public  void addCalendarToSchedule(CalendarBundle cal) 
 protected boolean addCustomDigesterRules(Digester digester) 
    Template method provided as a hook for those who wish to extend this class and add more functionality. This method is invoked after the Digester is instantiated, and before the default set of rules are added.
 protected  void addDefaultDigesterRules(Digester digester) 
    Add the default set of digest rules
 public  void addJobToSchedule(JobSchedulingBundle job) 
 public  void addListenerToSchedule(JobListener listener) 
 protected  void addScheduledJob(JobSchedulingBundle job) 
    Adds a scheduled job.
 protected  void addValidationException(SAXException e) 
    Adds a detected validation exception.
 protected  void clearValidationExceptions() 
    Resets the the number of detected validation exceptions.
 public  void error(SAXParseException e) throws SAXException 
    ErrorHandler interface. Receive notification of a recoverable error.
 public  void fatalError(SAXParseException e) throws SAXException 
    ErrorHandler interface. Receive notification of a non-recoverable error.
 protected InputStream getInputStream(String fileName) 
    Returns an InputStream from the fileName as a resource.
 protected Log getLog() 
 public boolean getOverWriteExistingJobs() 
    Returns whether to overwrite existing jobs.
 public JobSchedulingBundle getScheduledJob(String name) 
    Returns a JobSchedulingBundle for the job name.
 public Map getScheduledJobs() 
    Returns a Map of scheduled jobs.

    The key is the job name and the value is a JobSchedulingBundle containing the JobDetail and Trigger.

 protected String getSystemIdForFileName(String fileName) 
    For the given fileName, attempt to expand it to its full path for use as a system id.
 protected URL getURL(String fileName) 
    Returns an URL from the fileName as a resource.
 public boolean getUseContextClassLoader() 
    Returns whether to use the context class loader.
 protected  void initDigester(boolean useContextClassLoader,
    boolean validating,
    boolean validatingSchema) 
    Initializes the digester.
 protected  void initSchemaValidation(boolean validatingSchema) 
    Initializes the digester for XML Schema validation.
 protected  void maybeThrowValidationException() throws ValidationException 
    Throws a ValidationException if the number of validationExceptions detected is greater than zero.
 public  void processFile() throws Exception 
    Process the xml file in the default location (a file named "quartz_jobs.xml" in the current working directory).
 public  void processFile(String fileName) throws Exception 
    Process the xml file named fileName.
 public  void processFile(String fileName,
    String systemId) throws SchedulerException, ClassNotFoundException, IOException, ValidationException, SAXException, ParseException, ParserConfigurationException 
    Process the xmlfile named fileName with the given system ID.
 public  void processFileAndScheduleJobs(Scheduler sched,
    boolean overWriteExistingJobs) throws Exception, SchedulerException 
    Process the xml file in the default location, and schedule all of the jobs defined within it.
 public  void processFileAndScheduleJobs(String fileName,
    Scheduler sched,
    boolean overWriteExistingJobs) throws Exception 
    Process the xml file in the given location, and schedule all of the jobs defined within it.
 public  void processFileAndScheduleJobs(String fileName,
    String systemId,
    Scheduler sched,
    boolean overWriteExistingJobs) throws Exception 
    Process the xml file in the given location, and schedule all of the jobs defined within it.
 public  void processStream(InputStream stream,
    String systemId) throws SchedulerException, ClassNotFoundException, IOException, ValidationException, SAXException, ParseException, ParserConfigurationException 
    Process the xmlfile named fileName with the given system ID.
 public InputSource resolveEntity(String publicId,
    String systemId) 
    EntityResolver interface.

    Allow the application to resolve external entities.

    Until 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).

    1. Tries to resolve the systemId with ClassLoader.getResourceAsStream(String).
    2. If the systemId starts with QUARTZ_SYSTEM_ID_PREFIX, then resolve the part after QUARTZ_SYSTEM_ID_PREFIX with ClassLoader.getResourceAsStream(String).
    3. Else try to resolve systemId as a URL.
    4. If systemId has a colon in it, create a new URL
    5. Else resolve systemId as a File and then call File.toURL().

    If the publicId does exist, resolve it as a URL. If the publicId is the Quartz public ID, then resolve it locally.

 public  void scheduleJob(JobSchedulingBundle job) throws SchedulerException 
    Schedules a given job and trigger (both wrapped by a JobSchedulingBundle).
 public  void scheduleJob(JobSchedulingBundle job,
    Scheduler sched,
    boolean localOverWriteExistingJobs) throws SchedulerException 
    Schedules a given job and trigger (both wrapped by a JobSchedulingBundle).
 public  void scheduleJobs(Map jobBundles,
    Scheduler sched,
    boolean overWriteExistingJobs) throws Exception 
    Add the Jobs and Triggers defined in the given map of JobSchedulingBundle s to the given scheduler.
 public  void setOverWriteExistingJobs(boolean overWriteExistingJobs) 
    Sets whether to overwrite existing jobs.
 public  void setUseContextClassLoader(boolean useContextClassLoader) 
    Sets whether to use the context class loader.
 public  void warning(SAXParseException e) throws SAXException 
    ErrorHandler interface. Receive notification of a warning.