Class CleanupCallable<V>
- java.lang.Object
-
- de.aristaflow.adept2.util.threading.CleanupCallable<V>
-
- Type Parameters:
V
- the result type of methodcall
.
- All Implemented Interfaces:
Callable<V>
public class CleanupCallable<V> extends Object implements Callable<V>
A cleanup callable executes a callable and afterwards a special cleanup consuming runnable finally after the first callable. Problems occurring in the cleanup will be logged to the designated logger. This way exceptions from the first callable will not be swallowed.
-
-
Field Summary
Fields Modifier and Type Field Description protected Callable<V>
callable
The callable executed normally.protected ConsumingRunnable<V,Throwable>
cleanup
The cleanup runnable executed after the normal execution has terminated.protected Logger
logger
The logger for logging exceptions from the cleanup runnable.
-
Constructor Summary
Constructors Constructor Description CleanupCallable(Callable<V> callable, ConsumingRunnable<V,Throwable> cleanup, Logger logger)
Creates a new cleanup runnable executing the callable and the cleanup runnable finally after the callable.
-
-
-
Field Detail
-
cleanup
protected final ConsumingRunnable<V,Throwable> cleanup
The cleanup runnable executed after the normal execution has terminated.
-
logger
protected final Logger logger
The logger for logging exceptions from the cleanup runnable.
-
-
Constructor Detail
-
CleanupCallable
public CleanupCallable(Callable<V> callable, ConsumingRunnable<V,Throwable> cleanup, Logger logger)
Creates a new cleanup runnable executing the callable and the cleanup runnable finally after the callable. Problems occurring in the cleanup will be logged to the designated logger.- Parameters:
callable
- The callable executed normally.cleanup
- The cleanup runnable executed after the normal execution has terminated.logger
- The logger for logging exceptions from the cleanup.
-
-