users@jax-rs-spec.java.net

[jax-rs-spec users] Re: Default Media Type for SSE even data

From: Sergey Beryozkin <sberyozkin_at_talend.com>
Date: Sat, 14 Nov 2015 12:38:42 +0000

Hi Santiago - sounds good, to be honest this is all I'm after, being
able to set a media type once.

Sergey

P.S. Should we try and provide the same for Client API ?
On 13/11/15 14:00, Santiago Pericasgeertsen wrote:
>> On Nov 12, 2015, at 6:01 AM, Sergey Beryozkin <sberyozkin_at_talend.com> wrote:
>>
>> Hi
>>
>> I guess it can be easier to have a new thread on it.
>> The question: how users can set a MT once for the purpose of formatting the event data, as opposed to
>> setting it on the builder every time.
> Haven’t looked at this in any detail, but it seems that setting it in the SseEventOutput instance may be an option …
>
> — Santiago
>
>> Perhaps my solution to it was not ideal - lets do something simpler, perhaps at the Sse channel initialization time, etc
>>
>> Thanks, Sergey
>>
>>> I'm sure you know, without SSE, when we have
>>>
>>> @Produces("application/json")
>>> @GET
>>> public Book getBook() {
>>> return Response.ok(new Book()).type("application/xml").build();
>>> }
>>>
>>> the final CT to be used for selecting MBW is "application/xml". I.e, if the application code does not set "application/xml" then the default application/json is set, but the application can override it.
>>>
>>> This is exactly what I suggested:
>>>
>>> @Produces("application/json")
>>> @SseProduces
>>> public SseOutputChannel get() {
>>> // set MT for a given event to application/bar
>>> }
>>>
>>> or
>>>
>>> @SseProduces
>>> @Produces("application/json")
>>> public SseOutputChannel get() {
>>> // all events data are JSON - why set it for every event if non-SSE users can avoid doing by having @Produces ?
>>> }
>>>
>>> or
>>>
>>> @SseProduces
>>> public SseOutputChannel get() {
>>> // all events data MTs are set individually
>>> }
>>>
>>>
>>> However I'm agreeing that
>>>
>>> '_at_SseProduces' is a special approach. Hmm...
>>>
>>> So what can be done to make this (non SSE)
>>>
>>> @Produces("application/json")
>>> @GET
>>> public Book getBook() {
>>> return Response.ok(new Book()).build();
>>> }
>>>
>>> where a user does not have to set a type on every response working for SSE too ?