users@jax-rs-spec.java.net

[jax-rs-spec users] Re: NIO API Proposal in Java

From: Sergey Beryozkin <sberyozkin_at_talend.com>
Date: Tue, 13 Oct 2015 14:08:28 +0100

OK, time to start reading that Java 8 book I have :-) Hope Bill has not
started yet too :-)
On 13/10/15 14:02, Santiago Pericasgeertsen wrote:
>
>> On Oct 13, 2015, at 8:46 AM, Sergey Beryozkin <sberyozkin_at_talend.com
>> <mailto:sberyozkin_at_talend.com>> wrote:
>>
>> Hi Santiago
>>
>> Yes, can they use inner classes instead (not sure if 'yes' implies
>> JDK 7 can be used but I'm not after using JDK7...).
>> I see in your example a Request context has been modified so a new
>> Request method will be visible to a non-lambdas code (request.entity
>> ?), hence I'm curious.
>>
>> https://github.com/spericas/api/blob/master/jaxrs-api/src/main/java/javax/ws/rs/core/Request.java#L181
> Lambdas are functional interfaces. NioReaderHandler is defined as
> follows:
>
> https://github.com/spericas/api/blob/master/jaxrs-api/src/main/java/javax/ws/rs/core/NioReaderHandler.java
>
> That method in Request is being used when a (single) lambda is
> specified; that is, when neither a completion nor an error handler is
> provided. Note that an NioInputStream has an isFinished() method which
> applications can check instead of providing a completion handler if
> they prefer.
>
> ā€” Santiago
>
>
>>
>> Cheers, Sergey
>>
>> On 13/10/15 13:34, Santiago Pericasgeertsen wrote:
>>> Hi Sergey,
>>>
>>> Iā€™m not sure I follow. Is your question whether they can use inner
>>> classes instead of lambdas? Or if they can use a JDK without lambda
>>> support?
>>>
>>> ā€” Santiago
>>>
>>>> On Oct 12, 2015, at 4:39 PM, Sergey Beryozkin
>>>> <sberyozkin_at_talend.com <mailto:sberyozkin_at_talend.com>> wrote:
>>>>
>>>> Hi Santiago, All
>>>>
>>>>> (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.
>>>>>
>>>>>
>>>> This may be a very silly question, but can we have a FileResource
>>>> code also shown in Java ? Fine with the lamdas being used there -
>>>> but can users keep working with the 'traditional' Java syntax in
>>>> order to work with this NIO API ?
>>>>
>>>> Thanks, Sergey
>>
>