• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Making values assigned to JobContext available in an abstract Class

 
Ranch Hand
Posts: 76
IntelliJ IDE Spring BSD
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Been trying to get this to work for a few days, and after banging my head on it for a while, was wondering if anyone else more experienced with Spring could give a hand?

In a nutshell, what Im trying to do is to take a value that's obtained in a tasklet, and make it available in an abstract class. This abstract class is extended by child classes that would need this value to perform some operations in the steps that we perform. It should then reset once the current job is done and if not complete, move on to the next.

In the tasklet's execute method, I have the following line that assigned data to the StepContext.


then in the abstract class, I have the following


Now I've followed a few texts in trying to get this to work, such as this example at spring.io, although I'm not certain that I implemented it successfully (my project only uses java annotation). I've also verified that the value is being populated into the JobContext, it's just a matter of getting it out that seems to be the issue, as all attempts result in null.

For completeness, this is what I have in the InterstepDataRetriever interface mentioned above


For job listeners, the application is using a class that's extending JobExecutionListener (it does nothing right now other then extend JobListener, since using JobListener directly gave an error). For step, it's using a method that has the following code.


I've verified that this code is being seen and executed.

I've hopefully outlined successfully what is going on, what I've trying to do, and what I'm failing at. If not, please ask for clairafication. This is the second time I've performed this operation and I'm sure I've missed somthing important.
 
Sheriff
Posts: 9691
42
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As a quick check, can you put a println statement in the retrieveInterstepDataFromJobContext to make sure it is being called...
 
Chris Creed
Ranch Hand
Posts: 76
IntelliJ IDE Spring BSD
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ankit Garg wrote:As a quick check, can you put a println statement in the retrieveInterstepDataFromJobContext to make sure it is being called...



I made the following modification in the abstract class mentioned in the OP.



No output was seen in the console.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic