Results 1 to 2 of 2

Thread: How to get execution context inside the reader

  1. #1

    Default 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. #2
    Join Date
    May 2010
    Posts
    3

    Default

    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");

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •