Class MethodInvokingTaskletAdapter
java.lang.Object
org.springframework.batch.item.adapter.AbstractMethodInvokingDelegator<Object>
org.springframework.batch.core.step.tasklet.MethodInvokingTaskletAdapter
- All Implemented Interfaces:
Tasklet,org.springframework.beans.factory.InitializingBean
public class MethodInvokingTaskletAdapter
extends AbstractMethodInvokingDelegator<Object>
implements Tasklet
A
Tasklet that wraps a method in a POJO. By default the return value is
ExitStatus.COMPLETED unless the delegate POJO itself returns an
ExitStatus. The POJO method is usually going to have no arguments, but a static
argument or array of arguments can be used by setting the arguments property.- Author:
- Dave Syer, Mahmoud Ben Hassine
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.batch.item.adapter.AbstractMethodInvokingDelegator
AbstractMethodInvokingDelegator.InvocationTargetThrowableWrapper -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionexecute(StepContribution contribution, ChunkContext chunkContext) Delegate execution to the target object and translate the return value to anExitStatusby invoking a method in the delegate POJO.protected ExitStatusIf the result is anExitStatusalready just return that, otherwise returnExitStatus.COMPLETED.Methods inherited from class org.springframework.batch.item.adapter.AbstractMethodInvokingDelegator
afterPropertiesSet, getArguments, getTargetMethod, getTargetObject, invokeDelegateMethod, invokeDelegateMethodWithArgument, invokeDelegateMethodWithArguments, setArguments, setTargetMethod, setTargetObject
-
Constructor Details
-
MethodInvokingTaskletAdapter
public MethodInvokingTaskletAdapter()
-
-
Method Details
-
execute
@Nullable public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception Delegate execution to the target object and translate the return value to anExitStatusby invoking a method in the delegate POJO. Ignores theStepContributionand the attributes.- Specified by:
executein interfaceTasklet- Parameters:
contribution- mutable state to be passed back to update the current step executionchunkContext- attributes shared between invocations but not between restarts- Returns:
- an
RepeatStatusindicating whether processing is continuable. Returningnullis interpreted asRepeatStatus.FINISHED - Throws:
Exception- thrown if error occurs during execution.- See Also:
-
mapResult
If the result is anExitStatusalready just return that, otherwise returnExitStatus.COMPLETED.- Parameters:
result- the value returned by the delegate method- Returns:
- an
ExitStatusconsistent with the result
-