/** * <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 jobTriggerName = JOB_INITIALIZATION_PLUGIN_NAME + '_' + getName() + '_' + fileBasename.replace('.', '_');
/** * @see org.quartz.jobs.FileScanListener#fileUpdated(java.lang.String) */ public void fileUpdated(String fileName) { if (started) { processFile(fileName); } }
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_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;
XMLSchedulingDataProcessorPlugin xmlSchedulingDataProcessorPlugin = new XMLSchedulingDataProcessorPlugin(); xmlSchedulingDataProcessorPlugin.setFailOnFileNotFound(false); xmlSchedulingDataProcessorPlugin.setScanInterval(0); quartzSchedulerResources.addSchedulerPlugin(xmlSchedulingDataProcessorPlugin); xmlSchedulingDataProcessorPlugin.initialize("XMLSchedulingDataProcessorPlugin", quartzScheduler); shutdownHookPlugin.initialize("ShutdownHookPlugin", quartzScheduler); annotationJobTriggerPlugin.initialize("AnnotationJobTriggerPlugin", quartzScheduler);
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); } }
@Override public void start() { try { XMLSchedulingDataProcessor processor = new XMLSchedulingDataProcessor(scheduler.getCascadingClassLoadHelper()); processor.processFile(XMLSchedulingDataProcessor.QUARTZ_XML_DEFAULT_FILE_NAME, failOnFileNotFound); processor.scheduleJobs(getScheduler()); } catch (Exception e) { logger.error("Error scheduling jobs: " + e.getMessage(), e); } }
if (isFailOnFileNotFound()) { throw new SchedulerException( "File named '" + getFileName() + "' does not exist.");
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_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;
new XMLSchedulingDataProcessorPlugin(); xmlSchedulingDataProcessorPlugin.setFailOnFileNotFound(false); xmlSchedulingDataProcessorPlugin.setScanInterval(0); quartzSchedulerResources.addSchedulerPlugin(xmlSchedulingDataProcessorPlugin); xmlSchedulingDataProcessorPlugin.initialize( "XMLSchedulingDataProcessorPlugin", quartzScheduler); shutdownHookPlugin.initialize("ShutdownHookPlugin", quartzScheduler);
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); } }
@Override public void start() { try { XMLSchedulingDataProcessor processor = new XMLSchedulingDataProcessor(scheduler.getCascadingClassLoadHelper()); processor.processFile( XMLSchedulingDataProcessor.QUARTZ_XML_DEFAULT_FILE_NAME, failOnFileNotFound); processor.scheduleJobs(getScheduler()); } catch (Exception e) { logger.error("Error scheduling jobs: " + e.getMessage(), e); } }
if (isFailOnFileNotFound()) { throw new SchedulerException( "File named '" + getFileName() + "' does not exist.");
XMLSchedulingDataProcessorPlugin xmlSchedulingDataProcessorPlugin = new XMLSchedulingDataProcessorPlugin(); xmlSchedulingDataProcessorPlugin.setFailOnFileNotFound(false); xmlSchedulingDataProcessorPlugin.setScanInterval(0); quartzSchedulerResources.addSchedulerPlugin(xmlSchedulingDataProcessorPlugin); xmlSchedulingDataProcessorPlugin.initialize("XMLSchedulingDataProcessorPlugin", quartzScheduler); shutdownHookPlugin.initialize("ShutdownHookPlugin", quartzScheduler); annotationJobTriggerPlugin.initialize("AnnotationJobTriggerPlugin", quartzScheduler);
@Override public void start() { try { XMLSchedulingDataProcessor processor = new XMLSchedulingDataProcessor(scheduler.getCascadingClassLoadHelper()); processor.processFile(XMLSchedulingDataProcessor.QUARTZ_XML_DEFAULT_FILE_NAME, failOnFileNotFound); processor.scheduleJobs(getScheduler()); } catch (Exception e) { logger.error("Error scheduling jobs: " + e.getMessage(), e); } }
/** * @see org.quartz.jobs.FileScanListener#fileUpdated(java.lang.String) */ public void fileUpdated(String fileName) { if (started) { processFile(fileName); } }
/** * <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 jobTriggerName = JOB_INITIALIZATION_PLUGIN_NAME + '_' + getName() + '_' + fileBasename.replace('.', '_');
public void processFile(String filePath) { processFile((JobFile)jobFiles.get(filePath)); }
public void processFile(String filePath) { processFile((JobFile)jobFiles.get(filePath)); }