jsr339-experts@jax-rs-spec.java.net

[jsr339-experts] Re: Proposal draft for the JAX-RS server-side asynchronous request processing API

From: Marek Potociar <marek.potociar_at_oracle.com>
Date: Mon, 08 Aug 2011 16:08:34 +0200

Hi Bill,

On 08/05/2011 08:10 PM, Bill Burke wrote:
> All your Ctx initiated suspend examples should probably suspend the context *before* you submit the task. Otherwise
> there is a race condition between the suspend() call and the thread doing the resume(). Might want to have doco stating
> that that is required.

I was more thinking that it would be the implementor responsibility to deal with the potential race condition. Do you
see any issues with that?

>
>
> Also, question: Can AsyncContext take a Response object too as a parameter? Also, if a non-Response object is the
> parameter, how will JAX-RS know what media type the object is when it marshalls it? From a @Produces annotation? (ya,
> that's obvious, just making sure.)

Sure, async context should be able to take anything that can be considered as a valid return type of an http resource
method as a parameter. Also, I assume that the combination of suspended http method and resource annotations and the run
time type of the response should be enough to choose the right marshaller. I was also considering to generify the
AsyncContext, but decided not to do it in the end. We may revisit that if you or anyone else in the EG feels it might
make sense.

Marek

>
>
> On 8/5/11 12:25 PM, Marek Potociar wrote:
>> Hello *,
>>
>> Based on the recent discussion in the EG, I have checked in a proposed API code including a couple of sample resources
>> to demonstrate the intended usage:
>>
>> http://java.net/projects/jax-rs-spec/sources/git/revision/e8a964aaa0e8af2febd551660d07df3bbb903bcc
>>
>> Based on the EG feedback, I have focused on simplicity and addressing the most basic scenarios. The API consists of
>> @Suspend method-level annotation and AsyncContext interface.
>>
>> Please review the examples to see how the API is supposed to be used:
>>
>> http://java.net/projects/jax-rs-spec/sources/git/content/src/examples/src/main/java/jaxrs/examples/async/LongRunningAsyncOperationResource.java
>>
>>
>> http://java.net/projects/jax-rs-spec/sources/git/content/src/examples/src/main/java/jaxrs/examples/async/AsyncEventResource.java
>>
>>
>> Looking forward to your feedback.
>>
>> Kind regards,
>> Marek
>