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


Java KeyAttachment类代码示例

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


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

示例1: resetTimeouts

import org.apache.tomcat.util.net.NioEndpoint.KeyAttachment; //导入依赖的package包/类
@Override
protected void resetTimeouts() {
    // The NIO connector uses the timeout configured on the wrapper in the
    // poller. Therefore, it needs to be reset once asycn processing has
    // finished.
    final KeyAttachment attach =
            (KeyAttachment)socketWrapper.getSocket().getAttachment();
    if (!getErrorState().isError() && attach != null &&
            asyncStateMachine.isAsyncDispatching()) {
        long soTimeout = endpoint.getSoTimeout();

        //reset the timeout
        if (keepAliveTimeout > 0) {
            attach.setTimeout(keepAliveTimeout);
        } else {
            attach.setTimeout(soTimeout);
        }
    }

}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:21,代码来源:AjpNioProcessor.java

示例2: resetTimeouts

import org.apache.tomcat.util.net.NioEndpoint.KeyAttachment; //导入依赖的package包/类
@Override
protected void resetTimeouts() {
    final NioEndpoint.KeyAttachment attach = (NioEndpoint.KeyAttachment)socketWrapper.getSocket().getAttachment();
    if (!getErrorState().isError() && attach != null &&
            asyncStateMachine.isAsyncDispatching()) {
        long soTimeout = endpoint.getSoTimeout();

        //reset the timeout
        if (keepAlive) {
            attach.setTimeout(keepAliveTimeout);
        } else {
            attach.setTimeout(soTimeout);
        }
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:16,代码来源:Http11NioProcessor.java

示例3: setCometTimeouts

import org.apache.tomcat.util.net.NioEndpoint.KeyAttachment; //导入依赖的package包/类
@Override
protected void setCometTimeouts(SocketWrapper<NioChannel> socketWrapper) {
    // Comet support
    SelectionKey key = socketWrapper.getSocket().getIOChannel().keyFor(
            socketWrapper.getSocket().getPoller().getSelector());
    if (key != null) {
        NioEndpoint.KeyAttachment attach = (NioEndpoint.KeyAttachment) key.attachment();
        if (attach != null)  {
            attach.setComet(comet);
            if (comet) {
                Integer comettimeout = (Integer) request.getAttribute(
                        org.apache.coyote.Constants.COMET_TIMEOUT_ATTR);
                if (comettimeout != null) {
                    attach.setTimeout(comettimeout.longValue());
                }
            }
        }
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:20,代码来源:Http11NioProcessor.java

示例4: resetTimeouts

import org.apache.tomcat.util.net.NioEndpoint.KeyAttachment; //导入依赖的package包/类
@Override
protected void resetTimeouts() {
	// The NIO connector uses the timeout configured on the wrapper in the
	// poller. Therefore, it needs to be reset once asycn processing has
	// finished.
	final KeyAttachment attach = (KeyAttachment) socketWrapper.getSocket().getAttachment();
	if (!getErrorState().isError() && attach != null && asyncStateMachine.isAsyncDispatching()) {
		long soTimeout = endpoint.getSoTimeout();

		// reset the timeout
		if (keepAliveTimeout > 0) {
			attach.setTimeout(keepAliveTimeout);
		} else {
			attach.setTimeout(soTimeout);
		}
	}

}
 
开发者ID:how2j,项目名称:lazycat,代码行数:19,代码来源:AjpNioProcessor.java

示例5: setCometTimeouts

import org.apache.tomcat.util.net.NioEndpoint.KeyAttachment; //导入依赖的package包/类
@Override
protected void setCometTimeouts(SocketWrapper<NioChannel> socketWrapper) {
	// Comet support
	SelectionKey key = socketWrapper.getSocket().getIOChannel()
			.keyFor(socketWrapper.getSocket().getPoller().getSelector());
	if (key != null) {
		NioEndpoint.KeyAttachment attach = (NioEndpoint.KeyAttachment) key.attachment();
		if (attach != null) {
			attach.setComet(comet);
			if (comet) {
				Integer comettimeout = (Integer) request
						.getAttribute(org.apache.coyote.Constants.COMET_TIMEOUT_ATTR);
				if (comettimeout != null) {
					attach.setTimeout(comettimeout.longValue());
				}
			}
		}
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:20,代码来源:Http11NioProcessor.java

示例6: actionInternal

import org.apache.tomcat.util.net.NioEndpoint.KeyAttachment; //导入依赖的package包/类
/**
 * Send an action to the connector.
 *
 * @param actionCode Type of the action
 * @param param Action parameter
 */
@Override
protected void actionInternal(ActionCode actionCode, Object param) {

    if (actionCode == ActionCode.ASYNC_COMPLETE) {
        if (asyncStateMachine.asyncComplete()) {
            ((NioEndpoint)endpoint).processSocket(this.socketWrapper.getSocket(),
                    SocketStatus.OPEN_READ, false);
        }

    } else if (actionCode == ActionCode.ASYNC_SETTIMEOUT) {
        if (param == null) return;
        long timeout = ((Long)param).longValue();
        final KeyAttachment ka =
                (KeyAttachment)socketWrapper.getSocket().getAttachment(false);
        ka.setTimeout(timeout);

    } else if (actionCode == ActionCode.ASYNC_DISPATCH) {
        if (asyncStateMachine.asyncDispatch()) {
            ((NioEndpoint)endpoint).processSocket(this.socketWrapper.getSocket(),
                    SocketStatus.OPEN_READ, true);
        }
    }
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:30,代码来源:AjpNioProcessor.java

示例7: resetTimeouts

import org.apache.tomcat.util.net.NioEndpoint.KeyAttachment; //导入依赖的package包/类
@Override
protected void resetTimeouts() {
    // The NIO connector uses the timeout configured on the wrapper in the
    // poller. Therefore, it needs to be reset once asycn processing has
    // finished.
    final KeyAttachment attach =
            (KeyAttachment)socketWrapper.getSocket().getAttachment(false);
    if (!error && attach != null &&
            asyncStateMachine.isAsyncDispatching()) {
        long soTimeout = endpoint.getSoTimeout();

        //reset the timeout
        if (keepAliveTimeout > 0) {
            attach.setTimeout(keepAliveTimeout);
        } else {
            attach.setTimeout(soTimeout);
        }
    }

}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:21,代码来源:AjpNioProcessor.java

示例8: breakKeepAliveLoop

import org.apache.tomcat.util.net.NioEndpoint.KeyAttachment; //导入依赖的package包/类
@Override
protected boolean breakKeepAliveLoop(
        SocketWrapper<NioChannel> socketWrapper) {
    openSocket = keepAlive;
    // Do sendfile as needed: add socket to sendfile and end
    if (sendfileData != null && !error) {
        ((KeyAttachment) socketWrapper).setSendfileData(sendfileData);
        sendfileData.keepAlive = keepAlive;
        SelectionKey key = socketWrapper.getSocket().getIOChannel().keyFor(
                socketWrapper.getSocket().getPoller().getSelector());
        //do the first write on this thread, might as well
        if (socketWrapper.getSocket().getPoller().processSendfile(key,
                (KeyAttachment) socketWrapper, true)) {
            sendfileInProgress = true;
        } else {
            // Write failed
            if (log.isDebugEnabled()) {
                log.debug(sm.getString("http11processor.sendfile.error"));
            }
            error = true;
        }
        return true;
    }
    return false;
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:26,代码来源:Http11NioProcessor.java

示例9: resetTimeouts

import org.apache.tomcat.util.net.NioEndpoint.KeyAttachment; //导入依赖的package包/类
@Override
protected void resetTimeouts() {
    // The NIO connector uses the timeout configured on the wrapper in the
    // poller. Therefore, it needs to be reset once asycn processing has
    // finished.
    final KeyAttachment attach =
            (KeyAttachment)socketWrapper.getSocket().getAttachment(false);
    if (!getErrorState().isError() && attach != null &&
            asyncStateMachine.isAsyncDispatching()) {
        long soTimeout = endpoint.getSoTimeout();

        //reset the timeout
        if (keepAliveTimeout > 0) {
            attach.setTimeout(keepAliveTimeout);
        } else {
            attach.setTimeout(soTimeout);
        }
    }

}
 
开发者ID:sdw2330976,项目名称:apache-tomcat-7.0.57,代码行数:21,代码来源:AjpNioProcessor.java

示例10: breakKeepAliveLoop

import org.apache.tomcat.util.net.NioEndpoint.KeyAttachment; //导入依赖的package包/类
@Override
protected boolean breakKeepAliveLoop(SocketWrapper<NioChannel> socketWrapper) {
    openSocket = keepAlive;
    // Do sendfile as needed: add socket to sendfile and end
    if (sendfileData != null && !getErrorState().isError()) {
        ((KeyAttachment) socketWrapper).setSendfileData(sendfileData);
        sendfileData.keepAlive = keepAlive;
        SelectionKey key = socketWrapper.getSocket().getIOChannel().keyFor(
                socketWrapper.getSocket().getPoller().getSelector());
        //do the first write on this thread, might as well
        if (socketWrapper.getSocket().getPoller().processSendfile(key,
                (KeyAttachment) socketWrapper, true)) {
            sendfileInProgress = true;
        } else {
            // Write failed
            if (log.isDebugEnabled()) {
                log.debug(sm.getString("http11processor.sendfile.error"));
            }
            setErrorState(ErrorState.CLOSE_NOW, null);
        }
        return true;
    }
    return false;
}
 
开发者ID:sdw2330976,项目名称:apache-tomcat-7.0.57,代码行数:25,代码来源:Http11NioProcessor.java

示例11: actionInternal

import org.apache.tomcat.util.net.NioEndpoint.KeyAttachment; //导入依赖的package包/类
/**
 * Send an action to the connector.
 *
 * @param actionCode Type of the action
 * @param param Action parameter
 */
@Override
protected void actionInternal(ActionCode actionCode, Object param) {

    if (actionCode == ActionCode.ASYNC_COMPLETE) {
        if (asyncStateMachine.asyncComplete()) {
            ((NioEndpoint)endpoint).processSocket(this.socket,
                    SocketStatus.OPEN, false);
        }
    } else if (actionCode == ActionCode.ASYNC_SETTIMEOUT) {
        if (param == null) return;
        long timeout = ((Long)param).longValue();
        final KeyAttachment ka = (KeyAttachment)socket.getAttachment(false);
        if (keepAliveTimeout > 0) {
            ka.setTimeout(timeout);
        }
    } else if (actionCode == ActionCode.ASYNC_DISPATCH) {
        if (asyncStateMachine.asyncDispatch()) {
            ((NioEndpoint)endpoint).processSocket(this.socket,
                    SocketStatus.OPEN, true);
        }
    }
}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:29,代码来源:AjpNioProcessor.java

示例12: output

import org.apache.tomcat.util.net.NioEndpoint.KeyAttachment; //导入依赖的package包/类
@Override
protected void output(byte[] src, int offset, int length)
        throws IOException {
    ByteBuffer writeBuffer = socket.getBufHandler() .getWriteBuffer();

    writeBuffer.put(src, offset, length);
    
    writeBuffer.flip();
    
    NioEndpoint.KeyAttachment att = (NioEndpoint.KeyAttachment)socket.getAttachment(false);
    if ( att == null ) throw new IOException("Key must be cancelled");
    long writeTimeout = att.getTimeout();
    Selector selector = null;
    try {
        selector = pool.get();
    } catch ( IOException x ) {
        //ignore
    }
    try {
        pool.write(writeBuffer, socket, selector, writeTimeout, true,
                null);
    }finally { 
        if ( selector != null ) pool.put(selector);
    }
    writeBuffer.clear();
}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:27,代码来源:AjpNioProcessor.java

示例13: longPoll

import org.apache.tomcat.util.net.NioEndpoint.KeyAttachment; //导入依赖的package包/类
@Override
protected void longPoll(SocketWrapper<NioChannel> socket,
        Http11NioProcessor processor) {
    connections.put(socket.getSocket(), processor);
    
    if (processor.isAsync()) {
        socket.setAsync(true);
    } else {
        // Either:
        //  - this is comet request
        //  - the request line/headers have not been completely
        //    read
        SelectionKey key = socket.getSocket().getIOChannel().keyFor(
                socket.getSocket().getPoller().getSelector());
        key.interestOps(SelectionKey.OP_READ);
        ((KeyAttachment) socket).interestOps(
                SelectionKey.OP_READ);
    }
}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:20,代码来源:Http11NioProtocol.java

示例14: setCometTimeouts

import org.apache.tomcat.util.net.NioEndpoint.KeyAttachment; //导入依赖的package包/类
@Override
protected void setCometTimeouts(SocketWrapper<NioChannel> socketWrapper) {
    // Comet support
    SelectionKey key = socketWrapper.getSocket().getIOChannel().keyFor(
            socketWrapper.getSocket().getPoller().getSelector());
    if (key != null) {
        NioEndpoint.KeyAttachment attach = (NioEndpoint.KeyAttachment) key.attachment();
        if (attach != null)  {
            attach.setComet(comet);
            if (comet) {
                Integer comettimeout = (Integer) request.getAttribute("org.apache.tomcat.comet.timeout");
                if (comettimeout != null) attach.setTimeout(comettimeout.longValue());
            }
        }
    }
}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:17,代码来源:Http11NioProcessor.java

示例15: breakKeepAliveLoop

import org.apache.tomcat.util.net.NioEndpoint.KeyAttachment; //导入依赖的package包/类
@Override
protected boolean breakKeepAliveLoop(
        SocketWrapper<NioChannel> socketWrapper) {
    // Do sendfile as needed: add socket to sendfile and end
    if (sendfileData != null && !error) {
        ((KeyAttachment) socketWrapper).setSendfileData(sendfileData);
        sendfileData.keepAlive = keepAlive;
        SelectionKey key = socketWrapper.getSocket().getIOChannel().keyFor(
                socketWrapper.getSocket().getPoller().getSelector());
        //do the first write on this thread, might as well
        openSocket = socketWrapper.getSocket().getPoller().processSendfile(key,
                (KeyAttachment) socketWrapper, true, true);
        return true;
    }
    return false;
}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:17,代码来源:Http11NioProcessor.java


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