Class MethodInvokingRunnable

  extended by org.springframework.util.MethodInvoker
      extended by
          extended by
All Implemented Interfaces:
Runnable, BeanClassLoaderAware, InitializingBean
Direct Known Subclasses:

public class MethodInvokingRunnable
extends ArgumentConvertingMethodInvoker
implements Runnable, BeanClassLoaderAware, InitializingBean

Adapter that implements the Runnable interface as a configurable method invocation based on Spring's MethodInvoker.

Inherits common configuration properties from MethodInvoker.

Useful to generically encapsulate a method invocation as timer task for java.util.Timer, in combination with a DelegatingTimerTask adapter. Can also be used with JDK 1.5's java.util.concurrent.Executor abstraction, which works with plain Runnables.

Extended by Spring's MethodInvokingTimerTaskFactoryBean adapter for java.util.TimerTask. Note that you can populate a ScheduledTimerTask object with a plain MethodInvokingRunnable instance as well, which will automatically get wrapped with a DelegatingTimerTask.

Juergen Hoeller
See Also:
ScheduledTimerTask.setRunnable(Runnable), Executor.execute(Runnable)

Field Summary
protected  Log logger
Constructor Summary
Method Summary
 void afterPropertiesSet()
          Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).
protected  String getInvocationFailureMessage()
          Build a message for an invocation failure exception.
protected  Class resolveClassName(String className)
          Resolve the given class name into a Class.
 void run()
 void setBeanClassLoader(ClassLoader classLoader)
          Callback that supplies the bean class loader to a bean instance.
Methods inherited from class
doFindMatchingMethod, findMatchingMethod, getDefaultTypeConverter, getTypeConverter, registerCustomEditor, setTypeConverter
Methods inherited from class org.springframework.util.MethodInvoker
getArguments, getPreparedMethod, getTargetClass, getTargetMethod, getTargetObject, getTypeDifferenceWeight, invoke, isPrepared, prepare, setArguments, setStaticMethod, setTargetClass, setTargetMethod, setTargetObject
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail


protected final Log logger
Constructor Detail


public MethodInvokingRunnable()
Method Detail


public void setBeanClassLoader(ClassLoader classLoader)
Description copied from interface: BeanClassLoaderAware
Callback that supplies the bean class loader to a bean instance.

Invoked after the population of normal bean properties but before an initialization callback such as InitializingBean's InitializingBean.afterPropertiesSet() method or a custom init-method.

Specified by:
setBeanClassLoader in interface BeanClassLoaderAware
classLoader - the owning class loader; may be null in which case a default ClassLoader must be used, for example the ClassLoader obtained via ClassUtils.getDefaultClassLoader()


protected Class resolveClassName(String className)
                          throws ClassNotFoundException
Description copied from class: MethodInvoker
Resolve the given class name into a Class.

The default implementations uses ClassUtils.forName, using the thread context class loader.

resolveClassName in class MethodInvoker
className - the class name to resolve
the resolved Class
ClassNotFoundException - if the class name was invalid


public void afterPropertiesSet()
                        throws ClassNotFoundException,
Description copied from interface: InitializingBean
Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).

This method allows the bean instance to perform initialization only possible when all bean properties have been set and to throw an exception in the event of misconfiguration.

Specified by:
afterPropertiesSet in interface InitializingBean


public void run()
Specified by:
run in interface Runnable


protected String getInvocationFailureMessage()
Build a message for an invocation failure exception.

the error message, including the target method name etc

Copyright © 2002-2008 The Spring Framework.