• Post Reply Bookmark Topic Watch Topic
  • New Topic

Making values assigned to JobContext available in an abstract Class  RSS feed

 
Ranch Hand
Posts: 71
BSD IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • 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: 9610
37
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • 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: 71
BSD IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!