use of javax.ejb.AsyncResult in project wildfly by wildfly.
the class SecuredStatelessBean method method.
@RolesAllowed("allowed")
public Future<Boolean> method() throws InterruptedException, ExecutionException {
try {
if (!startLatch.await(5, TimeUnit.SECONDS)) {
throw new RuntimeException("Invocation was not asynchronous");
}
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
SecuredStatelessLocal localSearchedBean = null;
try {
Context context = new InitialContext();
localSearchedBean = (SecuredStatelessLocal) context.lookup("java:module/" + SecuredStatelessBean.class.getSimpleName() + "!" + SecuredStatelessLocal.class.getName());
} catch (NamingException e) {
throw new RuntimeException(e);
}
final CountDownLatch latchLocal = new CountDownLatch(1);
final Future<Boolean> future = localSearchedBean.localSecured(latchLocal);
latchLocal.countDown();
boolean result = future.get();
Assert.assertTrue(result);
return new AsyncResult<Boolean>(true);
}
use of javax.ejb.AsyncResult in project wildfly by wildfly.
the class AsyncBeanRemote method futureMethod.
@Override
public Future<Boolean> futureMethod() throws InterruptedException, ExecutionException {
AsyncBean.futureMethodCalled = false;
final CountDownLatch latch = new CountDownLatch(1);
final Future<Boolean> future = asyncBean.futureMethod(latch);
latch.countDown();
return new AsyncResult<Boolean>(future.get());
}
Aggregations