java.lang.Object | |
↳ | org.springframework.util.MethodInvoker |
Known Direct Subclasses |
Known Indirect Subclasses |
Helper class that allows for specifying a method to invoke in a declarative fashion, be it static or non-static.
Usage: Specify "targetClass"/"targetMethod" or "targetObject"/"targetMethod", optionally specify arguments, prepare the invoker. Afterwards, you may invoke the method any number of times, obtaining the invocation result.
Typically not used directly but via its subclasses
MethodInvokingFactoryBean
and
MethodInvokingJobDetailFactoryBean
.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Return the arguments for the method invocation.
| |||||||||||
Return the prepared Method object that will be invoked.
| |||||||||||
Return the target class on which to call the target method.
| |||||||||||
Return the name of the method to be invoked.
| |||||||||||
Return the target object on which to call the target method.
| |||||||||||
Algorithm that judges the match between the declared parameter types of a candidate method
and a specific list of arguments that this method is supposed to be invoked with.
| |||||||||||
Invoke the specified method.
| |||||||||||
Return whether this invoker has been prepared already,
i.e.
| |||||||||||
Prepare the specified method.
| |||||||||||
Set arguments for the method invocation.
| |||||||||||
Set a fully qualified static method name to invoke,
e.g.
| |||||||||||
Set the target class on which to call the target method.
| |||||||||||
Set the name of the method to be invoked.
| |||||||||||
Set the target object on which to call the target method.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Find a matching method with the specified name for the specified arguments.
| |||||||||||
Resolve the given class name into a Class.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Return the prepared Method object that will be invoked.
Can for example be used to determine the return type.
null
)IllegalStateException | if the invoker hasn't been prepared yet |
---|
Return the target class on which to call the target method.
Return the target object on which to call the target method.
Algorithm that judges the match between the declared parameter types of a candidate method and a specific list of arguments that this method is supposed to be invoked with.
Determines a weight that represents the class hierarchy difference between types and arguments. A direct match, i.e. type Integer -> arg of class Integer, does not increase the result - all direct matches means weight 0. A match between type Object and arg of class Integer would increase the weight by 2, due to the superclass 2 steps up in the hierarchy (i.e. Object) being the last one that still matches the required type Object. Type Number and class Integer would increase the weight by 1 accordingly, due to the superclass 1 step up the hierarchy (i.e. Number) still matching the required type Number. Therefore, with an arg of type Integer, a constructor (Integer) would be preferred to a constructor (Number) which would in turn be preferred to a constructor (Object). All argument weights get accumulated.
paramTypes | the parameter types to match |
---|---|
args | the arguments to match |
Invoke the specified method.
The invoker needs to have been prepared before.
null
if the method has a void return typeInvocationTargetException | if the target method threw an exception |
---|---|
IllegalAccessException | if the target method couldn't be accessed |
Return whether this invoker has been prepared already,
i.e. whether it allows access to getPreparedMethod()
already.
Prepare the specified method. The method can be invoked any number of times afterwards.
Set arguments for the method invocation. If this property is not set, or the Object array is of length 0, a method with no arguments is assumed.
Set a fully qualified static method name to invoke, e.g. "example.MyExampleClass.myExampleMethod". Convenient alternative to specifying targetClass and targetMethod.
Set the target class on which to call the target method. Only necessary when the target method is static; else, a target object needs to be specified anyway.
Set the name of the method to be invoked. Refers to either a static method or a non-static method, depending on a target object being set.
Set the target object on which to call the target method. Only necessary when the target method is not static; else, a target class is sufficient.
Find a matching method with the specified name for the specified arguments.
null
if noneResolve the given class name into a Class.
The default implementations uses ClassUtils.forName
,
using the thread context class loader.
className | the class name to resolve |
---|
ClassNotFoundException | if the class name was invalid |
---|