org.springframework.expression.spel.support

Class ReflectiveMethodExecutor

  • java.lang.Object
    • org.springframework.expression.spel.support.ReflectiveMethodExecutor
  • All Implemented Interfaces:
    MethodExecutor


    public class ReflectiveMethodExecutor
    extends java.lang.Object
    implements MethodExecutor
    MethodExecutor that works via reflection.
    Since:
    3.0
    Author:
    Andy Clement, Juergen Hoeller
    • Constructor Summary

      Constructors 
      Constructor and Description
      ReflectiveMethodExecutor(java.lang.reflect.Method method)
      Create a new executor for the given method.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      boolean didArgumentConversionOccur() 
      TypedValue execute(EvaluationContext context, java.lang.Object target, java.lang.Object... arguments)
      Execute a command using the specified arguments, and using the specified expression state.
      java.lang.reflect.Method getMethod()
      Return the original method that this executor has been configured for.
      java.lang.Class<?> getPublicDeclaringClass()
      Find the first public class in the methods declaring class hierarchy that declares this method.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ReflectiveMethodExecutor

        public ReflectiveMethodExecutor(java.lang.reflect.Method method)
        Create a new executor for the given method.
        Parameters:
        method - the method to invoke
    • Method Detail

      • getMethod

        public final java.lang.reflect.Method getMethod()
        Return the original method that this executor has been configured for.
      • getPublicDeclaringClass

        @Nullable
        public java.lang.Class<?> getPublicDeclaringClass()
        Find the first public class in the methods declaring class hierarchy that declares this method. Sometimes the reflective method discovery logic finds a suitable method that can easily be called via reflection but cannot be called from generated code when compiling the expression because of visibility restrictions. For example if a non-public class overrides toString(), this helper method will walk up the type hierarchy to find the first public type that declares the method (if there is one!). For toString() it may walk as far as Object.
      • didArgumentConversionOccur

        public boolean didArgumentConversionOccur()
      • execute

        public TypedValue execute(EvaluationContext context,
                                  java.lang.Object target,
                                  java.lang.Object... arguments)
                           throws AccessException
        Description copied from interface: MethodExecutor
        Execute a command using the specified arguments, and using the specified expression state.
        Specified by:
        execute in interface MethodExecutor
        Parameters:
        context - the evaluation context in which the command is being executed
        target - the target object of the call - null for static methods
        arguments - the arguments to the executor, should match (in terms of number and type) whatever the command will need to run
        Returns:
        the value returned from execution
        Throws:
        AccessException - if there is a problem executing the command or the MethodExecutor is no longer valid