io.undertow.io.BufferWritableOutputStream
, java.io.Closeable
, java.io.Flushable
, java.lang.AutoCloseable
public class ServletOutputStreamImpl
extends javax.servlet.ServletOutputStream
implements io.undertow.io.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 | Description |
---|---|
ServletOutputStreamImpl(ServletRequestContext servletRequestContext) |
Construct a new instance.
|
ServletOutputStreamImpl(ServletRequestContext servletRequestContext,
int bufferSize) |
Construct a new instance.
|
Modifier and Type | Method | Description |
---|---|---|
void |
close() |
|
void |
closeAsync() |
Closes the channel, and flushes any data out using async IO
|
void |
flush() |
|
void |
flushInternal() |
|
boolean |
isClosed() |
|
boolean |
isReady() |
|
void |
resetBuffer() |
|
void |
setBufferSize(int size) |
|
void |
setWriteListener(javax.servlet.WriteListener writeListener) |
|
void |
transferFrom(java.nio.channels.FileChannel source) |
|
void |
write(byte[] b) |
|
void |
write(byte[] b,
int off,
int len) |
|
void |
write(int b) |
|
void |
write(java.nio.ByteBuffer byteBuffer) |
|
void |
write(java.nio.ByteBuffer[] buffers) |
public ServletOutputStreamImpl(ServletRequestContext servletRequestContext)
public ServletOutputStreamImpl(ServletRequestContext servletRequestContext, int bufferSize)
public void write(int b) throws java.io.IOException
write
in class java.io.OutputStream
java.io.IOException
public void write(byte[] b) throws java.io.IOException
write
in class java.io.OutputStream
java.io.IOException
public void write(byte[] b, int off, int len) throws java.io.IOException
write
in class java.io.OutputStream
java.io.IOException
public void write(java.nio.ByteBuffer[] buffers) throws java.io.IOException
write
in interface io.undertow.io.BufferWritableOutputStream
java.io.IOException
public void write(java.nio.ByteBuffer byteBuffer) throws java.io.IOException
write
in interface io.undertow.io.BufferWritableOutputStream
java.io.IOException
public void flush() throws java.io.IOException
flush
in interface java.io.Flushable
flush
in class java.io.OutputStream
java.io.IOException
public void flushInternal() throws java.io.IOException
java.io.IOException
public void transferFrom(java.nio.channels.FileChannel source) throws java.io.IOException
transferFrom
in interface io.undertow.io.BufferWritableOutputStream
java.io.IOException
public void close() throws java.io.IOException
close
in interface java.lang.AutoCloseable
close
in interface java.io.Closeable
close
in class java.io.OutputStream
java.io.IOException
public void closeAsync() throws java.io.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
java.io.IOException
public void resetBuffer()
public void setBufferSize(int size)
public boolean isClosed()
public boolean isReady()
isReady
in class javax.servlet.ServletOutputStream
public void setWriteListener(javax.servlet.WriteListener writeListener)
setWriteListener
in class javax.servlet.ServletOutputStream
Copyright © 2018. All rights reserved.