jsr370-experts@jax-rs-spec.java.net

Default Media Type for SSE even data

From: Sergey Beryozkin <sberyozkin_at_talend.com>
Date: Thu, 12 Nov 2015 11:01:08 +0000

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.
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 ?