コード例 #1
0
 @Scheduled(fixedRate = 1 * 60 * 1000, initialDelay = 5000)
 private void performUpdate() {
   // log.info("Updating printers...");
   List<Printer> printerList = printerRepository.getAll();
   try {
     for (Printer printer : printerList) {
       int paperCounter = webScraper.extractCounterStatus(printer.getId());
       if (paperCounter != -1) {
         printer.setPaperCounter(paperCounter);
         printer.setLastUpdatePaperCounter(DateTime.now().toString());
       }
       printer.setStatus(webScraper.extractPrinterStatus(printer.getId()));
       // log.info(printer.getName() + " updated with status " + printer.getStatus() + " and paper
       // " + String.valueOf(printer.getPaperCounter()));
     }
     lastUpdate = DateTime.now();
   } catch (NullPointerException e) {
     // return false;
   }
 }
コード例 #2
0
 public List<Printer> getAll() {
   return printerRepository.getAll();
 }