ExecutorJob implements IJob interface and provides opportunity of parallel execution of the several IJob-s, provided as an constructor parameter. Number of threads could be also customized via input parameter of the ExecutorJob constructor. Multiple executions are permitted.
Exception processing strategy is uncommon in comparison to Java executors paradigm: job results could influence each other. When any job throws an exception, all other jobs are cancelled immediately and this exception is rethrown as a result of ExecutorJob execution.
Two supporting implementations of IJob interface are provided for demonstrative and unit-testing needs:
- SomeLongTermJob: emulates some long-term process and calculates execution counters
- SomeExceptionJob: generates runtime exception after some delay
The following unit-tests are provided in ExecutorJobTest class (testExecute_***):
- Basic: tests basic functionality
- Exception: verifies proper exception rethrowing
- Interruptions: checks that all jobs are stopped after an exception in any.
- MultiExec: tests multiple execution of ExecutorJob
- MultiThreading: validates reality of multi-threading processing for IJobs
Implementation is based on maven utility and could be built with the following command (from the sources folder):
mvn package