Announcement Announcement Module
Collapse
No announcement yet.
How to get execution context inside the reader Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to get execution context inside the reader

    Hi ,

    I have implemented the ItemReader interface.Inside the custom item reader, how we will get the execution context?In execution context ,how we can store any key/ value pairs?

    Regards,
    Siva

  • #2
    Hi,
    To get the execution context in custom reader,You need to implement beforeStep() or afterStep() method.
    In that you have to put some value in execution context and you can access that value in next step wherever required,
    Like

    @BeforeStep
    public void beforeStep(StepExecution stepExecution) throws Exception {
    ExitStatus exitStatus = stepExecution.getExitStatus();
    stepExecution.getJobExecution().getExecutionContex t().put("Name","testUser");

    return exitStatus;
    }

    To access the value from execution context this way,
    String str = (String) stepExecution.getJobExecution().getExecutionContex t().get("Name");

    Comment

    Working...
    X