Spring Framework

org.springframework.scheduling.support
Class MethodInvokingRunnable

java.lang.Object
  extended by org.springframework.util.MethodInvoker
      extended by org.springframework.beans.support.ArgumentConvertingMethodInvoker
          extended by org.springframework.scheduling.support.MethodInvokingRunnable
All Implemented Interfaces:
java.lang.Runnable, Aware, BeanClassLoaderAware, InitializingBean
Direct Known Subclasses:
MethodInvokingTimerTaskFactoryBean

public class MethodInvokingRunnable
extends ArgumentConvertingMethodInvoker
implements java.lang.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.

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

Field Summary
protected  org.apache.commons.logging.Log logger
           
 
Constructor Summary
MethodInvokingRunnable()
           
 
Method Summary
 void afterPropertiesSet()
          Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).
protected  java.lang.String getInvocationFailureMessage()
          Build a message for an invocation failure exception.
protected  java.lang.Class resolveClassName(java.lang.String className)
          Resolve the given class name into a Class.
 void run()
           
 void setBeanClassLoader(java.lang.ClassLoader classLoader)
          Callback that supplies the bean class loader to a bean instance.
 
Methods inherited from class org.springframework.beans.support.ArgumentConvertingMethodInvoker
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

logger

protected final org.apache.commons.logging.Log logger
Constructor Detail

MethodInvokingRunnable

public MethodInvokingRunnable()
Method Detail

setBeanClassLoader

public void setBeanClassLoader(java.lang.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
Parameters:
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()

resolveClassName

protected java.lang.Class resolveClassName(java.lang.String className)
                                    throws java.lang.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.

Overrides:
resolveClassName in class MethodInvoker
Parameters:
className - the class name to resolve
Returns:
the resolved Class
Throws:
java.lang.ClassNotFoundException - if the class name was invalid

afterPropertiesSet

public void afterPropertiesSet()
                        throws java.lang.ClassNotFoundException,
                               java.lang.NoSuchMethodException
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
Throws:
java.lang.ClassNotFoundException
java.lang.NoSuchMethodException

run

public void run()
Specified by:
run in interface java.lang.Runnable

getInvocationFailureMessage

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

Returns:
the error message, including the target method name etc

Spring Framework