本文整理汇总了Java中io.undertow.io.IoCallback.onException方法的典型用法代码示例。如果您正苦于以下问题:Java IoCallback.onException方法的具体用法?Java IoCallback.onException怎么用?Java IoCallback.onException使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.undertow.io.IoCallback
的用法示例。
在下文中一共展示了IoCallback.onException方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeBuffer
import io.undertow.io.IoCallback; //导入方法依赖的package包/类
private boolean writeBuffer(final ByteBuffer buffer, final IoCallback callback) {
StringBuilder builder = new StringBuilder();
try {
builder.append(charsetDecoder.decode(buffer));
} catch (CharacterCodingException e) {
callback.onException(exchange, this, e);
return false;
}
String data = builder.toString();
writer.write(data);
if (writer.checkError()) {
callback.onException(exchange, this, new IOException());
return false;
}
return true;
}
示例2: queue
import io.undertow.io.IoCallback; //导入方法依赖的package包/类
private void queue(final ByteBuffer[] byteBuffers, final IoCallback ioCallback) {
//if data is sent from withing the callback we queue it, to prevent the stack growing indefinitely
if (next != null || pendingFile != null) {
throw UndertowMessages.MESSAGES.dataAlreadyQueued();
}
StringBuilder builder = new StringBuilder();
for (ByteBuffer buffer : byteBuffers) {
try {
builder.append(charsetDecoder.decode(buffer));
} catch (CharacterCodingException e) {
ioCallback.onException(exchange, this, e);
return;
}
}
this.next = builder.toString();
queuedCallback = ioCallback;
}
示例3: send
import io.undertow.io.IoCallback; //导入方法依赖的package包/类
@Override
public void send(final String data, final IoCallback callback) {
if (inCall) {
queue(data, callback);
return;
}
writer.write(data);
if (writer.checkError()) {
callback.onException(exchange, this, new IOException());
} else {
invokeOnComplete(callback);
}
}
示例4: performTransfer
import io.undertow.io.IoCallback; //导入方法依赖的package包/类
private void performTransfer(FileChannel source, IoCallback callback) {
ByteBuffer buffer = ByteBuffer.allocate(BUFFER_SIZE);
try {
long pos = source.position();
long size = source.size();
while (size - pos > 0) {
int ret = source.read(buffer);
if (ret <= 0) {
break;
}
pos += ret;
buffer.flip();
if (!writeBuffer(buffer, callback)) {
return;
}
buffer.clear();
}
if (pos != size) {
throw new EOFException("Unexpected EOF reading file");
}
} catch (IOException e) {
callback.onException(exchange, this, e);
}
invokeOnComplete(callback);
}
示例5: sendContinueResponse
import io.undertow.io.IoCallback; //导入方法依赖的package包/类
/**
* Sends a continuation using async IO, and calls back when it is complete.
*
* @param exchange The exchange
* @param callback The completion callback
*/
public static void sendContinueResponse(final HttpServerExchange exchange, final IoCallback callback) {
if (!exchange.isResponseChannelAvailable()) {
callback.onException(exchange, null, UndertowMessages.MESSAGES.cannotSendContinueResponse());
return;
}
internalSendContinueResponse(exchange, callback);
}