org.springframework.binding.method
Class MethodInvoker

java.lang.Object
  extended by org.springframework.binding.method.MethodInvoker

public class MethodInvoker
extends java.lang.Object

A helper for invoking typed methods on arbitrary objects, with support for argument value type conversion from values retrieved from an argument attribute source, and conversion of the result to a desired type.

Author:
Keith Donald, Jeremy Grelle

Constructor Summary
MethodInvoker()
           
 
Method Summary
protected  java.lang.Object applyTypeConversion(java.lang.Object value, java.lang.Class targetType)
          Apply type conversion on the supplied value
 java.lang.Object invoke(MethodSignature signature, java.lang.Object bean, java.lang.Object argumentSource)
          Invoke the method on the bean provided.
 void setConversionService(ConversionService conversionService)
          Sets the conversion service to convert argument values as needed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MethodInvoker

public MethodInvoker()
Method Detail

setConversionService

public void setConversionService(ConversionService conversionService)
Sets the conversion service to convert argument values as needed.


invoke

public java.lang.Object invoke(MethodSignature signature,
                               java.lang.Object bean,
                               java.lang.Object argumentSource)
                        throws MethodInvocationException
Invoke the method on the bean provided. Argument values are pulled from the provided argument source.

Parameters:
signature - the definition of the method to invoke, including the method name and the method argument types
bean - the bean to invoke
argumentSource - the source for method arguments
Returns:
the invoked method's return value
Throws:
MethodInvocationException - the method could not be invoked

applyTypeConversion

protected java.lang.Object applyTypeConversion(java.lang.Object value,
                                               java.lang.Class targetType)
Apply type conversion on the supplied value

Parameters:
value - the raw value to be converted
targetType - the target type for the conversion
Returns:
the converted result