I would expect a call to getExecutionContext
on the StepExecution
to give you the proper context.
@Override
public void beforeStep(StepExecution execution) {
String s = "select getdate()";
execution.getExecutionContext().putString("readQuery", s);
}
Your current solution is getting the StepContext
. The StepContext
is the object that is exposed and used for expression parsing, whereas the ExecutionContext
associated with the StepExecution
is the actual stepExecutionContext. ItemReaders
and ItemWriters
and such object also use the ExecutionContext
to update the state (skipped items, commit count etc.).