org.glassfish.jersey.server
Class ChunkedResponse<T>

java.lang.Object
  extended by org.glassfish.jersey.server.ChunkedResponse<T>
Type Parameters:
T - chunk type.
All Implemented Interfaces:
java.io.Closeable

public class ChunkedResponse<T>
extends java.lang.Object
implements java.io.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)

Constructor Summary
ChunkedResponse(GenericType<T> genericType)
          Creates a new instance of ChunkResponse, passing the chunk type as an instance of GenericType.
ChunkedResponse(java.lang.reflect.Type chunkType)
          Create ChunkedResponse with specified type.
 
Method Summary
 void close()
          Close this response - it will be finalized and underlying connections will be closed or made available for another response.
 boolean isClosed()
          Get state information.
 void write(T chunk)
          Write a chunk.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChunkedResponse

public ChunkedResponse(java.lang.reflect.Type chunkType)
Create ChunkedResponse with specified type.

Parameters:
chunkType - chunk type

ChunkedResponse

public ChunkedResponse(GenericType<T> genericType)
Creates a new instance of ChunkResponse, passing the chunk type as an instance of GenericType.

Parameters:
genericType - chunk type
Method Detail

write

public void write(T chunk)
           throws java.io.IOException
Write a chunk.

Parameters:
chunk - a chunk instance to be written.
Throws:
java.lang.IllegalStateException - when ChunkedResponse is closed.
java.io.IOException - when encountered any problem during serializing or writing a chunk.

close

public void close()
           throws java.io.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 java.io.Closeable
Throws:
java.io.IOException

isClosed

public boolean isClosed()
Get state information. Please note that ChunkedResponse can be closed by the client side - client can close connection from its side.

Returns:
true when closed, false otherwise.


Copyright © 2007-2012 Oracle Corporation. All Rights Reserved. Use is subject to license terms.