users@jax-rs-spec.java.net

[jax-rs-spec users] Re: NIO reader/writer interface and contract?

From: Santiago Pericasgeertsen <santiago.pericasgeertsen_at_oracle.com>
Date: Tue, 13 Oct 2015 13:29:27 -0400

> On Oct 13, 2015, at 12:40 PM, Bill Burke <bburke_at_redhat.com> wrote:
>
>
>
> On 10/12/2015 10:30 AM, Santiago Pericasgeertsen wrote:
>> (2) NIO:
>>
>> https://github.com/spericas/api/blob/master/examples/src/main/java/jaxrs/examples/nio/FileResource.java
>> https://github.com/spericas/api/blob/master/examples/src/main/java/jaxrs/examples/nio/FileResourceClient.java
>>
>> On the server side, the proposal follows the pattern set by
>> StreamingOutput, but of course using lambdas this time around. As you
>> know, Servlet already supports NIO, but with a completely different API.
>>
>
> I don't think lambdas should be the only approach to NIO. Developers are gonna want to encapsulate NIO parsing logic into reusable components like MessageBodyReaders/Writers, right? These NIO readers/writers would either be consumed internally by the CLient or Server JAX-RS implementation, or passed off to the developers own event loop logic. Wouldn't thesee NIO reader/writers need to hold state as they are called by the event loop when io is ready? Wouldn't that mean they need to support injection?

 Yes, indeed. I should have clarified that the NIO part only addresses the case where the resource needs direct access to the stream, much like StreamingOutput. NIO in MBR and MBW is TBD. As for the state, you can have state in lambdas using non-primitive types and closures.

 It would be great if someone has the cycles to investigate NIO in MBR/MBW’s.
 
— Santiago