final SessionBeanComponent sessionBeanComponent = (SessionBeanComponent) componentView.getComponent();
final CancellationFlag cancellationFlag = new CancellationFlag();
// add the cancellation flag to the interceptor context
interceptorContext.putPrivateData(CancellationFlag.class, cancellationFlag);
final AsyncInvocationTask asyncInvocationTask = new AsyncInvocationTask(cancellationFlag) {
@Override
protected Object runInvocation() throws Exception {
return componentView.invoke(interceptorContext);
}
};
// invoke
sessionBeanComponent.getAsynchronousExecutor().submit(asyncInvocationTask);
// wait/block for the bean invocation to complete and get the real result to be returned to the client
return asyncInvocationTask.get();
} else {
return componentView.invoke(interceptorContext);
}
}