jsr340-experts@servlet-spec.java.net

[jsr340-experts] Re: Do we really need async IO

From: Rajiv Mordani <rajiv.mordani_at_oracle.com>
Date: Fri, 09 Mar 2012 11:26:05 -0800

I think we discussed whether we should do an API with this style early
on. The problems with these are all the ByteBuffers that you could have
for example if you have a slow connection.
Also I am not so sure about tying it to AsyncContext for the
CompletionHandler. If we were to do this style of an API I don't think
we should be necessarily joined at hip with AsyncContext.

Also why do we need to read any content into a File? I don't understand
that?

- Rajiv


On 3/6/2012 2:20 PM, Greg Wilkins wrote:
>
> Here is the kind of java7 inspired API I'm thinking about to add to
> AsyncContext:
>
>
>
> /* ------------------------------------------------------------ */
> /**
> * Write the buffer and then call the completion handler
> * @param buffer
> * @param handler
> */
> public void write(ByteBuffer
> buffer,CompletionHandler<Boolean,AsyncContext> handler)
> {
> }
>
> /* ------------------------------------------------------------ */
> /**
> * Write the file and then call the completion handler
> * @param file
> * @param handler
> */
> public void write(File file, CompletionHandler<Boolean,
> AsyncContext> handler)
> {
> }
>
> /* ------------------------------------------------------------ */
> /**
> * Read the request content into memory so that it is available
> * from the {_at_link ServletRequest#getInputStream()} API without
> blocking
> * and then call the completion handler
> * @param attachment
> * @param handler
> */
> public <A> void read(CompletionHandler<Boolean,AsyncContext> handler)
> {
> }
>
> /* ------------------------------------------------------------ */
> /**
> * Read the request content into the file and then call the
> completion handler
> * @param file
> * @param handler
> */
> public <A> void read(File file, CompletionHandler<Boolean,
> AsyncContext> handler)
> {
> }
>
>
>
>