Package org.glassfish.jersey.server
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
Used for sending messages in "typed" chunks. Useful for long running processes,
which needs to produce partial responses.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate AsyncContext
private final byte[]
private boolean
private javax.ws.rs.container.ConnectionCallback
private boolean
private final BlockingDeque<T>
private ContainerRequest
private RequestScope
private RequestContext
private ContainerResponse
private final AtomicBoolean
private static final byte[]
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Create newChunkedOutput
.protected
ChunkedOutput
(byte[] chunkDelimiter) Create newChunkedOutput
with a custom chunk delimiter.protected
ChunkedOutput
(byte[] chunkDelimiter, javax.inject.Provider<AsyncContext> asyncContextProvider) Create newChunkedOutput
with a custom chunk delimiter.ChunkedOutput
(Type chunkType) CreateChunkedOutput
with specified type.ChunkedOutput
(Type chunkType, byte[] chunkDelimiter) Create newChunkedOutput
with a custom chunk delimiter.ChunkedOutput
(Type chunkType, String chunkDelimiter) Create newChunkedOutput
with a custom chunk delimiter.protected
ChunkedOutput
(String chunkDelimiter) Create newChunkedOutput
with a custom chunk delimiter. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close this response - it will be finalized and underlying connections will be closed or made available for another response.boolean
protected void
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.toString()
void
Write a chunk.Methods inherited from class javax.ws.rs.core.GenericType
forInstance, getRawType, getType
-
Field Details
-
ZERO_LENGTH_DELIMITER
private static final byte[] ZERO_LENGTH_DELIMITER -
queue
-
chunkDelimiter
private final byte[] chunkDelimiter -
resumed
-
flushing
private boolean flushing -
closed
private volatile boolean closed -
asyncContext
-
requestScope
-
requestScopeContext
-
requestContext
-
responseContext
-
connectionCallback
private volatile javax.ws.rs.container.ConnectionCallback connectionCallback
-
-
Constructor Details
-
ChunkedOutput
protected ChunkedOutput()Create newChunkedOutput
. -
ChunkedOutput
CreateChunkedOutput
with specified type.- Parameters:
chunkType
- chunk type. Must not be {code null}.
-
ChunkedOutput
protected ChunkedOutput(byte[] chunkDelimiter) Create newChunkedOutput
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 newChunkedOutput
with a custom chunk delimiter.- Parameters:
chunkDelimiter
- custom chunk delimiter bytes. Must not be {code null}.- Since:
- 2.4.1
-
ChunkedOutput
Create newChunkedOutput
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
Create newChunkedOutput
with a custom chunk delimiter.- Parameters:
chunkDelimiter
- custom chunk delimiter string. Must not be {code null}.- Since:
- 2.4.1
-
ChunkedOutput
Create newChunkedOutput
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
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
- Throws:
IOException
-
close
Close this response - it will be finalized and underlying connections will be closed or made available for another response.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
isClosed
public boolean isClosed()Get state information. Please note thatChunkedOutput
can be closed by the client side - client can close connection from its side.- Returns:
- true when closed, false otherwise.
-
equals
- Overrides:
equals
in classjavax.ws.rs.core.GenericType<T>
-
hashCode
public int hashCode()- Overrides:
hashCode
in classjavax.ws.rs.core.GenericType<T>
-
toString
- Overrides:
toString
in classjavax.ws.rs.core.GenericType<T>
-
setContext
void setContext(RequestScope requestScope, RequestContext requestScopeContext, ContainerRequest requestContext, ContainerResponse responseContext, javax.ws.rs.container.ConnectionCallback connectionCallbackRunner) throws IOException Set context used for writing chunks.- Parameters:
requestScope
- request scope.requestScopeContext
- current request context instance.requestContext
- request context.responseContext
- response context.connectionCallbackRunner
- connection callback.- Throws:
IOException
- when encountered any problem during serializing or writing a chunk.
-