Sync with 3.1.x
* 3.1.x: Demonstrate use of @Configuration as meta-annotation Prune dead code from JmsTransactionManager#doBegin Apply @Configuration BeanNameGenerator consistently Improve @Configuration bean name discovery Fix infinite recursion bug in nested @Configuration Polish static imports Minor fix in ServletResponseMethodArgumentResolver extracted ResourceUtils.useCachesIfNecessary(URLConnection) method (SP prepared for 3.1.1 release CustomSQLExceptionTranslatorRegistry/Registrar etc revised CustomSQLExceptionTranslatorRegistry/Registrar method naming use custom InputStream traversal instead of a full byte array (SPR-911 PathMatchingResourcePatternResolver preserves caching for JNLP jar con Resource "contentLength()" implementations work with OSGi bundle resou fixed MethodInvokingJobDetailFactoryBean for compatibility with Quartz fixed MethodInvokingJobDetailFactoryBean for compatibility with Quartz
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2011 the original author or authors.
|
||||
* Copyright 2002-2012 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.
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.scheduling.quartz;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
@@ -40,6 +41,7 @@ import org.springframework.beans.support.ArgumentConvertingMethodInvoker;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.MethodInvoker;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
/**
|
||||
* {@link org.springframework.beans.factory.FactoryBean} that exposes a
|
||||
@@ -80,6 +82,8 @@ public class MethodInvokingJobDetailFactoryBean extends ArgumentConvertingMethod
|
||||
|
||||
private static Class<?> jobDetailImplClass;
|
||||
|
||||
private static Method setResultMethod;
|
||||
|
||||
static {
|
||||
try {
|
||||
jobDetailImplClass = Class.forName("org.quartz.impl.JobDetailImpl");
|
||||
@@ -87,6 +91,14 @@ public class MethodInvokingJobDetailFactoryBean extends ArgumentConvertingMethod
|
||||
catch (ClassNotFoundException ex) {
|
||||
jobDetailImplClass = null;
|
||||
}
|
||||
try {
|
||||
Class jobExecutionContextClass =
|
||||
QuartzJobBean.class.getClassLoader().loadClass("org.quartz.JobExecutionContext");
|
||||
setResultMethod = jobExecutionContextClass.getMethod("setResult", Object.class);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new IllegalStateException("Incompatible Quartz API: " + ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -296,7 +308,7 @@ public class MethodInvokingJobDetailFactoryBean extends ArgumentConvertingMethod
|
||||
@Override
|
||||
protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
|
||||
try {
|
||||
context.setResult(this.methodInvoker.invoke());
|
||||
ReflectionUtils.invokeMethod(setResultMethod, context, this.methodInvoker.invoke());
|
||||
}
|
||||
catch (InvocationTargetException ex) {
|
||||
if (ex.getTargetException() instanceof JobExecutionException) {
|
||||
|
||||
Reference in New Issue
Block a user