public <T> Future<T> submitTask(final Callable<T> task) {
final ContextHandle contextHandle = createContextHandle();
return executorService.submit(new Callable<T>() {
@Override
public T call() throws Exception {
final Handle handle = contextHandle.setup();
try {
return task.call();
} finally {
handle.tearDown();
}
}
});
}