/** * @see org.quartz.jobs.FileScanListener#fileUpdated(java.lang.String) */ public void fileUpdated(String fileName) { if (started) { processFile(fileName); } }
protected JobFile(String fileName) throws SchedulerException { this.fileName = fileName; initialize(); }
private void processFile(JobFile jobFile) { if (jobFile == null || !jobFile.getFileFound()) { return; } try { XMLSchedulingDataProcessor processor = new XMLSchedulingDataProcessor(this.classLoadHelper); processor.addJobGroupToNeverDelete(JOB_INITIALIZATION_PLUGIN_NAME); processor.addTriggerGroupToNeverDelete(JOB_INITIALIZATION_PLUGIN_NAME); processor.processFileAndScheduleJobs( jobFile.getFileName(), jobFile.getFileName(), // systemId getScheduler()); } catch (Exception e) { getLog().error("Error scheduling jobs: " + e.getMessage(), e); } }
getScheduler().getContext().put(JOB_INITIALIZATION_PLUGIN_NAME + '_' + getName(), this); String jobTriggerName = buildJobTriggerName(jobFile.getFileBasename()); TriggerKey tKey = new TriggerKey(jobTriggerName, JOB_INITIALIZATION_PLUGIN_NAME); getScheduler().unscheduleJob(tKey); .usingJobData(FileScanJob.FILE_NAME, jobFile.getFileName()) .usingJobData(FileScanJob.FILE_SCAN_LISTENER_NAME, JOB_INITIALIZATION_PLUGIN_NAME + '_' + getName()) .build(); .build(); getScheduler().scheduleJob(job, trig); getLog().debug("Scheduled file scan job for data file: {}, at interval: {}", jobFile.getFileName(), scanInterval); processFile(jobFile); getLog().error("Error starting background-task for watching jobs file.", se); } finally { started = true;
/** * <p> * Called during creation of the <code>Scheduler</code> in order to give * the <code>SchedulerPlugin</code> a chance to initialize. * </p> * * @throws org.quartz.SchedulerConfigException * if there is an error initializing. */ public void initialize(String name, final Scheduler scheduler, ClassLoadHelper schedulerFactoryClassLoadHelper) throws SchedulerException { super.initialize(name, scheduler); this.classLoadHelper = schedulerFactoryClassLoadHelper; getLog().info("Registering Quartz Job Initialization Plug-in."); // Create JobFile objects StringTokenizer stok = new StringTokenizer(fileNames, FILE_NAME_DELIMITERS); while (stok.hasMoreTokens()) { final String fileName = stok.nextToken(); final JobFile jobFile = new JobFile(fileName); jobFiles.put(fileName, jobFile); } }
String furl = null; File file = new File(getFileName()); // files in filesystem if (!file.exists()) { URL url = classLoadHelper.getResource(getFileName()); if(url != null) { try { if (isFailOnFileNotFound()) { throw new SchedulerException( "File named '" + getFileName() + "' does not exist."); } else { getLog().warn("File named '" + getFileName() + "' does not exist."); getLog().warn("Error closing jobs file " + getFileName(), ioe);
String jobTriggerName = JOB_INITIALIZATION_PLUGIN_NAME + '_' + getName() + '_' + fileBasename.replace('.', '_');
/** * ErrorHandler interface. Receive notification of a warning. * * @param e The error information encapsulated in a SAX parse exception. * @exception SAXException Any SAX exception, possibly wrapping another exception. */ @Override public void warning(SAXParseException e) throws SAXException { addValidationException(e); }
/** * Constructor for JobSchedulingDataLoader. * * @param classLoadHelper * @param clh class-loader helper to share with digester. * @throws ParserConfigurationException if the XML parser cannot be configured as needed. */ public XMLSchedulingDataProcessor(ClassLoadHelper classLoadHelper) throws ParserConfigurationException { this.classLoadHelper = classLoadHelper; initDocumentParser(); }
protected JobFile(String fileName) throws SchedulerException { this.fileName = fileName; initialize(); }
getScheduler().getContext().put(JOB_INITIALIZATION_PLUGIN_NAME + '_' + getName(), this); String jobTriggerName = buildJobTriggerName(jobFile.getFileBasename()); TriggerKey tKey = new TriggerKey(jobTriggerName, JOB_INITIALIZATION_PLUGIN_NAME); getScheduler().unscheduleJob(tKey); .usingJobData(FileScanJob.FILE_NAME, jobFile.getFileName()) .usingJobData(FileScanJob.FILE_SCAN_LISTENER_NAME, JOB_INITIALIZATION_PLUGIN_NAME + '_' + getName()) .build(); .build(); getScheduler().scheduleJob(job, trig); getLog().debug("Scheduled file scan job for data file: {}, at interval: {}", jobFile.getFileName(), scanInterval); processFile(jobFile); getLog().error("Error starting background-task for watching jobs file.", se); } finally { started = true;
private void processFile(JobFile jobFile) { if (jobFile == null || !jobFile.getFileFound()) { return; } try { XMLSchedulingDataProcessor processor = new XMLSchedulingDataProcessor(this.classLoadHelper); processor.addJobGroupToNeverDelete(JOB_INITIALIZATION_PLUGIN_NAME); processor.addTriggerGroupToNeverDelete(JOB_INITIALIZATION_PLUGIN_NAME); processor.processFileAndScheduleJobs( jobFile.getFileName(), jobFile.getFileName(), // systemId getScheduler()); } catch (Exception e) { getLog().error("Error scheduling jobs: " + e.getMessage(), e); } }
/** * <p> * Called during creation of the <code>Scheduler</code> in order to give * the <code>SchedulerPlugin</code> a chance to initialize. * </p> * * @throws org.quartz.SchedulerConfigException * if there is an error initializing. */ public void initialize(String name, final Scheduler scheduler, ClassLoadHelper schedulerFactoryClassLoadHelper) throws SchedulerException { super.initialize(name, scheduler); this.classLoadHelper = schedulerFactoryClassLoadHelper; getLog().info("Registering Quartz Job Initialization Plug-in."); // Create JobFile objects StringTokenizer stok = new StringTokenizer(fileNames, FILE_NAME_DELIMITERS); while (stok.hasMoreTokens()) { final String fileName = stok.nextToken(); final JobFile jobFile = new JobFile(fileName); jobFiles.put(fileName, jobFile); } }
String furl = null; File file = new File(getFileName()); // files in filesystem if (!file.exists()) { URL url = classLoadHelper.getResource(getFileName()); if(url != null) { try { if (isFailOnFileNotFound()) { throw new SchedulerException( "File named '" + getFileName() + "' does not exist."); } else { getLog().warn("File named '" + getFileName() + "' does not exist."); getLog().warn("Error closing jobs file " + getFileName(), ioe);
/** * @see org.quartz.jobs.FileScanListener#fileUpdated(java.lang.String) */ public void fileUpdated(String fileName) { if (started) { processFile(fileName); } }
protected JobFile(String fileName) throws SchedulerException { this.fileName = fileName; initialize(); }
String jobTriggerName = JOB_INITIALIZATION_PLUGIN_NAME + '_' + getName() + '_' + fileBasename.replace('.', '_');
/** * ErrorHandler interface. Receive notification of a non-recoverable error. * * @param e The error information encapsulated in a SAX parse exception. * @exception SAXException Any SAX exception, possibly wrapping another exception. */ @Override public void fatalError(SAXParseException e) throws SAXException { addValidationException(e); }
public void processFile(String filePath) { processFile((JobFile)jobFiles.get(filePath)); }
public void processFile(String filePath) { processFile((JobFile)jobFiles.get(filePath)); }