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

java.lang.Object
  extended by org.glassfish.jersey.server.ChunkedResponse<T>

public class ChunkedResponse<T>
extends java.lang.Object

Used for sending messages in "typed" chunks. Useful for long running processes, which are able to produce partial responses.

Author:
Pavel Bucek (pavel.bucek at oracle.com)

Constructor Summary
ChunkedResponse(java.lang.Class<T> clazz)
          Create ChunkedResponse with specified type.
ChunkedResponse(java.lang.Class<T> clazz, java.lang.Long interval, java.util.concurrent.TimeUnit timeUnit)
          Create ChunkedResponse with specified type and polling interval.
 
Method Summary
 void close()
          Close this response - it will be finalized and underlying connections will be closed or made available for another response.
protected  T getChunk()
           
protected  java.lang.Class<T> getChunkType()
           
 void write(T t)
          Write 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.Class<T> clazz)
Create ChunkedResponse with specified type. TODO: make EventChannel use this class as impl base

Parameters:
clazz - chunk type

ChunkedResponse

public ChunkedResponse(java.lang.Class<T> clazz,
                       java.lang.Long interval,
                       java.util.concurrent.TimeUnit timeUnit)
Create ChunkedResponse with specified type and polling interval. Polling interval is used when retrieving data - basically it specifies how often will be connection checked if it is closed from the client side.

Parameters:
interval - polling interval. Default value is 5.
timeUnit - polling interval TimeUnit. Default value is TimeUnit.SECONDS.
clazz - chunk type
Method Detail

write

public void write(T t)
Write chunk.

Parameters:
t - chunk instance to be written.
Throws:
java.lang.IllegalStateException - when ChunkedResponse is closed.

close

public void close()
Close this response - it will be finalized and underlying connections will be closed or made available for another response.


getChunkType

protected java.lang.Class<T> getChunkType()

getChunk

protected T getChunk()
              throws java.lang.InterruptedException
Throws:
java.lang.InterruptedException


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