Class AbstractMethodInvokingDelegator<T>
java.lang.Object
org.springframework.batch.item.adapter.AbstractMethodInvokingDelegator<T>
- All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean
- Direct Known Subclasses:
ItemProcessorAdapter,ItemReaderAdapter,ItemWriterAdapter,MethodInvokingTaskletAdapter,PropertyExtractingDelegatingItemWriter
public abstract class AbstractMethodInvokingDelegator<T>
extends Object
implements org.springframework.beans.factory.InitializingBean
Superclass for delegating classes which dynamically call a custom method of an injected
object. Provides a convenient API for dynamic method invocation shielding subclasses
from low-level details and exception handling.
Exceptions thrown by a successfully invoked delegate method are re-thrown
without wrapping. In case the delegate method throws a Throwable that doesn't
subclass Exception it will be wrapped by
AbstractMethodInvokingDelegator.InvocationTargetThrowableWrapper.
- Author:
- Robert Kasanicky, Mahmoud Ben Hassine, Glenn Renfro, Stefano Cordio
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected @Nullable Object @Nullable []Return arguments.protected @Nullable Stringprotected @Nullable Objectprotected @Nullable TInvoker the target method with arguments set bysetArguments(Object[]).protected @Nullable TInvokes the target method with given argument.protected @Nullable TinvokeDelegateMethodWithArguments(@Nullable Object[] args) Invokes the target method with given arguments.voidsetArguments(Object @Nullable [] arguments) voidsetTargetMethod(String targetMethod) voidsetTargetObject(Object targetObject)
-
Constructor Details
-
AbstractMethodInvokingDelegator
public AbstractMethodInvokingDelegator()
-
-
Method Details
-
invokeDelegateMethod
Invoker the target method with arguments set bysetArguments(Object[]).- Returns:
- object returned by invoked method
- Throws:
Exception- exception thrown when executing the delegate method.
-
invokeDelegateMethodWithArgument
Invokes the target method with given argument.- Parameters:
object- argument for the target method- Returns:
- object returned by target method
- Throws:
Exception- exception thrown when executing the delegate method.
-
invokeDelegateMethodWithArguments
Invokes the target method with given arguments.- Parameters:
args- arguments for the invoked method- Returns:
- object returned by invoked method
- Throws:
Exception- exception thrown when executing the delegate method.
-
afterPropertiesSet
- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
Exception
-
setTargetObject
- Parameters:
targetObject- the delegate - bean id can be used to set this value in Spring configuration
-
setTargetMethod
- Parameters:
targetMethod- name of the method to be invoked onsetTargetObject(Object).
-
setArguments
- Parameters:
arguments- arguments values for the {setTargetMethod(String). These will be used only when the subclass tries to invoke the target method without providing explicit argument values.If arguments are set to not-null value
afterPropertiesSet()will check the values are compatible with target method's signature. In case arguments arenull(not set), the method signature will not be checked, and it is assumed correct values will be supplied at runtime.
-
getArguments
Return arguments.- Returns:
- arguments
-
getTargetObject
- Returns:
- the object on which the method will be invoked.
- Since:
- 5.1
-
getTargetMethod
- Returns:
- the name of the method to be invoked.
- Since:
- 5.1
-