/** * Calls {@code doWork()} with proper error handling and then {@code loop()} again to schedule the next call. */ private void executeWork() { try { if (orchestration == null || orchestration.tryExecuteBackgroundLoop(getName())) { try { Watch w = Watch.start(); LocalDateTime now = LocalDateTime.now(); String executedWork = doWork(); buildAndLogExecutionInfo(w, now, executedWork); } finally { if (orchestration != null) { orchestration.backgroundLoopCompleted(getName(), executionInfo); } } } } catch (Exception e) { Exceptions.handle(Tasks.LOG, e); } loop(); }