Class MethodInvoker

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

public class MethodInvoker extends 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 Details

    • MethodInvoker

      public MethodInvoker()
  • Method Details

    • setConversionService

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

      public Object invoke(MethodSignature signature, Object bean, 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 Object applyTypeConversion(Object value, 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