jax-rs-spec
  1. jax-rs-spec
  2. JAX_RS_SPEC-449

Introduce a typed version of StreamingOutput

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: 2.1
    • Component/s: spec
    • Labels:
      None

      Description

      Markus Karg typed a nice code prototype suggesting the use of java.util.Stream in scope of the possible support for SSE.
      java.util.Stream is available in Java 8 and perhaps it won't map 1 to 1 to JAX-RS centric activities.

      It would be very good for JAX-RS 2.1 API introduce a typed version of StreamingOutput, similar to java.util.Stream, such that it can be used
      with or without SSE. Something like

      interface StreamingResponse<T> {
         interface Writer<T> {
              void write(T);
              // may be useful in non SSE cases, 
              // to properly format the payload, example, to start/end the document with a root tag
              // OutputStream getEntityStream();
              
         }
      
         writeTo(Writer<T> stream);
      }
      

        Activity

        Hide
        beryozkin_sergey added a comment -

        We have it working nicely in scope of binding WebSocket invocations to JAX-RS endpoints, but it will also make it much simpler to produce streaming responses without having to write into OutputStream all the time.

        StreamingResponse provider implementation is straghtforward: it is implemented by asking the injected Providers context to find MBW and delegating to it.

        Show
        beryozkin_sergey added a comment - We have it working nicely in scope of binding WebSocket invocations to JAX-RS endpoints, but it will also make it much simpler to produce streaming responses without having to write into OutputStream all the time. StreamingResponse provider implementation is straghtforward: it is implemented by asking the injected Providers context to find MBW and delegating to it.
        Hide
        beryozkin_sergey added a comment -

        Please do not hesitate to reopen if needed

        Show
        beryozkin_sergey added a comment - Please do not hesitate to reopen if needed

          People

          • Assignee:
            beryozkin_sergey
            Reporter:
            beryozkin_sergey
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: