diff --git a/org.springframework.context/src/main/java/org/springframework/scheduling/support/ScheduledMethodRunnable.java b/org.springframework.context/src/main/java/org/springframework/scheduling/support/ScheduledMethodRunnable.java index 2f7270747e6..207a717a05e 100644 --- a/org.springframework.context/src/main/java/org/springframework/scheduling/support/ScheduledMethodRunnable.java +++ b/org.springframework.context/src/main/java/org/springframework/scheduling/support/ScheduledMethodRunnable.java @@ -23,12 +23,13 @@ import java.lang.reflect.UndeclaredThrowableException; import org.springframework.util.ReflectionUtils; /** - * Variation of {@link MethodInvokingRunnable} meant to be used for processing + * Variant of {@link MethodInvokingRunnable} meant to be used for processing * of no-arg scheduled methods. Propagates user exceptions to the caller, * assuming that an error strategy for Runnables is in place. * * @author Juergen Hoeller * @since 3.0.6 + * @see org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor */ public class ScheduledMethodRunnable implements Runnable { @@ -59,6 +60,7 @@ public class ScheduledMethodRunnable implements Runnable { public void run() { try { + ReflectionUtils.makeAccessible(this.method); this.method.invoke(this.target); } catch (InvocationTargetException ex) { diff --git a/org.springframework.context/src/test/java/org/springframework/scheduling/annotation/taskNamespaceTests.xml b/org.springframework.context/src/test/java/org/springframework/scheduling/annotation/taskNamespaceTests.xml index 9f613201377..2dc689973c9 100644 --- a/org.springframework.context/src/test/java/org/springframework/scheduling/annotation/taskNamespaceTests.xml +++ b/org.springframework.context/src/test/java/org/springframework/scheduling/annotation/taskNamespaceTests.xml @@ -11,12 +11,20 @@ --> - + + + + + + + + + diff --git a/org.springframework.context/src/test/java/org/springframework/scheduling/config/ScheduledTasksBeanDefinitionParserTests.java b/org.springframework.context/src/test/java/org/springframework/scheduling/config/ScheduledTasksBeanDefinitionParserTests.java index 52112929038..295c282ad0d 100644 --- a/org.springframework.context/src/test/java/org/springframework/scheduling/config/ScheduledTasksBeanDefinitionParserTests.java +++ b/org.springframework.context/src/test/java/org/springframework/scheduling/config/ScheduledTasksBeanDefinitionParserTests.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. @@ -16,19 +16,18 @@ package org.springframework.scheduling.config; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - +import java.lang.reflect.Method; import java.util.Collection; import java.util.Map; +import static org.junit.Assert.*; import org.junit.Before; import org.junit.Test; import org.springframework.beans.DirectFieldAccessor; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.springframework.scheduling.support.MethodInvokingRunnable; +import org.springframework.scheduling.support.ScheduledMethodRunnable; /** * @author Mark Fisher @@ -64,11 +63,11 @@ public class ScheduledTasksBeanDefinitionParserTests { Map tasks = (Map) new DirectFieldAccessor( this.registrar).getPropertyValue("fixedRateTasks"); Runnable runnable = tasks.keySet().iterator().next(); - assertEquals(MethodInvokingRunnable.class, runnable.getClass()); - Object targetObject = ((MethodInvokingRunnable) runnable).getTargetObject(); - String targetMethod = ((MethodInvokingRunnable) runnable).getTargetMethod(); + assertEquals(ScheduledMethodRunnable.class, runnable.getClass()); + Object targetObject = ((ScheduledMethodRunnable) runnable).getTarget(); + Method targetMethod = ((ScheduledMethodRunnable) runnable).getMethod(); assertEquals(this.testBean, targetObject); - assertEquals("test", targetMethod); + assertEquals("test", targetMethod.getName()); } @Test