public class ServletOutputStreamImpl extends ServletOutputStream implements BufferWritableOutputStream
If a content-length header was present when the stream was created then it will automatically close and flush itself once the appropriate amount of data has been written.
Once the listener has been set it goes into async mode, and writes become non blocking. Most methods have two different code paths, based on if the listener has been set or not
Once the write listener has been set operations must only be invoked on this stream from the write listener callback. Attempting to invoke from a different thread will result in an IllegalStateException.
Async listener tasks are queued in the AsyncContextImpl. At most one lister can be active at
one time, which simplifies the thread safety requirements.
| Constructor and Description |
|---|
ServletOutputStreamImpl(ServletRequestContext servletRequestContext)
Construct a new instance.
|
ServletOutputStreamImpl(ServletRequestContext servletRequestContext,
int bufferSize)
Construct a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
closeAsync()
Closes the channel, and flushes any data out using async IO
|
void |
flush() |
void |
flushInternal() |
boolean |
isClosed() |
boolean |
isReady()
This method can be used to determine if data can be written without blocking.
|
void |
resetBuffer() |
void |
setBufferSize(int size) |
void |
setWriteListener(WriteListener writeListener)
Instructs the
ServletOutputStream to invoke the provided
WriteListener when it is possible to write |
void |
transferFrom(FileChannel source) |
void |
write(byte[] b) |
void |
write(byte[] b,
int off,
int len) |
void |
write(ByteBuffer byteBuffer) |
void |
write(ByteBuffer[] buffers) |
void |
write(int b) |
public ServletOutputStreamImpl(ServletRequestContext servletRequestContext)
public ServletOutputStreamImpl(ServletRequestContext servletRequestContext, int bufferSize)
public void write(int b)
throws IOException
write in class OutputStreamIOExceptionpublic void write(byte[] b)
throws IOException
write in class OutputStreamIOExceptionpublic void write(byte[] b,
int off,
int len)
throws IOException
write in class OutputStreamIOExceptionpublic void write(ByteBuffer[] buffers) throws IOException
write in interface BufferWritableOutputStreamIOExceptionpublic void write(ByteBuffer byteBuffer) throws IOException
write in interface BufferWritableOutputStreamIOExceptionpublic void flush()
throws IOException
flush in interface Flushableflush in class OutputStreamIOExceptionpublic void flushInternal()
throws IOException
IOExceptionpublic void transferFrom(FileChannel source) throws IOException
transferFrom in interface BufferWritableOutputStreamIOExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class OutputStreamIOExceptionpublic void closeAsync()
throws IOException
This is used in two situations, if an output stream is not closed when a request is done, and when performing a close on a stream that is in async mode
IOExceptionpublic void resetBuffer()
public void setBufferSize(int size)
public boolean isClosed()
public boolean isReady()
ServletOutputStreamisReady in class ServletOutputStreamtrue if a write to this ServletOutputStream
will succeed, otherwise returns false.public void setWriteListener(WriteListener writeListener)
ServletOutputStreamServletOutputStream to invoke the provided
WriteListener when it is possible to writesetWriteListener in class ServletOutputStreamwriteListener - the WriteListener that should be notified
when it's possible to writeCopyright © 2018 JBoss by Red Hat. All rights reserved.