/** * Execute database transactions in an isolated context. * * @param <T> return type * @param callable transaction * @return */ synchronized <T> T exec(Callable<T> callable) { // We want to submit db jobs to an executor to isolate // them from the current thread, Future<T> future = _executor.submit(callable); try { return future.get(); } catch (Exception e) { throw new ContextException("DbError", e); } }
public void shutdown() { if (_inMemDs != null) { shutdownInternalDB(_inMemDs); _inMemDs = null; } if (_executor != null) { _executor.shutdownNow(); _executor = null; } }