jsr340-experts@servlet-spec.java.net

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

From: Greg Wilkins <gregw_at_intalio.com>
Date: Wed, 7 Mar 2012 09:20:45 +1100

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)
    {
    }



>