For a restart after a failed job execution, JBeret automatically restarts from the previous failed job element. However, step has an attribute "allow-start-if-complete", if set to true, the restart after a failed execution will still run these completed steps, even though they appear before the failed step in job.xml. This may be something you want to leverage.
For a restart after a stopped job execution, user can set the restart position in job.xml.
The restart position is stored in JOB_EXECUTION table as column RESTARTPOSITION, in the job repository db. I don't think you should need to change the job execution data in job repository.
If you want to dynamically set the restart position for a restart after a failed job execution, you can try some JBeret internal api (not stable and not recommented) to modify the internal restartPosition value.
If you know where to restart when a step fails, use a job listener, whose afterJob method calls org.jberet.runtime.JobExecutionImpl#setRestartPosition
If you know where to restart at restart time, use a job listener, whose beforeJob method calls
org.jberet.runtime.JobExecutionImpl#setRestartPosition. The desired restartPosition may be passed in as restart job param.
You can access JobExecutionImpl by injecting JobContext, cast it to JobContextImpl, and jobContextImpl.getJobExecution().
I really appreciate the help you and James have given me in implementing JBeret.
you're welcome. It could be a useful feature in JBeret to support custom restart position in a portable way without relying on JBeret internal methods.