Class MethodInvokingTaskletAdapter
- java.lang.Object
- org.springframework.batch.item.adapter.AbstractMethodInvokingDelegator<java.lang.Object>
- org.springframework.batch.core.step.tasklet.MethodInvokingTaskletAdapter
- All Implemented Interfaces:
Tasklet
,org.springframework.beans.factory.InitializingBean
public class MethodInvokingTaskletAdapter extends AbstractMethodInvokingDelegator<java.lang.Object> implements Tasklet
ATasklet
that wraps a method in a POJO. By default the return value isExitStatus.COMPLETED
unless the delegate POJO itself returns anExitStatus
. 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:
AbstractMethodInvokingDelegator
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.batch.item.adapter.AbstractMethodInvokingDelegator
AbstractMethodInvokingDelegator.InvocationTargetThrowableWrapper
Constructor Summary
Constructors Constructor Description MethodInvokingTaskletAdapter()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RepeatStatus
execute(StepContribution contribution, ChunkContext chunkContext)
Delegate execution to the target object and translate the return value to anExitStatus
by invoking a method in the delegate POJO.protected ExitStatus
mapResult(java.lang.Object result)
If the result is anExitStatus
already just return that, otherwise returnExitStatus.COMPLETED
.Methods inherited from class org.springframework.batch.item.adapter.AbstractMethodInvokingDelegator
afterPropertiesSet, getArguments, invokeDelegateMethod, invokeDelegateMethodWithArgument, invokeDelegateMethodWithArguments, setArguments, setTargetMethod, setTargetObject
Method Detail
execute
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws java.lang.Exception
Delegate execution to the target object and translate the return value to anExitStatus
by invoking a method in the delegate POJO. Ignores theStepContribution
and the attributes.- Specified by:
execute
in 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
RepeatStatus
indicating whether processing is continuable. Returningnull
is interpreted asRepeatStatus.FINISHED
- Throws:
java.lang.Exception
- thrown if error occurs during execution.- See Also:
Tasklet.execute(StepContribution, ChunkContext)
mapResult
protected ExitStatus mapResult(java.lang.Object result)
If the result is anExitStatus
already just return that, otherwise returnExitStatus.COMPLETED
.- Parameters:
result
- the value returned by the delegate method- Returns:
- an
ExitStatus
consistent with the result