Class UpgradeServletOutputStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
-
Constructor Summary
ConstructorDescriptionUpgradeServletOutputStream
(UpgradeProcessorBase processor, SocketWrapperBase<?> socketWrapper, UpgradeInfo upgradeInfo) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
flush()
final boolean
isReady()
Returnstrue
if it is allowable to call any method that may write data (e.g.final void
setWriteListener
(WriteListener listener) Sets theWriteListener
for thisServletOutputStream
and thereby switches to non-blocking IO.void
write
(byte[] b, int off, int len) void
write
(int b) Methods inherited from class jakarta.servlet.ServletOutputStream
print, print, print, print, print, print, print, println, println, println, println, println, println, println, println, write
Methods inherited from class java.io.OutputStream
nullOutputStream, write
-
Constructor Details
-
UpgradeServletOutputStream
public UpgradeServletOutputStream(UpgradeProcessorBase processor, SocketWrapperBase<?> socketWrapper, UpgradeInfo upgradeInfo)
-
-
Method Details
-
isReady
public final boolean isReady()Description copied from class:jakarta.servlet.ServletOutputStream
Returnstrue
if it is allowable to call any method that may write data (e.g.write()
,print()
orflush
). In blocking mode, this method will always returntrue
, but a subsequent call to a method that writes data may block. In non-blocking mode this method may returnfalse
, in which case it is illegal to call a method that writes data and anIllegalStateException
MUST be thrown. WhenWriteListener.onWritePossible()
is called, a call to this method that returnedtrue
is implicit.If this method returns
false
and aWriteListener
has been set viaServletOutputStream.setWriteListener(WriteListener)
, then container will subsequently invokeWriteListener.onWritePossible()
once a write operation becomes possible without blocking. Other than the initial call,WriteListener.onWritePossible()
will only be called if and only if this method is called and returns false.- Specified by:
isReady
in classServletOutputStream
- Returns:
true
if data can be written without blocking, otherwise returnsfalse
.
-
setWriteListener
Description copied from class:jakarta.servlet.ServletOutputStream
Sets theWriteListener
for thisServletOutputStream
and thereby switches to non-blocking IO. It is only valid to switch to non-blocking IO within async processing or HTTP upgrade processing.- Specified by:
setWriteListener
in classServletOutputStream
- Parameters:
listener
- The non-blocking IO write listener
-
write
- Specified by:
write
in classOutputStream
- Throws:
IOException
-
write
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
flush
- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classOutputStream
- Throws:
IOException
-
close
Description copied from class:jakarta.servlet.ServletOutputStream
If this method is called when the output stream is in non-blocking mode, it will immediately return with the stream effectively closed, even if the stream contains buffered data that is yet to be written to client. The container will write this data out in the background. If this process fails the
WriteListener.onError(Throwable)
method will be invoked as normal.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classServletOutputStream
- Throws:
IOException
-