Class ChunkedOutput<T>

java.lang.Object
javax.ws.rs.core.GenericType<T>
org.glassfish.jersey.server.ChunkedOutput<T>
Type Parameters:
T - chunk type.
All Implemented Interfaces:
Closeable, AutoCloseable

public class ChunkedOutput<T> extends javax.ws.rs.core.GenericType<T> implements Closeable
Used for sending messages in "typed" chunks. Useful for long running processes, which needs to produce partial responses.
Author:
Pavel Bucek (pavel.bucek at oracle.com), Martin Matula, Marek Potociar (marek.potociar at oracle.com)
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Create new ChunkedOutput.
    protected
    ChunkedOutput(byte[] chunkDelimiter)
    Create new ChunkedOutput with a custom chunk delimiter.
    protected
    ChunkedOutput(byte[] chunkDelimiter, javax.inject.Provider<AsyncContext> asyncContextProvider)
    Create new ChunkedOutput with a custom chunk delimiter.
     
    ChunkedOutput(Type chunkType)
    Create ChunkedOutput with specified type.
     
    ChunkedOutput(Type chunkType, byte[] chunkDelimiter)
    Create new ChunkedOutput with a custom chunk delimiter.
     
    ChunkedOutput(Type chunkType, String chunkDelimiter)
    Create new ChunkedOutput with a custom chunk delimiter.
    protected
    ChunkedOutput(String chunkDelimiter)
    Create new ChunkedOutput with a custom chunk delimiter.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Close this response - it will be finalized and underlying connections will be closed or made available for another response.
    boolean
     
    protected void
     
    int
     
    boolean
    Get state information.
     
    void
    write(T chunk)
    Write a chunk.

    Methods inherited from class javax.ws.rs.core.GenericType

    forInstance, getRawType, getType

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ChunkedOutput

      protected ChunkedOutput()
      Create new ChunkedOutput.
    • ChunkedOutput

      public ChunkedOutput(Type chunkType)
      Create ChunkedOutput with specified type.
      Parameters:
      chunkType - chunk type. Must not be {code null}.
    • ChunkedOutput

      protected ChunkedOutput(byte[] chunkDelimiter)
      Create new ChunkedOutput with a custom chunk delimiter.
      Parameters:
      chunkDelimiter - custom chunk delimiter bytes. Must not be {code null}.
      Since:
      2.4.1
    • ChunkedOutput

      protected ChunkedOutput(byte[] chunkDelimiter, javax.inject.Provider<AsyncContext> asyncContextProvider)
      Create new ChunkedOutput with a custom chunk delimiter.
      Parameters:
      chunkDelimiter - custom chunk delimiter bytes. Must not be {code null}.
      Since:
      2.4.1
    • ChunkedOutput

      public ChunkedOutput(Type chunkType, byte[] chunkDelimiter)
      Create new ChunkedOutput with a custom chunk delimiter.
      Parameters:
      chunkType - chunk type. Must not be {code null}.
      chunkDelimiter - custom chunk delimiter bytes. Must not be {code null}.
      Since:
      2.4.1
    • ChunkedOutput

      protected ChunkedOutput(String chunkDelimiter)
      Create new ChunkedOutput with a custom chunk delimiter.
      Parameters:
      chunkDelimiter - custom chunk delimiter string. Must not be {code null}.
      Since:
      2.4.1
    • ChunkedOutput

      public ChunkedOutput(Type chunkType, String chunkDelimiter)
      Create new ChunkedOutput with a custom chunk delimiter.
      Parameters:
      chunkType - chunk type. Must not be {code null}.
      chunkDelimiter - custom chunk delimiter string. Must not be {code null}.
      Since:
      2.4.1
  • Method Details

    • write

      public void write(T chunk) throws IOException
      Write a chunk.
      Parameters:
      chunk - a chunk instance to be written.
      Throws:
      IOException - if this response is closed or when encountered any problem during serializing or writing a chunk.
    • flushQueue

      protected void flushQueue() throws IOException
      Throws:
      IOException
    • close

      public void close() throws IOException
      Close this response - it will be finalized and underlying connections will be closed or made available for another response.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • isClosed

      public boolean isClosed()
      Get state information. Please note that ChunkedOutput can be closed by the client side - client can close connection from its side.
      Returns:
      true when closed, false otherwise.
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class javax.ws.rs.core.GenericType<T>
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class javax.ws.rs.core.GenericType<T>
    • toString

      public String toString()
      Overrides:
      toString in class javax.ws.rs.core.GenericType<T>