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


Java Connection.isOpen方法代码示例

本文整理汇总了Java中org.glassfish.grizzly.Connection.isOpen方法的典型用法代码示例。如果您正苦于以下问题:Java Connection.isOpen方法的具体用法?Java Connection.isOpen怎么用?Java Connection.isOpen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.glassfish.grizzly.Connection的用法示例。


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

示例1: getOrAddChannel

import org.glassfish.grizzly.Connection; //导入方法依赖的package包/类
static GrizzlyChannel getOrAddChannel(Connection<?> connection, URL url, ChannelHandler handler) {
    if (connection == null) {
        return null;
    }
    GrizzlyChannel ret = ATTRIBUTE.get(connection);
    if (ret == null) {
        ret = new GrizzlyChannel(connection, url, handler);
        if (connection.isOpen()) {
            ATTRIBUTE.set(connection, ret);
        }
    }
    return ret;
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:14,代码来源:GrizzlyChannel.java

示例2: getChannel

import org.glassfish.grizzly.Connection; //导入方法依赖的package包/类
@Override
protected Channel getChannel() {
    Connection<?> c = connection;
    if (c == null || ! c.isOpen())
        return null;
    return GrizzlyChannel.getOrAddChannel(c, getUrl(), this);
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:8,代码来源:GrizzlyClient.java

示例3: handleClose

import org.glassfish.grizzly.Connection; //导入方法依赖的package包/类
/**
 * This method will be called, to notify about {@link Connection} closing.
 */
@Override
public NextAction handleClose(FilterChainContext ctx) throws IOException {
    final Connection connection = ctx.getConnection();
    final Connection peerConnection = peerConnectionAttribute
            .get(connection);

    // Close peer connection as well, if it wasn't closed before
    if (peerConnection != null && peerConnection.isOpen()) {
        peerConnection.closeSilently();
    }

    return ctx.getInvokeAction();
}
 
开发者ID:chocotan,项目名称:kazeproxy,代码行数:17,代码来源:TunnelRedirectServerFilter.java

示例4: getChannel

import org.glassfish.grizzly.Connection; //导入方法依赖的package包/类
@Override
protected Channel getChannel() {
    Connection<?> c = connection;
    if (c == null || !c.isOpen())
        return null;
    return GrizzlyChannel.getOrAddChannel(c, getUrl(), this);
}
 
开发者ID:hufeng,项目名称:dubbo2.js,代码行数:8,代码来源:GrizzlyClient.java

示例5: removeChannelIfDisconnectd

import org.glassfish.grizzly.Connection; //导入方法依赖的package包/类
static void removeChannelIfDisconnectd(Connection<?> connection) {
    if (connection != null && ! connection.isOpen()) {
        ATTRIBUTE.remove(connection);
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:6,代码来源:GrizzlyChannel.java

示例6: handleRead

import org.glassfish.grizzly.Connection; //导入方法依赖的package包/类
/**
 * This method will be called, once {@link Connection} has some available
 * data
 */
@Override
public NextAction handleRead(final FilterChainContext ctx)
        throws IOException {
    logger.log(Level.FINEST, "Connection: {0} handleRead: {1}",
            new Object[] { ctx.getConnection(), ctx.getMessage() });

    final Connection connection = ctx.getConnection();
    final Connection peerConnection = peerConnectionAttribute
            .get(connection);

    // if connection is closed - stop the execution
    if (!connection.isOpen()) {
        return ctx.getStopAction();
    }

    final NextAction suspendNextAction = ctx.getSuspendAction();

    // if peerConnection wasn't created - create it (usually happens on
    // first connection request)
    if (peerConnection == null) {
        // "Peer connect" phase could take some time - so execute it in
        // non-blocking mode

        // Connect peer connection and register completion handler
        transport.connect(redirectAddress,
                new ConnectCompletionHandler(ctx));

        // return suspend status
        return suspendNextAction;
    }

    final Object message = ctx.getMessage();
    // if peer connection is already created - just forward data to peer
    redirectToPeer(ctx, peerConnection, message);
    // if peer connection is already created - just forward data to peer

    final AsyncQueueWriter writer = (AsyncQueueWriter) connection
            .getTransport().getWriter(false);

    if (writer.canWrite(peerConnection)) {
        return ctx.getStopAction();
    }

    // Make sure we don't overload peer's output buffer and do not cause
    // OutOfMemoryError
    ctx.suspend();
    writer.notifyWritePossible(peerConnection, new WriteHandler() {

        @Override
        public void onWritePossible() throws Exception {
            finish();
        }

        @Override
        public void onError(Throwable t) {
            finish();
        }

        private void finish() {
            ctx.resumeNext();
        }
    });

    // return ctx.getStopAction();
    return suspendNextAction;
}
 
开发者ID:chocotan,项目名称:kazeproxy,代码行数:71,代码来源:TunnelRedirectServerFilter.java

示例7: removeChannelIfDisconnectd

import org.glassfish.grizzly.Connection; //导入方法依赖的package包/类
static void removeChannelIfDisconnectd(Connection<?> connection) {
    if (connection != null && !connection.isOpen()) {
        ATTRIBUTE.remove(connection);
    }
}
 
开发者ID:hufeng,项目名称:dubbo2.js,代码行数:6,代码来源:GrizzlyChannel.java


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