Skip to content

Instantly share code, notes, and snippets.

@theflofly
Created February 14, 2016 21:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theflofly/5d66108b58554f339653 to your computer and use it in GitHub Desktop.
Save theflofly/5d66108b58554f339653 to your computer and use it in GitHub Desktop.
package com.tcb.issue1.job;
import com.tcb.issue1.model.Car;
import com.tcb.issue1.repository.CarRepository;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.listener.JobExecutionListenerSupport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* This class is the job listener for our Car to Offer job. It is useful to insert some data before to
* run the job (cars in our case).
*
* Created by Florian.Courtial on 13/02/16.
*/
@Component
public class CarToOfferJobListener extends JobExecutionListenerSupport {
@Autowired
private CarRepository carRepository;
@Override
public void beforeJob(JobExecution jobExecution) {
carRepository.save(new Car("1", "Ford Escort", 128000, 10));
carRepository.save(new Car("2", "Opel Corsa", 23000, 3));
carRepository.save(new Car("3", "Renault Clio", 290000, 16));
carRepository.save(new Car("4", "Peugeot 206", 1000, 8));
carRepository.save(new Car("5", "Peugeot 107", 95000, 6));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment