Top Description Fields Constructors Methods
io.undertow.servlet.core

public Class BlockingWriterSenderImpl

extends Object
implements Sender
Class Inheritance
All Implemented Interfaces
io.undertow.io.Sender
Imports
java.io.EOFException, .IOException, .PrintWriter, java.nio.ByteBuffer, java.nio.channels.FileChannel, java.nio.charset.CharacterCodingException, .Charset, .CharsetDecoder, jakarta.servlet.DispatcherType, io.undertow.UndertowMessages, io.undertow.io.IoCallback, .Sender, io.undertow.server.HttpServerExchange, io.undertow.servlet.handlers.ServletRequestContext, org.xnio.IoUtils

A sender that uses a print writer. In general this should never be used. It exists for the edge case where a filter has called getWriter() and then the default servlet is being used to serve a text file.
Author
Stuart Douglas

Field Summary

Modifier and TypeField and Description
public static final int
BUFFER_SIZE

Todo

we should be used pooled buffers

private final CharsetDecoder
private final HttpServerExchange
private volatile Thread
private String
private FileChannel
private IoCallback
private volatile Thread
private final PrintWriter

Constructor Summary

AccessConstructor and Description
public
BlockingWriterSenderImpl(final HttpServerExchange exchange, final PrintWriter writer, final String charset)

Method Summary

Modifier and TypeMethod and Description
public void
close(final IoCallback
The callback that is notified when all data has been flushed and the channel is closed
callback
)

Implements io.undertow.io.Sender.close.

Closes this sender asynchronously.

public void
close()

Implements io.undertow.io.Sender.close.

Closes this sender asynchronously

private void
invokeOnComplete(final IoCallback callback)

private void
private void
queue(final ByteBuffer[] byteBuffers, final IoCallback ioCallback)

private void
queue(final String data, final IoCallback callback)

private void
queue(final FileChannel data, final IoCallback callback)

public void
send(final ByteBuffer
The buffer to send.
buffer
,
final IoCallback
The callback
callback
)

Implements io.undertow.io.Sender.send.

Write the given buffer using async IO, and calls the given callback on completion or error.

public void
send(final ByteBuffer[]
The buffers to send.
buffer
,
final IoCallback
The callback
callback
)

Implements io.undertow.io.Sender.send.

Write the given buffers using async IO, and calls the given callback on completion or error.

public void
send(final String
The data to send
data
,
final IoCallback
The callback
callback
)

Implements io.undertow.io.Sender.send.

Write the given String using async IO, and calls the given callback on completion or error.

public void
send(final ByteBuffer
The buffer to send.
buffer
)

Implements io.undertow.io.Sender.send.

Write the given buffer using async IO, and ends the exchange when done

public void
send(final ByteBuffer[]
The buffers to send.
buffer
)

Implements io.undertow.io.Sender.send.

Write the given buffers using async IO, and ends the exchange when done

public void
send(final String
The buffer to end.
data
,
final Charset
The charset to use
charset
,
final IoCallback
The callback
callback
)

Implements io.undertow.io.Sender.send.

Write the given String using async IO, and calls the given callback on completion or error.

public void
send(final String
The data to send
data
)

Implements io.undertow.io.Sender.send.

Write the given String using async IO, and ends the exchange when done

The CharSequence is encoded to UTF8

public void
send(final String
The buffer to end.
data
,
final Charset
The charset to use
charset
)

Implements io.undertow.io.Sender.send.

Write the given String using async IO, and ends the exchange when done

public void
transferFrom(FileChannel
the file channel to transfer
source
,
IoCallback
The callback
callback
)

Implements io.undertow.io.Sender.transferFrom.

Transfers all content from the specified file

private boolean
writeBuffer(final ByteBuffer buffer, final IoCallback callback)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BUFFER_SIZEback to summary
public static final int BUFFER_SIZE

Todo

we should be used pooled buffers

charsetDecoderback to summary
private final CharsetDecoder charsetDecoder
exchangeback to summary
private final HttpServerExchange exchange
inCallback to summary
private volatile Thread inCall
nextback to summary
private String next
pendingFileback to summary
private FileChannel pendingFile
queuedCallbackback to summary
private IoCallback queuedCallback
sendThreadback to summary
private volatile Thread sendThread
writerback to summary
private final PrintWriter writer

Constructor Detail

BlockingWriterSenderImplback to summary
public BlockingWriterSenderImpl(final HttpServerExchange exchange, final PrintWriter writer, final String charset)

Method Detail

closeback to summary
public void close(final IoCallback callback)

Implements io.undertow.io.Sender.close.

Doc from io.undertow.io.Sender.close.

Closes this sender asynchronously. The given callback is notified on completion

Parameters
callback:IoCallback

The callback that is notified when all data has been flushed and the channel is closed

Annotations
@Override
closeback to summary
public void close()

Implements io.undertow.io.Sender.close.

Doc from io.undertow.io.Sender.close.

Closes this sender asynchronously

Annotations
@Override
invokeOnCompleteback to summary
private void invokeOnComplete(final IoCallback callback)
performTransferback to summary
private void performTransfer(FileChannel source, IoCallback callback)
queueback to summary
private void queue(final ByteBuffer[] byteBuffers, final IoCallback ioCallback)
queueback to summary
private void queue(final String data, final IoCallback callback)
queueback to summary
private void queue(final FileChannel data, final IoCallback callback)
sendback to summary
public void send(final ByteBuffer buffer, final IoCallback callback)

Implements io.undertow.io.Sender.send.

Doc from io.undertow.io.Sender.send.

Write the given buffer using async IO, and calls the given callback on completion or error.

Parameters
buffer:ByteBuffer

The buffer to send.

callback:IoCallback

The callback

Annotations
@Override
sendback to summary
public void send(final ByteBuffer[] buffer, final IoCallback callback)

Implements io.undertow.io.Sender.send.

Doc from io.undertow.io.Sender.send.

Write the given buffers using async IO, and calls the given callback on completion or error.

Parameters
buffer:ByteBuffer[]

The buffers to send.

callback:IoCallback

The callback

Annotations
@Override
sendback to summary
public void send(final String data, final IoCallback callback)

Implements io.undertow.io.Sender.send.

Doc from io.undertow.io.Sender.send.

Write the given String using async IO, and calls the given callback on completion or error.

The CharSequence is encoded to UTF8

Parameters
data:String

The data to send

callback:IoCallback

The callback

Annotations
@Override
sendback to summary
public void send(final ByteBuffer buffer)

Implements io.undertow.io.Sender.send.

Doc from io.undertow.io.Sender.send.

Write the given buffer using async IO, and ends the exchange when done

Parameters
buffer:ByteBuffer

The buffer to send.

Annotations
@Override
sendback to summary
public void send(final ByteBuffer[] buffer)

Implements io.undertow.io.Sender.send.

Doc from io.undertow.io.Sender.send.

Write the given buffers using async IO, and ends the exchange when done

Parameters
buffer:ByteBuffer[]

The buffers to send.

Annotations
@Override
sendback to summary
public void send(final String data, final Charset charset, final IoCallback callback)

Implements io.undertow.io.Sender.send.

Doc from io.undertow.io.Sender.send.

Write the given String using async IO, and calls the given callback on completion or error.

Parameters
data:String

The buffer to end.

charset:Charset

The charset to use

callback:IoCallback

The callback

Annotations
@Override
sendback to summary
public void send(final String data)

Implements io.undertow.io.Sender.send.

Doc from io.undertow.io.Sender.send.

Write the given String using async IO, and ends the exchange when done

The CharSequence is encoded to UTF8

Parameters
data:String

The data to send

Annotations
@Override
sendback to summary
public void send(final String data, final Charset charset)

Implements io.undertow.io.Sender.send.

Doc from io.undertow.io.Sender.send.

Write the given String using async IO, and ends the exchange when done

Parameters
data:String

The buffer to end.

charset:Charset

The charset to use

Annotations
@Override
transferFromback to summary
public void transferFrom(FileChannel source, IoCallback callback)

Implements io.undertow.io.Sender.transferFrom.

Doc from io.undertow.io.Sender.transferFrom.

Transfers all content from the specified file

Parameters
source:FileChannel

the file channel to transfer

callback:IoCallback

The callback

Annotations
@Override
writeBufferback to summary
private boolean writeBuffer(final ByteBuffer buffer, final IoCallback callback)