T
- chunk type.public class ChunkedOutput<T>
extends javax.ws.rs.core.GenericType<T>
implements java.io.Closeable
Modifier and Type | Field and Description |
---|---|
private AsyncContext |
asyncContext |
private byte[] |
chunkDelimiter |
private boolean |
closed |
private javax.ws.rs.container.ConnectionCallback |
connectionCallback |
private boolean |
flushing |
private java.util.concurrent.BlockingDeque<T> |
queue |
private ContainerRequest |
requestContext |
private RequestScope |
requestScope |
private RequestContext |
requestScopeContext |
private ContainerResponse |
responseContext |
private java.util.concurrent.atomic.AtomicBoolean |
resumed |
private static byte[] |
ZERO_LENGTH_DELIMITER |
Modifier | Constructor and Description |
---|---|
protected |
ChunkedOutput()
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. |
protected |
ChunkedOutput(java.lang.String chunkDelimiter)
Create new
ChunkedOutput with a custom chunk delimiter. |
|
ChunkedOutput(java.lang.reflect.Type chunkType)
Create
ChunkedOutput with specified type. |
|
ChunkedOutput(java.lang.reflect.Type chunkType,
byte[] chunkDelimiter)
Create new
ChunkedOutput with a custom chunk delimiter. |
|
ChunkedOutput(java.lang.reflect.Type chunkType,
java.lang.String chunkDelimiter)
Create new
ChunkedOutput with a custom chunk delimiter. |
Modifier and Type | Method and Description |
---|---|
void |
close()
Close this response - it will be finalized and underlying connections will be closed
or made available for another response.
|
boolean |
equals(java.lang.Object obj) |
protected void |
flushQueue() |
int |
hashCode() |
boolean |
isClosed()
Get state information.
|
(package private) void |
setContext(RequestScope requestScope,
RequestContext requestScopeContext,
ContainerRequest requestContext,
ContainerResponse responseContext,
javax.ws.rs.container.ConnectionCallback connectionCallbackRunner)
Set context used for writing chunks.
|
java.lang.String |
toString() |
void |
write(T chunk)
Write a chunk.
|
private static final byte[] ZERO_LENGTH_DELIMITER
private final java.util.concurrent.BlockingDeque<T> queue
private final byte[] chunkDelimiter
private final java.util.concurrent.atomic.AtomicBoolean resumed
private boolean flushing
private volatile boolean closed
private volatile AsyncContext asyncContext
private volatile RequestScope requestScope
private volatile RequestContext requestScopeContext
private volatile ContainerRequest requestContext
private volatile ContainerResponse responseContext
private volatile javax.ws.rs.container.ConnectionCallback connectionCallback
protected ChunkedOutput()
ChunkedOutput
.public ChunkedOutput(java.lang.reflect.Type chunkType)
ChunkedOutput
with specified type.chunkType
- chunk type. Must not be {code null}.protected ChunkedOutput(byte[] chunkDelimiter)
ChunkedOutput
with a custom chunk delimiter.chunkDelimiter
- custom chunk delimiter bytes. Must not be {code null}.protected ChunkedOutput(byte[] chunkDelimiter, javax.inject.Provider<AsyncContext> asyncContextProvider)
ChunkedOutput
with a custom chunk delimiter.chunkDelimiter
- custom chunk delimiter bytes. Must not be {code null}.public ChunkedOutput(java.lang.reflect.Type chunkType, byte[] chunkDelimiter)
ChunkedOutput
with a custom chunk delimiter.chunkType
- chunk type. Must not be {code null}.chunkDelimiter
- custom chunk delimiter bytes. Must not be {code null}.protected ChunkedOutput(java.lang.String chunkDelimiter)
ChunkedOutput
with a custom chunk delimiter.chunkDelimiter
- custom chunk delimiter string. Must not be {code null}.public ChunkedOutput(java.lang.reflect.Type chunkType, java.lang.String chunkDelimiter)
ChunkedOutput
with a custom chunk delimiter.chunkType
- chunk type. Must not be {code null}.chunkDelimiter
- custom chunk delimiter string. Must not be {code null}.public void write(T chunk) throws java.io.IOException
chunk
- a chunk instance to be written.java.io.IOException
- if this response is closed or when encountered any problem during serializing or writing a chunk.protected void flushQueue() throws java.io.IOException
java.io.IOException
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
java.io.IOException
public boolean isClosed()
ChunkedOutput
can be closed by the client side - client can close connection
from its side.public boolean equals(java.lang.Object obj)
equals
in class javax.ws.rs.core.GenericType<T>
public int hashCode()
hashCode
in class javax.ws.rs.core.GenericType<T>
public java.lang.String toString()
toString
in class javax.ws.rs.core.GenericType<T>
void setContext(RequestScope requestScope, RequestContext requestScopeContext, ContainerRequest requestContext, ContainerResponse responseContext, javax.ws.rs.container.ConnectionCallback connectionCallbackRunner) throws java.io.IOException
requestScope
- request scope.requestScopeContext
- current request context instance.requestContext
- request context.responseContext
- response context.connectionCallbackRunner
- connection callback.java.io.IOException
- when encountered any problem during serializing or writing a chunk.