On Mon, Aug 11, 2008 at 12:43 PM, Dain Sundstrom <[EMAIL PROTECTED]> wrote:
>
> I'm not sure. One thing I don't think should be changed in the spec is the
> async message signature, which is something like this:
>
> Future<ReturnType> asyncMethod(Params);
Ahh, yes. I didn't know it was defined like that by the spec. I just
looked at the draft spec a bit and it seems like the
performCalculation() method example that supposed to demonstrate
asynch invocation is implemented synchronously. I wondering if we
could get it updated to use ExecutorService or mention JSR 236, e.g.
do something like that:
@Resource
ManagedExecutorService executorService;
@Asynchronous
public Future<Integer> performCalculation(...) {
Callable<Integer> task = new Callable<Integer> () {
public Integer call() throws Exception {
// ... do calculation
Integer result = ...
return result;
}
}
return executorService.submit(task);
}
I don't know if it is possible, but maybe the EJB spec could also be
extended to support AynchListener to be passed as a parameter when
invoking asynch functions, for example:
@Asynchronous
public Future<Integer> performCalculation(..., AsynchListener listener) {
Callable<Integer> task = new Callable<Integer> () {
public Integer call() throws Exception {
// ... do calculation
Integer result = ...
return result;
}
}
return executorService.submit(task, new
ManagedTaskListenerWrapper(listener));
}
I think that could get you what you want. The JAX-WS Dispatch API
(http://java.sun.com/javase/6/docs/api/javax/xml/ws/Dispatch.html)
already has similar API (but that's purely for clients).
But I understand the problem now and I will try to bring it up to the EG.
Thanks,
Jarek