本文整理汇总了Java中org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState类的典型用法代码示例。如果您正苦于以下问题:Java SocketState类的具体用法?Java SocketState怎么用?Java SocketState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SocketState类属于org.apache.tomcat.util.net.AbstractEndpoint.Handler包,在下文中一共展示了SocketState类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: event
import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState; //导入依赖的package包/类
/**
* Process pipelined HTTP requests using the specified input and output
* streams.
*
* @throws IOException error during an I/O operation
*/
@Override
public SocketState event(SocketStatus status)
throws IOException {
RequestInfo rp = request.getRequestProcessor();
try {
rp.setStage(org.apache.coyote.Constants.STAGE_SERVICE);
if (!getAdapter().event(request, response, status)) {
setErrorState(ErrorState.CLOSE_NOW, null);
}
} catch (InterruptedIOException e) {
setErrorState(ErrorState.CLOSE_NOW, e);
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
// 500 - Internal Server Error
response.setStatus(500);
setErrorState(ErrorState.CLOSE_NOW, t);
getAdapter().log(request, response, 0);
log.error(sm.getString("http11processor.request.process"), t);
}
rp.setStage(org.apache.coyote.Constants.STAGE_ENDED);
if (getErrorState().isError() || status==SocketStatus.STOP) {
return SocketState.CLOSED;
} else if (!comet) {
inputBuffer.nextRequest();
outputBuffer.nextRequest();
return SocketState.OPEN;
} else {
return SocketState.LONG;
}
}
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:41,代码来源:Http11AprProcessor.java
示例2: doRun
import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState; //导入依赖的package包/类
private void doRun() {
// Process the request from this socket
if (socket.getSocket() == null) {
// Closed in another thread
return;
}
SocketState state = handler.process(socket, status);
if (state == Handler.SocketState.CLOSED) {
// Close socket and pool
closeSocket(socket.getSocket().longValue());
socket.socket = null;
} else if (state == Handler.SocketState.LONG) {
socket.access();
if (socket.async) {
waitingRequests.add(socket);
}
} else if (state == Handler.SocketState.ASYNC_END) {
socket.access();
SocketProcessor proc = new SocketProcessor(socket, SocketStatus.OPEN_READ);
getExecutor().execute(proc);
}
}
开发者ID:how2j,项目名称:lazycat,代码行数:23,代码来源:AprEndpoint.java
示例3: doRun
import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState; //导入依赖的package包/类
private void doRun() {
// Process the request from this socket
if (socket.getSocket() == null) {
// Closed in another thread
return;
}
SocketState state = handler.process(socket, status);
if (state == Handler.SocketState.CLOSED) {
// Close socket and pool
closeSocket(socket.getSocket().longValue());
socket.socket = null;
} else if (state == Handler.SocketState.LONG) {
socket.access();
if (socket.async) {
waitingRequests.add(socket);
}
} else if (state == Handler.SocketState.ASYNC_END) {
socket.access();
SocketProcessor proc = new SocketProcessor(socket,
SocketStatus.OPEN_READ);
getExecutor().execute(proc);
}
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:24,代码来源:AprEndpoint.java
示例4: asyncPostProcess
import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState; //导入依赖的package包/类
public synchronized SocketState asyncPostProcess() {
if (state == AsyncState.COMPLETE_PENDING) {
doComplete();
return SocketState.ASYNC_END;
} else if (state == AsyncState.DISPATCH_PENDING) {
doDispatch();
return SocketState.ASYNC_END;
} else if (state == AsyncState.STARTING) {
state = AsyncState.STARTED;
return SocketState.LONG;
} else if (state == AsyncState.MUST_COMPLETE) {
asyncCtxt.fireOnComplete();
state = AsyncState.DISPATCHED;
return SocketState.ASYNC_END;
} else if (state == AsyncState.COMPLETING) {
asyncCtxt.fireOnComplete();
state = AsyncState.DISPATCHED;
return SocketState.ASYNC_END;
} else if (state == AsyncState.MUST_DISPATCH) {
state = AsyncState.DISPATCHING;
return SocketState.ASYNC_END;
} else if (state == AsyncState.DISPATCHING) {
state = AsyncState.DISPATCHED;
return SocketState.ASYNC_END;
} else if (state == AsyncState.STARTED) {
// This can occur if an async listener does a dispatch to an async
// servlet during onTimeout
return SocketState.LONG;
} else {
throw new IllegalStateException(
sm.getString("asyncStateMachine.invalidAsyncState",
"asyncPostProcess()", state));
}
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:35,代码来源:AsyncStateMachine.java
示例5: run
import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState; //导入依赖的package包/类
@Override
public void run() {
synchronized (socket) {
if (!deferAccept) {
if (setSocketOptions(socket.getSocket().longValue())) {
getPoller().add(socket.getSocket().longValue(),
getSoTimeout(), true, false);
} else {
// Close socket and pool
closeSocket(socket.getSocket().longValue());
socket = null;
}
} else {
// Process the request from this socket
if (!setSocketOptions(socket.getSocket().longValue())) {
// Close socket and pool
closeSocket(socket.getSocket().longValue());
socket = null;
return;
}
// Process the request from this socket
Handler.SocketState state = handler.process(socket,
SocketStatus.OPEN_READ);
if (state == Handler.SocketState.CLOSED) {
// Close socket and pool
closeSocket(socket.getSocket().longValue());
socket = null;
} else if (state == Handler.SocketState.LONG) {
socket.access();
if (socket.async) {
waitingRequests.add(socket);
}
}
}
}
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:38,代码来源:AprEndpoint.java
示例6: asyncDispatch
import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState; //导入依赖的package包/类
@Override
public SocketState asyncDispatch(SocketStatus status) {
RequestInfo rp = request.getRequestProcessor();
try {
rp.setStage(org.apache.coyote.Constants.STAGE_SERVICE);
if(!getAdapter().asyncDispatch(request, response, status)) {
setErrorState(ErrorState.CLOSE_NOW, null);
}
resetTimeouts();
} catch (InterruptedIOException e) {
setErrorState(ErrorState.CLOSE_NOW, e);
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
setErrorState(ErrorState.CLOSE_NOW, t);
getLog().error(sm.getString("http11processor.request.process"), t);
} finally {
if (getErrorState().isError()) {
// 500 - Internal Server Error
response.setStatus(500);
adapter.log(request, response, 0);
}
}
rp.setStage(org.apache.coyote.Constants.STAGE_ENDED);
if (isAsync()) {
if (getErrorState().isError()) {
request.updateCounters();
return SocketState.CLOSED;
} else {
return SocketState.LONG;
}
} else {
request.updateCounters();
if (getErrorState().isError()) {
return SocketState.CLOSED;
} else {
recycle(false);
return SocketState.OPEN;
}
}
}
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:44,代码来源:AbstractAjpProcessor.java
示例7: event
import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState; //导入依赖的package包/类
/**
* Process pipelined HTTP requests using the specified input and output
* streams.
*
* @throws IOException error during an I/O operation
*/
@Override
public SocketState event(SocketStatus status) throws IOException {
long soTimeout = endpoint.getSoTimeout();
RequestInfo rp = request.getRequestProcessor();
final NioEndpoint.KeyAttachment attach = (NioEndpoint.KeyAttachment)socketWrapper.getSocket().getAttachment();
try {
rp.setStage(org.apache.coyote.Constants.STAGE_SERVICE);
if (!getAdapter().event(request, response, status)) {
setErrorState(ErrorState.CLOSE_NOW, null);
}
if (!getErrorState().isError()) {
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());
}
} else {
//reset the timeout
if (keepAlive) {
attach.setTimeout(keepAliveTimeout);
} else {
attach.setTimeout(soTimeout);
}
}
}
}
} catch (InterruptedIOException e) {
setErrorState(ErrorState.CLOSE_NOW, e);
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
// 500 - Internal Server Error
response.setStatus(500);
setErrorState(ErrorState.CLOSE_NOW, t);
log.error(sm.getString("http11processor.request.process"), t);
getAdapter().log(request, response, 0);
}
rp.setStage(org.apache.coyote.Constants.STAGE_ENDED);
if (getErrorState().isError() || status==SocketStatus.STOP) {
return SocketState.CLOSED;
} else if (!comet) {
if (keepAlive) {
inputBuffer.nextRequest();
outputBuffer.nextRequest();
return SocketState.OPEN;
} else {
return SocketState.CLOSED;
}
} else {
return SocketState.LONG;
}
}
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:66,代码来源:Http11NioProcessor.java
示例8: run
import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState; //导入依赖的package包/类
@Override
public void run() {
synchronized (socket) {
if (!deferAccept) {
if (setSocketOptions(socket.getSocket().longValue())) {
getPoller().add(socket.getSocket().longValue(), getSoTimeout(), true, false);
} else {
// Close socket and pool
closeSocket(socket.getSocket().longValue());
socket = null;
}
} else {
// Process the request from this socket
if (!setSocketOptions(socket.getSocket().longValue())) {
// Close socket and pool
closeSocket(socket.getSocket().longValue());
socket = null;
return;
}
// Process the request from this socket
Handler.SocketState state = handler.process(socket, SocketStatus.OPEN_READ);
if (state == Handler.SocketState.CLOSED) {
// Close socket and pool
closeSocket(socket.getSocket().longValue());
socket = null;
} else if (state == Handler.SocketState.LONG) {
socket.access();
if (socket.async) {
waitingRequests.add(socket);
}
}
}
}
}
开发者ID:how2j,项目名称:lazycat,代码行数:36,代码来源:AprEndpoint.java
示例9: asyncPostProcess
import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState; //导入依赖的package包/类
public synchronized SocketState asyncPostProcess() {
if (state == AsyncState.COMPLETE_PENDING) {
doComplete();
return SocketState.ASYNC_END;
} else if (state == AsyncState.DISPATCH_PENDING) {
doDispatch();
return SocketState.ASYNC_END;
} else if (state == AsyncState.STARTING) {
state = AsyncState.STARTED;
return SocketState.LONG;
} else if (state == AsyncState.MUST_COMPLETE) {
asyncCtxt.fireOnComplete();
state = AsyncState.DISPATCHED;
return SocketState.ASYNC_END;
} else if (state == AsyncState.COMPLETING) {
asyncCtxt.fireOnComplete();
state = AsyncState.DISPATCHED;
return SocketState.ASYNC_END;
} else if (state == AsyncState.MUST_DISPATCH) {
state = AsyncState.DISPATCHING;
return SocketState.ASYNC_END;
} else if (state == AsyncState.DISPATCHING) {
state = AsyncState.DISPATCHED;
return SocketState.ASYNC_END;
} else if (state == AsyncState.STARTED) {
// This can occur if an async listener does a dispatch to an async
// servlet during onTimeout
return SocketState.LONG;
} else {
throw new IllegalStateException(
sm.getString("asyncStateMachine.invalidAsyncState", "asyncPostProcess()", state));
}
}
开发者ID:how2j,项目名称:lazycat,代码行数:34,代码来源:AsyncStateMachine.java
示例10: asyncDispatch
import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState; //导入依赖的package包/类
@Override
public SocketState asyncDispatch(SocketStatus status) {
RequestInfo rp = request.getRequestProcessor();
try {
rp.setStage(org.apache.coyote.Constants.STAGE_SERVICE);
if (!getAdapter().asyncDispatch(request, response, status)) {
setErrorState(ErrorState.CLOSE_NOW, null);
}
resetTimeouts();
} catch (InterruptedIOException e) {
setErrorState(ErrorState.CLOSE_NOW, e);
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
setErrorState(ErrorState.CLOSE_NOW, t);
getLog().error(sm.getString("http11processor.request.process"), t);
} finally {
if (getErrorState().isError()) {
// 500 - Internal Server Error
response.setStatus(500);
adapter.log(request, response, 0);
}
}
rp.setStage(org.apache.coyote.Constants.STAGE_ENDED);
if (getErrorState().isError()) {
return SocketState.CLOSED;
} else if (isAsync()) {
return SocketState.LONG;
} else {
if (!keepAlive) {
return SocketState.CLOSED;
} else {
endRequest();
getInputBuffer().nextRequest();
getOutputBuffer().nextRequest();
return SocketState.OPEN;
}
}
}
开发者ID:how2j,项目名称:lazycat,代码行数:42,代码来源:AbstractHttp11Processor.java
示例11: onData
import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState; //导入依赖的package包/类
@Override
public final SocketState onData() throws IOException {
// Must be start the start of a message (which may consist of multiple
// frames)
WsInputStream wsIs = new WsInputStream(processor, getWsOutbound());
try {
WsFrame frame = wsIs.nextFrame(false);
while (frame != null) {
// TODO User defined extensions may define values for rsv
if (frame.getRsv() > 0) {
closeOutboundConnection(
Constants.STATUS_PROTOCOL_ERROR, null);
return SocketState.CLOSED;
}
byte opCode = frame.getOpCode();
if (opCode == Constants.OPCODE_BINARY) {
doOnBinaryData(wsIs);
} else if (opCode == Constants.OPCODE_TEXT) {
InputStreamReader r =
new InputStreamReader(wsIs, new Utf8Decoder());
doOnTextData(r);
} else if (opCode == Constants.OPCODE_CLOSE){
closeOutboundConnection(frame);
return SocketState.CLOSED;
} else if (opCode == Constants.OPCODE_PING) {
getWsOutbound().pong(frame.getPayLoad());
} else if (opCode == Constants.OPCODE_PONG) {
doOnPong(frame.getPayLoad());
} else {
// Unknown OpCode
closeOutboundConnection(
Constants.STATUS_PROTOCOL_ERROR, null);
return SocketState.CLOSED;
}
frame = wsIs.nextFrame(false);
}
} catch (MalformedInputException mie) {
// Invalid UTF-8
closeOutboundConnection(Constants.STATUS_BAD_DATA, null);
return SocketState.CLOSED;
} catch (UnmappableCharacterException uce) {
// Invalid UTF-8
closeOutboundConnection(Constants.STATUS_BAD_DATA, null);
return SocketState.CLOSED;
} catch (IOException ioe) {
// Given something must have gone to reach this point, this
// might not work but try it anyway.
closeOutboundConnection(Constants.STATUS_PROTOCOL_ERROR, null);
return SocketState.CLOSED;
}
return SocketState.UPGRADED;
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:57,代码来源:StreamInbound.java
示例12: event
import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState; //导入依赖的package包/类
@Override
public SocketState event(SocketStatus status) throws IOException {
// Should never reach this code but in case we do...
throw new IOException(
sm.getString("ajpprocessor.comet.notsupported"));
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:7,代码来源:AbstractAjpProcessor.java
示例13: upgradeDispatch
import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState; //导入依赖的package包/类
@Override
public SocketState upgradeDispatch() throws IOException {
// Should never reach this code but in case we do...
throw new IOException(
sm.getString("ajpprocessor.httpupgrade.notsupported"));
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:7,代码来源:AbstractAjpProcessor.java
示例14: asyncDispatch
import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState; //导入依赖的package包/类
@Override
public SocketState asyncDispatch(SocketStatus status) {
RequestInfo rp = request.getRequestProcessor();
try {
rp.setStage(org.apache.coyote.Constants.STAGE_SERVICE);
if (!getAdapter().asyncDispatch(request, response, status)) {
setErrorState(ErrorState.CLOSE_NOW, null);
}
resetTimeouts();
} catch (InterruptedIOException e) {
setErrorState(ErrorState.CLOSE_NOW, e);
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
setErrorState(ErrorState.CLOSE_NOW, t);
getLog().error(sm.getString("http11processor.request.process"), t);
} finally {
if (getErrorState().isError()) {
// 500 - Internal Server Error
response.setStatus(500);
adapter.log(request, response, 0);
}
}
rp.setStage(org.apache.coyote.Constants.STAGE_ENDED);
if (getErrorState().isError()) {
return SocketState.CLOSED;
} else if (isAsync()) {
return SocketState.LONG;
} else {
if (!keepAlive) {
return SocketState.CLOSED;
} else {
endRequest();
getInputBuffer().nextRequest();
getOutputBuffer().nextRequest();
return SocketState.OPEN;
}
}
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:42,代码来源:AbstractHttp11Processor.java
示例15: upgradeDispatch
import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState; //导入依赖的package包/类
@Override
public SocketState upgradeDispatch(SocketStatus status) throws IOException {
// Should never reach this code but in case we do...
throw new IOException(
sm.getString("ajpprocessor.httpupgrade.notsupported"));
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:7,代码来源:AbstractHttp11Processor.java
示例16: upgradeDispatch
import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState; //导入依赖的package包/类
@Override
public final SocketState upgradeDispatch() throws IOException {
return upgradeInbound.onData();
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:5,代码来源:UpgradeProcessor.java
示例17: process
import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState; //导入依赖的package包/类
@Override
public final SocketState process(SocketWrapper<S> socketWrapper)
throws IOException {
return null;
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:6,代码来源:UpgradeProcessor.java
示例18: event
import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState; //导入依赖的package包/类
@Override
public final SocketState event(SocketStatus status) throws IOException {
return null;
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:5,代码来源:UpgradeProcessor.java
示例19: asyncDispatch
import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState; //导入依赖的package包/类
@Override
public final SocketState asyncDispatch(SocketStatus status) {
return null;
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:5,代码来源:UpgradeProcessor.java
示例20: run
import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState; //导入依赖的package包/类
@Override
public void run() {
boolean launch = false;
synchronized (socket) {
try {
SocketState state = SocketState.OPEN;
try {
// SSL handshake
serverSocketFactory.handshake(socket.getSocket());
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
if (log.isDebugEnabled()) {
log.debug(sm.getString("endpoint.err.handshake"), t);
}
// Tell to close the socket
state = SocketState.CLOSED;
}
if ((state != SocketState.CLOSED)) {
if (status == null) {
state = handler.process(socket, SocketStatus.OPEN_READ);
} else {
state = handler.process(socket, status);
}
}
if (state == SocketState.CLOSED) {
// Close socket
if (log.isTraceEnabled()) {
log.trace("Closing socket:" + socket);
}
countDownConnection();
try {
socket.getSocket().close();
} catch (IOException e) {
// Ignore
}
} else if (state == SocketState.OPEN || state == SocketState.UPGRADING
|| state == SocketState.UPGRADING_TOMCAT || state == SocketState.UPGRADED) {
socket.setKeptAlive(true);
socket.access();
launch = true;
} else if (state == SocketState.LONG) {
socket.access();
waitingRequests.add(socket);
}
} finally {
if (launch) {
try {
getExecutor().execute(new SocketProcessor(socket, SocketStatus.OPEN_READ));
} catch (RejectedExecutionException x) {
log.warn("Socket reprocessing request was rejected for:" + socket, x);
try {
// unable to handle connection at this time
handler.process(socket, SocketStatus.DISCONNECT);
} finally {
countDownConnection();
}
} catch (NullPointerException npe) {
if (running) {
log.error(sm.getString("endpoint.launch.fail"), npe);
}
}
}
}
}
socket = null;
// Finish up this request
}
开发者ID:how2j,项目名称:lazycat,代码行数:71,代码来源:JIoEndpoint.java
注:本文中的org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论