users@servlet-spec.java.net

[servlet-spec users] [jsr369-experts] Re: Re: Re: Adding support for obtaining post parameters asynchronously

From: Shing Wai Chan <shing.wai.chan_at_oracle.com>
Date: Mon, 5 Dec 2016 18:28:15 -0800

> On Dec 7, 2015, at 10:21 PM, Greg Wilkins <gregw_at_webtide.com> wrote:
>
>
> On 8 December 2015 at 11:30, Edward Burns <edward.burns_at_oracle.com <mailto:edward.burns_at_oracle.com>> wrote:
> GW> I think those options need to be morphed into something that
> GW> operates in the same isReady() loop/callback style of the
> GW> ReadListener, which provides both flow control and help to avoid
> GW> deep callback recursion. Perhaps something like:
>
>
> GW> interface ParameterListener
> GW> {
> GW> void onParameterAvailable(Stream stream};
>
> GW> public interface Stream
> GW> {
> GW> boolean isReady();
> GW> Map.Entry<String,String> getParameter();
> GW> }
> GW> }
>
> This and your other examples beg the question: how do we depend on
> Stream when our maximum JDK level is SE 8?
>
> [...
>
> GW> So in summary, I'm not opposed to making the supported functionality
> GW> in async mode match that of blocking mode, but if we do so it needs
> GW> to support back pressure and to be a near complete match to the
> GW> blocking functionality.
>
> But can we support back pressure without introducing a dependency on the
> actual Streams API?
>
> Thanks,
>
> Ed,
>
> actually this example is not using reactive style. Instead it is an extension of Martin's proposed ParameterListener that will support back pressure by behaving in exactly the same way as the current isReady async IO ReadListener.
>
> Perhaps Stream was not the best name to use for that sub interface :)
>
> As for using the reactive stream API, it is available now, but just not in the package hierarchy that it will be in Java9. I'm not sure it is acceptable to have javax APIs depend on non-javax APIs, so perhaps Reactive Streams themselves are a non-starter until Servlet 4.1

+1 on for the next version as we have Java Flow API in JDK 9.

Shing Wai Chan

>
> Note however, that it has been moderately easy to write adaptors from the isReady byte IO in the servlet API to reactive streams API - so if we support a similar semantic for async parameters and parts, we should be able to later adapt them to the Reactive Stream API.
>
> cheers
>
>
>
>
>
>
>
>
>
>
> --
> Greg Wilkins <gregw@webtide.com <mailto:gregw@webtide.com>> CTO http://webtide.com <http://webtide.com/>