updated Quartz scheduling package to support Quartz 1.8 as well
This commit is contained in:
parent
f1b9b8e924
commit
8e169a2782
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2009 the original author or authors.
|
* Copyright 2002-2011 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -40,6 +40,13 @@ public class LocalTaskExecutorThreadPool implements ThreadPool {
|
||||||
private Executor taskExecutor;
|
private Executor taskExecutor;
|
||||||
|
|
||||||
|
|
||||||
|
public void setInstanceId(String schedInstId) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInstanceName(String schedName) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void initialize() throws SchedulerConfigException {
|
public void initialize() throws SchedulerConfigException {
|
||||||
// Absolutely needs thread-bound TaskExecutor to initialize.
|
// Absolutely needs thread-bound TaskExecutor to initialize.
|
||||||
this.taskExecutor = SchedulerFactoryBean.getConfigTimeTaskExecutor();
|
this.taskExecutor = SchedulerFactoryBean.getConfigTimeTaskExecutor();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2008 the original author or authors.
|
* Copyright 2002-2011 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package org.springframework.scheduling.quartz;
|
package org.springframework.scheduling.quartz;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
@ -34,7 +35,6 @@ import org.quartz.SchedulerListener;
|
||||||
import org.quartz.Trigger;
|
import org.quartz.Trigger;
|
||||||
import org.quartz.TriggerListener;
|
import org.quartz.TriggerListener;
|
||||||
import org.quartz.spi.ClassLoadHelper;
|
import org.quartz.spi.ClassLoadHelper;
|
||||||
import org.quartz.xml.JobSchedulingDataProcessor;
|
|
||||||
|
|
||||||
import org.springframework.context.ResourceLoaderAware;
|
import org.springframework.context.ResourceLoaderAware;
|
||||||
import org.springframework.core.io.ResourceLoader;
|
import org.springframework.core.io.ResourceLoader;
|
||||||
|
|
@ -240,9 +240,25 @@ public abstract class SchedulerAccessor implements ResourceLoaderAware {
|
||||||
if (this.jobSchedulingDataLocations != null) {
|
if (this.jobSchedulingDataLocations != null) {
|
||||||
ClassLoadHelper clh = new ResourceLoaderClassLoadHelper(this.resourceLoader);
|
ClassLoadHelper clh = new ResourceLoaderClassLoadHelper(this.resourceLoader);
|
||||||
clh.initialize();
|
clh.initialize();
|
||||||
JobSchedulingDataProcessor dataProcessor = new JobSchedulingDataProcessor(clh, true, true);
|
try {
|
||||||
|
// Quartz 1.8 or higher?
|
||||||
|
Class dataProcessorClass = getClass().getClassLoader().loadClass("import org.quartz.xml.XMLSchedulingDataProcessor");
|
||||||
|
logger.debug("Using Quartz 1.8 XMLSchedulingDataProcessor");
|
||||||
|
Object dataProcessor = dataProcessorClass.getConstructor(ClassLoadHelper.class).newInstance(clh);
|
||||||
|
Method processFileAndScheduleJobs = dataProcessorClass.getMethod("processFileAndScheduleJobs", String.class, Scheduler.class);
|
||||||
for (String location : this.jobSchedulingDataLocations) {
|
for (String location : this.jobSchedulingDataLocations) {
|
||||||
dataProcessor.processFileAndScheduleJobs(location, getScheduler(), this.overwriteExistingJobs);
|
processFileAndScheduleJobs.invoke(dataProcessor, location, getScheduler());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (ClassNotFoundException ex) {
|
||||||
|
// Quartz 1.6
|
||||||
|
Class dataProcessorClass = getClass().getClassLoader().loadClass("import org.quartz.xml.JobSchedulingDataProcessor");
|
||||||
|
logger.debug("Using Quartz 1.6 JobSchedulingDataProcessor");
|
||||||
|
Object dataProcessor = dataProcessorClass.getConstructor(ClassLoadHelper.class, boolean.class, boolean.class).newInstance(clh, true, true);
|
||||||
|
Method processFileAndScheduleJobs = dataProcessorClass.getMethod("processFileAndScheduleJobs", String.class, Scheduler.class, boolean.class);
|
||||||
|
for (String location : this.jobSchedulingDataLocations) {
|
||||||
|
processFileAndScheduleJobs.invoke(dataProcessor, location, getScheduler(), this.overwriteExistingJobs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2010 the original author or authors.
|
* Copyright 2002-2011 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -74,9 +74,9 @@ import org.springframework.util.CollectionUtils;
|
||||||
* automatically apply to Scheduler operations performed within those scopes.
|
* automatically apply to Scheduler operations performed within those scopes.
|
||||||
* Alternatively, you may add transactional advice for the Scheduler itself.
|
* Alternatively, you may add transactional advice for the Scheduler itself.
|
||||||
*
|
*
|
||||||
* <p><b>Note:</b> This version of Spring's SchedulerFactoryBean requires
|
* <p><b>Note:</b> This version of Spring's SchedulerFactoryBean supports Quartz 1.x,
|
||||||
* Quartz 1.5.x or 1.6.x. The "jobSchedulingDataLocation" feature requires
|
* more specifically Quartz 1.5 or higher. The "jobSchedulingDataLocation" feature
|
||||||
* Quartz 1.6.1 or higher (as of Spring 2.5.5).
|
* requires Quartz 1.6.1 or higher (as of Spring 2.5.5).
|
||||||
*
|
*
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
* @since 18.02.2004
|
* @since 18.02.2004
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue