• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ChannelListeners类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.xnio.ChannelListeners的典型用法代码示例。如果您正苦于以下问题:Java ChannelListeners类的具体用法?Java ChannelListeners怎么用?Java ChannelListeners使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ChannelListeners类属于org.xnio包,在下文中一共展示了ChannelListeners类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: sendGoAway

import org.xnio.ChannelListeners; //导入依赖的package包/类
public void sendGoAway(int status, final ChannelExceptionHandler<SpdyStreamSinkChannel> exceptionHandler) {
    if(thisGoneAway) {
        return;
    }
    thisGoneAway = true;
    SpdyGoAwayStreamSinkChannel goAway = new SpdyGoAwayStreamSinkChannel(this, status, lastGoodStreamId);
    try {
        goAway.shutdownWrites();
        if (!goAway.flush()) {
            goAway.getWriteSetter().set(ChannelListeners.flushingChannelListener(null, exceptionHandler));
            goAway.resumeWrites();
        }
    } catch (IOException e) {
        exceptionHandler.handleException(goAway, e);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:SpdyChannel.java


示例2: HttpClientConnection

import org.xnio.ChannelListeners; //导入依赖的package包/类
HttpClientConnection(final StreamConnection connection, final OptionMap options, final Pool<ByteBuffer> bufferPool) {
    this.options = options;
    this.connection = connection;
    this.pushBackStreamSourceConduit = new PushBackStreamSourceConduit(connection.getSourceChannel().getConduit());
    this.connection.getSourceChannel().setConduit(pushBackStreamSourceConduit);
    this.bufferPool = bufferPool;
    this.originalSinkConduit = connection.getSinkChannel().getConduit();

    connection.getCloseSetter().set(new ChannelListener<StreamConnection>() {

        public void handleEvent(StreamConnection channel) {
            HttpClientConnection.this.state |= CLOSED;
            ChannelListeners.invokeChannelListener(HttpClientConnection.this, closeSetter.get());
        }
    });
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:HttpClientConnection.java


示例3: handleEvent

import org.xnio.ChannelListeners; //导入依赖的package包/类
@Override
public void handleEvent(StreamConnection channel) {
    try {
        for (CloseListener l : closeListeners) {
            try {
                l.closed(AbstractServerConnection.this);
            } catch (Throwable e) {
                UndertowLogger.REQUEST_LOGGER.exceptionInvokingCloseListener(l, e);
            }
        }
        if (current != null) {
            current.endExchange();
        }
        ChannelListeners.invokeChannelListener(AbstractServerConnection.this, listener);
    } finally {
        if(extraBytes != null) {
            extraBytes.free();
            extraBytes = null;
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:AbstractServerConnection.java


示例4: handleEvent

import org.xnio.ChannelListeners; //导入依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes"})
@Override
public void handleEvent(final StreamSourceChannel channel) {
    final R receiver = AbstractFramedChannel.this.receiver;
    if ((isLastFrameReceived() || receivesSuspended) && receiver == null) {
        channel.suspendReads();
        return;
    } else {
        final ChannelListener listener = receiveSetter.get();
        if (listener != null) {
            WebSocketLogger.REQUEST_LOGGER.debugf("Invoking receive listener", receiver);
            ChannelListeners.invokeChannelListener(AbstractFramedChannel.this, listener);
        } else {
            channel.suspendReads();
        }
    }
    if (readData != null && channel.isOpen()) {
        ChannelListeners.invokeChannelListener(channel.getIoThread(), channel, this);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:AbstractFramedChannel.java


示例5: close

import org.xnio.ChannelListeners; //导入依赖的package包/类
@Override
public void close() throws IOException {
    if(anyAreSet(state, STATE_CLOSED)) {
        return;
    }
    state |= STATE_CLOSED;
    if (allAreClear(state, STATE_DONE | STATE_LAST_FRAME)) {
        state |= STATE_STREAM_BROKEN;
        getFramedChannel().notifyClosed(this);
        channelForciblyClosed();
    }
    if (data != null) {
        data.free();
        data = null;
    }
    while (!pendingFrameData.isEmpty()) {
        pendingFrameData.poll().frameData.free();
    }
    ChannelListeners.invokeChannelListener(this, (ChannelListener<? super AbstractFramedStreamSourceChannel<C, R, S>>) closeSetter.get());
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:AbstractFramedStreamSourceChannel.java


示例6: run

import org.xnio.ChannelListeners; //导入依赖的package包/类
@Override
public void run() {
    handle = null;
    if (expireTime == -1) {
        return;
    }
    long current = System.currentTimeMillis();
    if (current  < expireTime) {
        //timeout has been bumped, re-schedule
        handle = connection.getIoThread().executeAfter(timeoutCommand, (expireTime - current) + FUZZ_FACTOR, TimeUnit.MILLISECONDS);
        return;
    }
    UndertowLogger.REQUEST_LOGGER.tracef("Timing out channel %s due to inactivity");
    IoUtils.safeClose(connection);
    if (connection.getSourceChannel().isReadResumed()) {
        ChannelListeners.invokeChannelListener(connection.getSourceChannel(), connection.getSourceChannel().getReadListener());
    }
    if (connection.getSinkChannel().isWriteResumed()) {
        ChannelListeners.invokeChannelListener(connection.getSinkChannel(), connection.getSinkChannel().getWriteListener());
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:WriteTimeoutStreamSinkConduit.java


示例7: sendClose

import org.xnio.ChannelListeners; //导入依赖的package包/类
/**
 * Send a Close frame without a payload
 */
public void sendClose() throws IOException {
    closeReason = "";
    closeCode = CloseMessage.NORMAL_CLOSURE;
    StreamSinkFrameChannel closeChannel = send(WebSocketFrameType.CLOSE, 0);
    closeChannel.shutdownWrites();
    if (!closeChannel.flush()) {
        closeChannel.getWriteSetter().set(ChannelListeners.flushingChannelListener(
                null, new ChannelExceptionHandler<StreamSinkChannel>() {
            @Override
            public void handleException(final StreamSinkChannel channel, final IOException exception) {
                IoUtils.safeClose(WebSocketChannel.this);
            }
        }
        ));
        closeChannel.resumeWrites();
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:WebSocketChannel.java


示例8: writeDone

import org.xnio.ChannelListeners; //导入依赖的package包/类
protected void writeDone(final StreamSinkChannel channel) {
    try {
        channel.shutdownWrites();

        if (!channel.flush()) {
            channel.getWriteSetter().set(ChannelListeners.flushingChannelListener(new ChannelListener<StreamSinkChannel>() {
                @Override
                public void handleEvent(StreamSinkChannel o) {
                    IoUtils.safeClose(channel);
                }
            }, ChannelListeners.closingChannelExceptionHandler()));
            channel.resumeWrites();

        }
    } catch (IOException e) {
        handleError(channel, e);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:StringWriteChannelListener.java


示例9: start

import org.xnio.ChannelListeners; //导入依赖的package包/类
public void start() {
    try {

        OptionMap.Builder serverOptionsBuilder = OptionMap.builder()
                .set(Options.TCP_NODELAY, true)
                .set(Options.REUSE_ADDRESSES, true);
        ChannelListener acceptListener = ChannelListeners.openListenerAdapter(openListener);
        if (httpAddress != null) {
            normalServer = worker.createStreamConnectionServer(httpAddress, acceptListener, serverOptionsBuilder.getMap());
            normalServer.resumeAccepts();
        }
        if (secureAddress != null) {
            if (sslClientAuthMode != null) {
                serverOptionsBuilder.set(SSL_CLIENT_AUTH_MODE, sslClientAuthMode);
            }
            OptionMap secureOptions = serverOptionsBuilder.getMap();
            XnioSsl xnioSsl = new UndertowXnioSsl(worker.getXnio(), secureOptions, sslContext);
            secureServer = xnioSsl.createSslConnectionServer(worker, secureAddress, acceptListener, secureOptions);
            secureServer.resumeAccepts();
        }
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:25,代码来源:ManagementHttpServer.java


示例10: createServer

import org.xnio.ChannelListeners; //导入依赖的package包/类
private AcceptingChannel<? extends StreamConnection> createServer(int sourcePort, int targetPort)
    throws IllegalArgumentException, IOException {
    OptionMap socketOptions = OptionMap.builder()
        .set(Options.WORKER_IO_THREADS, 16)
        .set(Options.TCP_NODELAY, true)
        .set(Options.REUSE_ADDRESSES, true)
        .getMap();

    ChannelListener<AcceptingChannel<StreamConnection>> acceptListener = ChannelListeners.openListenerAdapter(
        new PortForwardOpenListener(connection, portForwardURI.getPath(), targetPort, requestId, bufferPoolSlice,
            OptionMap.EMPTY));
    AcceptingChannel<? extends StreamConnection> server =
        xnioWorker.createStreamConnectionServer(new InetSocketAddress(portForwardBindAddress, sourcePort),
            acceptListener, socketOptions);
    server.resumeAccepts();
    return server;
}
 
开发者ID:arquillian,项目名称:arquillian-cube,代码行数:18,代码来源:PortForwarder.java


示例11: complete

import org.xnio.ChannelListeners; //导入依赖的package包/类
@Override
protected void complete() throws IOException {
    super.complete();
    if(completionListener != null) {
        ChannelListeners.invokeChannelListener(this, completionListener);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:SpdyStreamStreamSourceChannel.java


示例12: handleFlushComplete

import org.xnio.ChannelListeners; //导入依赖的package包/类
@Override
protected void handleFlushComplete(boolean finalFrame) {
    super.handleFlushComplete(finalFrame);
    if (finalFrame) {
        if (completionListener != null) {
            ChannelListeners.invokeChannelListener(this, completionListener);
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:SpdySynReplyStreamSinkChannel.java


示例13: sendPing

import org.xnio.ChannelListeners; //导入依赖的package包/类
public void sendPing(int id, final ChannelExceptionHandler<SpdyStreamSinkChannel> exceptionHandler) {
    SpdyPingStreamSinkChannel ping = new SpdyPingStreamSinkChannel(this, id);
    try {
        ping.shutdownWrites();
        if (!ping.flush()) {
            ping.getWriteSetter().set(ChannelListeners.flushingChannelListener(null, exceptionHandler));
            ping.resumeWrites();
        }
    } catch (IOException e) {
        exceptionHandler.handleException(ping, e);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:SpdyChannel.java


示例14: sendUpdateWindowSize

import org.xnio.ChannelListeners; //导入依赖的package包/类
public void sendUpdateWindowSize(int streamId, int delta) {
    SpdyWindowUpdateStreamSinkChannel windowUpdateStreamSinkChannel = new SpdyWindowUpdateStreamSinkChannel(this, streamId, delta);
    try {
        windowUpdateStreamSinkChannel.shutdownWrites();
        if (!windowUpdateStreamSinkChannel.flush()) {
            windowUpdateStreamSinkChannel.getWriteSetter().set(ChannelListeners.flushingChannelListener(null, new SpdyControlMessageExceptionHandler()));
            windowUpdateStreamSinkChannel.resumeWrites();
        }
    } catch (IOException e) {
        handleBrokenSinkChannel(e);
    }

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:SpdyChannel.java


示例15: AjpClientConnection

import org.xnio.ChannelListeners; //导入依赖的package包/类
AjpClientConnection(final AjpClientChannel connection, final OptionMap options, final Pool<ByteBuffer> bufferPool) {
    this.options = options;
    this.connection = connection;
    this.bufferPool = bufferPool;

    connection.addCloseTask(new ChannelListener<AjpClientChannel>() {
        @Override
        public void handleEvent(AjpClientChannel channel) {
            ChannelListeners.invokeChannelListener(AjpClientConnection.this, closeSetter.get());
        }
    });
    connection.getReceiveSetter().set(new ClientReceiveListener());
    connection.resumeReceives();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:AjpClientConnection.java


示例16: handleFailedFlush

import org.xnio.ChannelListeners; //导入依赖的package包/类
private void handleFailedFlush(AjpClientRequestClientStreamSinkChannel sinkChannel) {
    sinkChannel.getWriteSetter().set(ChannelListeners.flushingChannelListener(null, new ChannelExceptionHandler<StreamSinkChannel>() {
        @Override
        public void handleException(StreamSinkChannel channel, IOException exception) {
            handleError(exception);
        }
    }));
    sinkChannel.resumeWrites();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:AjpClientConnection.java


示例17: SpdyClientConnection

import org.xnio.ChannelListeners; //导入依赖的package包/类
public SpdyClientConnection(SpdyChannel spdyChannel) {
    this.spdyChannel = spdyChannel;
    spdyChannel.getReceiveSetter().set(new SpdyReceiveListener());
    spdyChannel.resumeReceives();
    spdyChannel.addCloseTask(new ChannelListener<SpdyChannel>() {
        @Override
        public void handleEvent(SpdyChannel channel) {
            ChannelListeners.invokeChannelListener(SpdyClientConnection.this, closeSetter.get());
        }
    });
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:SpdyClientConnection.java


示例18: close

import org.xnio.ChannelListeners; //导入依赖的package包/类
@Override
public void close() throws IOException {
    if(fullyFlushed || anyAreSet(state, STATE_CLOSED)) {
        return;
    }
    try {
        state |= STATE_CLOSED;
        buffer.free();
        buffer = null;
        if (header != null && header.getByteBuffer() != null) {
            header.getByteBuffer().free();
        }
        if (trailer != null) {
            trailer.free();
        }
        if (anyAreSet(state, STATE_FIRST_DATA_WRITTEN)) {
            channelForciblyClosed();
        }
        //we need to wake up/invoke the write listener
        if (isWriteResumed()) {
            ChannelListeners.invokeChannelListener(getIoThread(), this, (ChannelListener) getWriteListener());
        }
        wakeupWrites();
    } finally {
        wakeupWaiters();
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:28,代码来源:AbstractFramedStreamSinkChannel.java


示例19: markBroken

import org.xnio.ChannelListeners; //导入依赖的package包/类
public void markBroken() {
    this.broken = true;
    try {
        wakeupWrites();
        wakeupWaiters();
        if (isWriteResumed()) {
            ChannelListener<? super S> writeListener = this.writeSetter.get();
            if (writeListener != null) {
                ChannelListeners.invokeChannelListener(getIoThread(), (S) this, writeListener);
            }
        }
        ChannelListener<? super S> closeListener = this.closeSetter.get();
        if (closeListener != null) {
            ChannelListeners.invokeChannelListener(getIoThread(), (S) this, closeListener);
        }
    } finally {
        if(header != null && header.getByteBuffer() != null) {
            header.getByteBuffer().free();
        }
        if(trailer != null) {
            trailer.free();
        }
        if(buffer != null) {
            buffer.free();
            buffer = null;
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:29,代码来源:AbstractFramedStreamSinkChannel.java


示例20: resumeReadsInternal

import org.xnio.ChannelListeners; //导入依赖的package包/类
/**
 * For this class there is no difference between a resume and a wakeup
 */
void resumeReadsInternal(boolean wakeup) {
    boolean alreadyResumed = anyAreSet(state, STATE_READS_RESUMED);
    state |= STATE_READS_RESUMED;
    if(!alreadyResumed || wakeup) {
        if (!anyAreSet(state, STATE_IN_LISTENER_LOOP)) {
            state |= STATE_IN_LISTENER_LOOP;
            getIoThread().execute(new Runnable() {

                @Override
                public void run() {
                    try {
                        boolean moreData;
                        do {
                            ChannelListener<? super R> listener = getReadListener();
                            if (listener == null || !isReadResumed()) {
                                return;
                            }
                            ChannelListeners.invokeChannelListener((R) AbstractFramedStreamSourceChannel.this, listener);
                            //if writes are shutdown or we become active then we stop looping
                            //we stop when writes are shutdown because we can't flush until we are active
                            //although we may be flushed as part of a batch
                            moreData = (frameDataRemaining > 0 &&  data != null) || !pendingFrameData.isEmpty();
                        } while (allAreSet(state, STATE_READS_RESUMED) && allAreClear(state, STATE_CLOSED) && moreData);
                    } finally {
                        state &= ~STATE_IN_LISTENER_LOOP;
                    }
                }
            });
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:35,代码来源:AbstractFramedStreamSourceChannel.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PointD类代码示例发布时间:2022-05-22
下一篇:
Java RegionSelector类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap