@Override public void execute(TaskParameters parameters, CancellationOption cancellationOption) { TaskExecutionContext executionContext = null; LOG.trace("Starting execution for {}", parameters); try { validateIfRequired(parameters); executionContext = new TaskExecutionContext(context.getTask(parameters), parameters.isLenient()); cancellationOption.setExecutionContext(executionContext); LOG.info("Starting task ({}) execution.", executionContext.task()); preExecution(executionContext); actualExecution(parameters, executionContext); postExecution(executionContext); } catch (InvalidTaskParametersException i) { LOG.error("Task execution failed due to invalid parameters: " + String.join(". ", i.getReasons()), i); executionFailed(i, executionContext); } catch (TaskException e) { LOG.error(String.format("Task (%s) execution failed.", ofNullable(executionContext).map(c -> c.task().toString()).orElse("")), e); executionFailed(e, executionContext); } catch (RuntimeException e) { executionFailed(e, executionContext); throw e; } }
@Override public void execute(TaskParameters parameters, CancellationOption cancellationOption) { TaskExecutionContext executionContext = null; LOG.trace("Starting execution for {}", parameters); try { validateIfRequired(parameters); executionContext = new TaskExecutionContext(context.getTask(parameters), parameters.isLenient()); cancellationOption.setExecutionContext(executionContext); LOG.info("Starting task ({}) execution.", executionContext.task()); preExecution(executionContext); actualExecution(parameters, executionContext); postExecution(executionContext); } catch (InvalidTaskParametersException i) { LOG.error("Task execution failed due to invalid parameters: " + String.join(". ", i.getReasons()), i); executionFailed(i, executionContext); } catch (TaskException e) { LOG.error(String.format("Task (%s) execution failed.", ofNullable(executionContext).map(c -> c.task().toString()).orElse("")), e); executionFailed(e, executionContext); } catch (RuntimeException e) { executionFailed(e, executionContext); throw e; } }