/** * The operation's result after it has completed. Waits until a result is available. * * @return The operation's result or null if the operation type does not produce any result. * @throws {@link AsyncDaoException} if the operation produced an exception * @see #waitForCompletion() */ public synchronized Object getResult() { if (!completed) { waitForCompletion(); } if (throwable != null) { throw new AsyncDaoException(this, throwable); } return result; }
public void testAsynCallInTx() { AsyncOperation operation = asyncSession.callInTx(new Callable<String>() { @Override public String call() throws Exception { txThread = Thread.currentThread(); return "OK"; } }); assertEquals("OK", operation.waitForCompletion()); assertNotNull(txThread); assertFalse(Thread.currentThread().equals(txThread)); }
/** * The operation's result after it has completed. Waits until a result is available. * * @return The operation's result or null if the operation type does not produce any result. * @throws {@link AsyncDaoException} if the operation produced an exception * @see #waitForCompletion() */ public synchronized Object getResult() { if (!completed) { waitForCompletion(); } if (throwable != null) { throw new AsyncDaoException(this, throwable); } return result; }