[jax-rs-spec users] [jsr339-experts] Re: Latest async API changes

From: Bill Burke <>
Date: Wed, 08 Aug 2012 16:37:12 -0400

The AsyncResponse.register() methods should have their signature changed to:

     public AsyncResponse registerCallback(Class<?> callback, Class<?>
callbacks) throws NullPointerException, IllegalArgumentException;
     public AsyncResponse registerCallback(Object callback, Object...
callbacks) throws NullPointerException, IllegalArgumentException;

Saves some typing when there is multiple callbacks. Also, IMO, renaming
the method to registerCallback makes the method self describing.
Otherwise you have to read the javadoc to know what it does.

Also, I do not think these methods belong on @Suspended

    Class<? extends TimeoutHandler> timeoutHandler() default
     Class<?>[] callbacks() default {};

DefaultTimeoutHandler should be removed as well. IMO, having this kind
of stuff in an annotation doesn't really provide any value or save any
typing or generally make things easier on the developer. I would even
make the case of removing timeout() or even the entire annotation. It's
just a matter of what looks nicer?

public void suspended(@Suspended(timeout=1, timeUnit=SECONDS,
callbacks=Foo.class, timeoutHandler=Timeout.class) AsyncResponse ) {...}


public void suspended(AsyncResponse response) {



I would say the second looks nicer. (if you add method chaining to

On 8/8/2012 3:06 PM, Bill Burke wrote:
> I don't agree with @ManagedAsync. A method annotated with @ManagedAsync
> is executed in a separate thread? The servlet container is *already*
> doing this so I don't see the point of this annotation.
> Please make ConnectionCallback optional as I don't believe there is any
> capability within Servlet 3 of providing that functionality.
> Everything else looks good.
> On 8/8/2012 2:36 PM, Marek Potociar wrote:
>> Hello experts,
>> Please review the latest async API changes:
>> I tried to make sure the javadoc is self-explanatory. You may also want
>> to consult the async-related examples to see the API in action.
>> Thanks,
>> Marek

Bill Burke
JBoss, a division of Red Hat