Class ServletOutputStreamImpl
- All Implemented Interfaces:
io.undertow.io.BufferWritableOutputStream,Closeable,Flushable,AutoCloseable
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 listener can be active at
one time, which simplifies the thread safety requirements.
- Author:
- Stuart Douglas
-
Constructor Summary
ConstructorsConstructorDescriptionServletOutputStreamImpl(ServletRequestContext servletRequestContext) Construct a new instance.ServletOutputStreamImpl(ServletRequestContext servletRequestContext, int bufferSize) Construct a new instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidCloses the channel, and flushes any data out using async IOvoidflush()voidbooleanisClosed()booleanisReady()voidvoidsetBufferSize(int size) voidsetWriteListener(javax.servlet.WriteListener writeListener) voidtransferFrom(FileChannel source) voidwrite(byte[] b) voidwrite(byte[] b, int off, int len) voidwrite(int b) voidwrite(ByteBuffer byteBuffer) voidwrite(ByteBuffer[] buffers) Methods inherited from class javax.servlet.ServletOutputStream
print, print, print, print, print, print, print, println, println, println, println, println, println, println, printlnMethods inherited from class java.io.OutputStream
nullOutputStream
-
Constructor Details
-
ServletOutputStreamImpl
Construct a new instance. No write timeout is configured. -
ServletOutputStreamImpl
Construct a new instance. No write timeout is configured.
-
-
Method Details
-
write
- Specified by:
writein classOutputStream- Throws:
IOException
-
write
- Overrides:
writein classOutputStream- Throws:
IOException
-
write
- Overrides:
writein classOutputStream- Throws:
IOException
-
write
- Specified by:
writein interfaceio.undertow.io.BufferWritableOutputStream- Throws:
IOException
-
write
- Specified by:
writein interfaceio.undertow.io.BufferWritableOutputStream- Throws:
IOException
-
flush
- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException
-
flushInternal
- Throws:
IOException
-
transferFrom
- Specified by:
transferFromin interfaceio.undertow.io.BufferWritableOutputStream- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException
-
closeAsync
Closes the channel, and flushes any data out using async IOThis 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
- Throws:
IOException
-
resetBuffer
public void resetBuffer() -
setBufferSize
public void setBufferSize(int size) -
isClosed
public boolean isClosed() -
isReady
public boolean isReady()- Specified by:
isReadyin classjavax.servlet.ServletOutputStream
-
setWriteListener
public void setWriteListener(javax.servlet.WriteListener writeListener) - Specified by:
setWriteListenerin classjavax.servlet.ServletOutputStream
-