Java Reference
In-Depth Information
Map<SeatType, Double> pricesInBitcoins =
seatTypeDao.findAll()); // [3]
writeToFile(pricesInBitcoins); // [4]
return "OK";
private Map<SeatType, Double>
calculeteBitcoinPrices(double averageValue, List<SeatType>
findAll) {
Collectors.toMap(seatType -> seatType,
seatType -> seatType.getPrice() / averageValue));
private void writeToFile(Map<SeatType, Double>
pricesInBitcoins) throws Exception {
Properties jobProperties =
jobContext.getProperties(); // [5]
String fileName =
try (BufferedWriter writer = new BufferedWriter(new
FileWriter(fileName))) {
The process method [1] is our entry point to the batchlet. We will start by making a
REST request against an external API [2] and use the response to calculate our prices in
bitcoins [3] . Finally, we will try to write so as to gathered data into a file. As you can
see, once more, we use JobContext to get the configuration properties from the batch-
ing framework (the filename in this case).
You may wonder, what is the point of the return type in the process method? It simply
indicates the status of the job, if it has been completed successfully or not.
Search WWH ::

Custom Search