diff --git a/org.springframework.context.support/src/main/java/org/springframework/scheduling/quartz/AdaptableJobFactory.java b/org.springframework.context.support/src/main/java/org/springframework/scheduling/quartz/AdaptableJobFactory.java
index c060093f974..caddf3584c1 100644
--- a/org.springframework.context.support/src/main/java/org/springframework/scheduling/quartz/AdaptableJobFactory.java
+++ b/org.springframework.context.support/src/main/java/org/springframework/scheduling/quartz/AdaptableJobFactory.java
@@ -16,17 +16,21 @@
package org.springframework.scheduling.quartz;
+import java.lang.reflect.Method;
+
import org.quartz.Job;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.spi.JobFactory;
import org.quartz.spi.TriggerFiredBundle;
+import org.springframework.util.ReflectionUtils;
+
/**
* JobFactory implementation that supports {@link java.lang.Runnable}
* objects as well as standard Quartz {@link org.quartz.Job} instances.
*
- *
Compatible with Quartz 1.x as well as Quartz 2.0, as of Spring 3.1.
+ *
Compatible with Quartz 1.5+ as well as Quartz 2.0, as of Spring 3.1.
*
* @author Juergen Hoeller
* @since 2.0
@@ -65,7 +69,12 @@ public class AdaptableJobFactory implements JobFactory {
* @throws Exception if job instantiation failed
*/
protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception {
- return bundle.getJobDetail().getJobClass().newInstance();
+ // Reflectively adapting to differences between Quartz 1.x and Quartz 2.0...
+ Method getJobDetail = bundle.getClass().getMethod("getJobDetail");
+ Object jobDetail = ReflectionUtils.invokeMethod(getJobDetail, bundle);
+ Method getJobClass = jobDetail.getClass().getMethod("getJobClass");
+ Class jobClass = (Class) ReflectionUtils.invokeMethod(getJobClass, jobDetail);
+ return jobClass.newInstance();
}
/**
diff --git a/org.springframework.context.support/src/main/java/org/springframework/scheduling/quartz/CronTriggerBean.java b/org.springframework.context.support/src/main/java/org/springframework/scheduling/quartz/CronTriggerBean.java
index ee99f4fc803..dc3b9dffc2b 100644
--- a/org.springframework.context.support/src/main/java/org/springframework/scheduling/quartz/CronTriggerBean.java
+++ b/org.springframework.context.support/src/main/java/org/springframework/scheduling/quartz/CronTriggerBean.java
@@ -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");
* you may not use this file except in compliance with the License.
@@ -43,10 +43,9 @@ import org.springframework.util.Assert;
* to automatically register a trigger for the corresponding JobDetail,
* instead of registering the JobDetail separately.
*
- *
NOTE: This convenience subclass does not work with trigger
- * persistence in Quartz 1.6, due to a change in Quartz's trigger handling.
- * Use Quartz 1.5 if you rely on trigger persistence based on this class,
- * or the standard Quartz {@link org.quartz.CronTrigger} class instead.
+ *
NOTE: This convenience subclass does not work against Quartz 2.0.
+ * Use Quartz 2.0's native CronTriggerImpl class or the new
+ * Quartz 2.0 builder API instead.
*
* @author Juergen Hoeller
* @since 18.02.2004
diff --git a/org.springframework.context.support/src/main/java/org/springframework/scheduling/quartz/JobDetailBean.java b/org.springframework.context.support/src/main/java/org/springframework/scheduling/quartz/JobDetailBean.java
index eafd818a960..8ff97295ed4 100644
--- a/org.springframework.context.support/src/main/java/org/springframework/scheduling/quartz/JobDetailBean.java
+++ b/org.springframework.context.support/src/main/java/org/springframework/scheduling/quartz/JobDetailBean.java
@@ -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");
* you may not use this file except in compliance with the License.
@@ -35,6 +35,10 @@ import org.springframework.context.ApplicationContextAware;
* sensible defaults. This class uses the Spring bean name as job name,
* and the Quartz default group ("DEFAULT") as job group if not specified.
*
+ *
NOTE: This convenience subclass does not work against Quartz 2.0.
+ * Use Quartz 2.0's native JobDetailImpl class or the new
+ * Quartz 2.0 builder API instead.
+ *
* @author Juergen Hoeller
* @since 18.02.2004
* @see #setName
diff --git a/org.springframework.context.support/src/main/java/org/springframework/scheduling/quartz/MethodInvokingJobDetailFactoryBean.java b/org.springframework.context.support/src/main/java/org/springframework/scheduling/quartz/MethodInvokingJobDetailFactoryBean.java
index 25ab176ad5b..bd0c5b6f68c 100644
--- a/org.springframework.context.support/src/main/java/org/springframework/scheduling/quartz/MethodInvokingJobDetailFactoryBean.java
+++ b/org.springframework.context.support/src/main/java/org/springframework/scheduling/quartz/MethodInvokingJobDetailFactoryBean.java
@@ -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");
* you may not use this file except in compliance with the License.
@@ -20,12 +20,16 @@ import java.lang.reflect.InvocationTargetException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.quartz.JobDataMap;
import org.quartz.JobDetail;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.Scheduler;
import org.quartz.StatefulJob;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.BeanWrapper;
+import org.springframework.beans.PropertyAccessorFactory;
import org.springframework.beans.factory.BeanClassLoaderAware;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
@@ -61,6 +65,8 @@ import org.springframework.util.MethodInvoker;
* You need to implement your own Quartz Job as a thin wrapper for each case
* where you want a persistent job to delegate to a specific service method.
*
+ *
Compatible with Quartz 1.5+ as well as Quartz 2.0, as of Spring 3.1.
+ *
* @author Juergen Hoeller
* @author Alef Arendsen
* @since 18.02.2004
@@ -70,7 +76,19 @@ import org.springframework.util.MethodInvoker;
* @see #setConcurrent
*/
public class MethodInvokingJobDetailFactoryBean extends ArgumentConvertingMethodInvoker
- implements FactoryBean