Top Description Fields Constructors Methods
org.springframework.expression.spel.support

public Class ReflectiveMethodExecutor

extends Object
implements MethodExecutor
Class Inheritance
All Implemented Interfaces
org.springframework.expression.MethodExecutor
Imports
java.lang.reflect.Method, .Modifier, org.springframework.core.MethodParameter, org.springframework.core.convert.TypeDescriptor, org.springframework.expression.AccessException, .EvaluationContext, .MethodExecutor, .TypedValue, org.springframework.lang.Nullable, org.springframework.util.ClassUtils, .ReflectionUtils

MethodExecutor that works via reflection.
Authors
Andy Clement, Juergen Hoeller
Since
3.0

Field Summary

Modifier and TypeField and Description
private boolean
private boolean
private final Method
private final Method
private Class<?>
private final Integer

Constructor Summary

AccessConstructor and Description
public
ReflectiveMethodExecutor(Method
the method to invoke
method
)

Create a new executor for the given method.

public
ReflectiveMethodExecutor(Method
the method to invoke
method
,
Class<?>
the target class to invoke the method on
targetClass
)

Create a new executor for the given method.

Method Summary

Modifier and TypeMethod and Description
public boolean
private Class<?>
public TypedValue
execute(EvaluationContext
the evaluation context in which the method is being executed
context
,
Object
the target of the method invocation; may be null for static methods
target
,
Object...
the arguments to the method; should match (in terms of number and type) whatever the method will need to run
arguments
)

Implements org.springframework.expression.MethodExecutor.execute.

Execute a method in the specified context using the specified arguments.

public final Method
getMethod()

Return the original method that this executor has been configured for.

public Class<?>
getPublicDeclaringClass()

Find the first public class in the method's declaring class hierarchy that declares this method.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

argumentConversionOccurredback to summary
private boolean argumentConversionOccurred
computedPublicDeclaringClassback to summary
private boolean computedPublicDeclaringClass
methodToInvokeback to summary
private final Method methodToInvoke
originalMethodback to summary
private final Method originalMethod
publicDeclaringClassback to summary
private Class<?> publicDeclaringClass
Annotations
@Nullable
varargsPositionback to summary
private final Integer varargsPosition
Annotations
@Nullable

Constructor Detail

ReflectiveMethodExecutorback to summary
public ReflectiveMethodExecutor(Method method)

Create a new executor for the given method.

Parameters
method:Method

the method to invoke

ReflectiveMethodExecutorback to summary
public ReflectiveMethodExecutor(Method method, Class<?> targetClass)

Create a new executor for the given method.

Parameters
method:Method

the method to invoke

targetClass:Class<?>

the target class to invoke the method on

Since
5.3.16

Method Detail

didArgumentConversionOccurback to summary
public boolean didArgumentConversionOccur()
discoverPublicDeclaringClassback to summary
private Class<?> discoverPublicDeclaringClass(Method method, Class<?> clazz)
Annotations
@Nullable
executeback to summary
public TypedValue execute(EvaluationContext context, Object target, Object... arguments) throws AccessException

Implements org.springframework.expression.MethodExecutor.execute.

Doc from org.springframework.expression.MethodExecutor.execute.

Execute a method in the specified context using the specified arguments.

Parameters
context:EvaluationContext

the evaluation context in which the method is being executed

target:Object

the target of the method invocation; may be null for static methods

arguments:Object[]

the arguments to the method; should match (in terms of number and type) whatever the method will need to run

Returns:TypedValue

the value returned from the method

Annotations
@Override
Exceptions
AccessException:
if there is a problem executing the method or if this MethodExecutor has become stale
getMethodback to summary
public final Method getMethod()

Return the original method that this executor has been configured for.

getPublicDeclaringClassback to summary
public Class<?> getPublicDeclaringClass()

Find the first public class in the method's 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 traverse up the type hierarchy to find the first public type that declares the method (if there is one). For toString(), it may traverse as far as Object.

Annotations
@Nullable