当前位置: 首页>>代码示例>>Java>>正文


Java IoCallback.onException方法代码示例

本文整理汇总了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;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:BlockingWriterSenderImpl.java

示例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;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:BlockingWriterSenderImpl.java

示例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);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:BlockingWriterSenderImpl.java

示例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);
    }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:29,代码来源:BlockingWriterSenderImpl.java

示例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);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:HttpContinue.java


注:本文中的io.undertow.io.IoCallback.onException方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。