| Method from org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler Detail: |
protected Http11AprProcessor createProcessor() {
Http11AprProcessor processor =
new Http11AprProcessor(proto.maxHttpHeaderSize, proto.endpoint);
processor.setAdapter(proto.adapter);
processor.setMaxKeepAliveRequests(proto.maxKeepAliveRequests);
processor.setTimeout(proto.timeout);
processor.setDisableUploadTimeout(proto.disableUploadTimeout);
processor.setCompressionMinSize(proto.compressionMinSize);
processor.setCompression(proto.compression);
processor.setNoCompressionUserAgents(proto.noCompressionUserAgents);
processor.setCompressableMimeTypes(proto.compressableMimeTypes);
processor.setRestrictedUserAgents(proto.restrictedUserAgents);
processor.setSocketBuffer(proto.socketBuffer);
processor.setMaxSavePostSize(proto.maxSavePostSize);
processor.setServer(proto.server);
register(processor);
return processor;
}
|
public SocketState event(long socket,
SocketStatus status) {
Http11AprProcessor result = connections.get(socket);
SocketState state = SocketState.CLOSED;
if (result != null) {
// Call the appropriate event
try {
state = result.event(status);
} catch (java.net.SocketException e) {
// SocketExceptions are normal
Http11AprProtocol.log.debug
(sm.getString
("http11protocol.proto.socketexception.debug"), e);
} catch (java.io.IOException e) {
// IOExceptions are normal
Http11AprProtocol.log.debug
(sm.getString
("http11protocol.proto.ioexception.debug"), e);
}
// Future developers: if you discover any other
// rare-but-nonfatal exceptions, catch them here, and log as
// above.
catch (Throwable e) {
// any other exception or error is odd. Here we log it
// with "ERROR" level, so it will show up even on
// less-than-verbose logs.
Http11AprProtocol.log.error
(sm.getString("http11protocol.proto.error"), e);
} finally {
if (state != SocketState.LONG) {
connections.remove(socket);
recycledProcessors.offer(result);
if (state == SocketState.OPEN) {
proto.endpoint.getPoller().add(socket);
}
} else {
proto.endpoint.getCometPoller().add(socket);
}
}
}
return state;
}
|
public SocketState process(long socket) {
Http11AprProcessor processor = recycledProcessors.poll();
try {
if (processor == null) {
processor = createProcessor();
}
if (processor instanceof ActionHook) {
((ActionHook) processor).action(ActionCode.ACTION_START, null);
}
SocketState state = processor.process(socket);
if (state == SocketState.LONG) {
// Associate the connection with the processor. The next request
// processed by this thread will use either a new or a recycled
// processor.
connections.put(socket, processor);
proto.endpoint.getCometPoller().add(socket);
} else {
recycledProcessors.offer(processor);
}
return state;
} catch (java.net.SocketException e) {
// SocketExceptions are normal
Http11AprProtocol.log.debug
(sm.getString
("http11protocol.proto.socketexception.debug"), e);
} catch (java.io.IOException e) {
// IOExceptions are normal
Http11AprProtocol.log.debug
(sm.getString
("http11protocol.proto.ioexception.debug"), e);
}
// Future developers: if you discover any other
// rare-but-nonfatal exceptions, catch them here, and log as
// above.
catch (Throwable e) {
// any other exception or error is odd. Here we log it
// with "ERROR" level, so it will show up even on
// less-than-verbose logs.
Http11AprProtocol.log.error
(sm.getString("http11protocol.proto.error"), e);
}
recycledProcessors.offer(processor);
return SocketState.CLOSED;
}
|
protected void register(Http11AprProcessor processor) {
if (proto.getDomain() != null) {
synchronized (this) {
try {
long count = registerCount.incrementAndGet();
RequestInfo rp = processor.getRequest().getRequestProcessor();
rp.setGlobalProcessor(global);
ObjectName rpName = new ObjectName
(proto.getDomain() + ":type=RequestProcessor,worker="
+ proto.getName() + ",name=HttpRequest" + count);
if (log.isDebugEnabled()) {
log.debug("Register " + rpName);
}
Registry.getRegistry(null, null).registerComponent(rp, rpName, null);
rp.setRpName(rpName);
} catch (Exception e) {
log.warn("Error registering request");
}
}
}
}
|
protected void unregister(Http11AprProcessor processor) {
if (proto.getDomain() != null) {
synchronized (this) {
try {
RequestInfo rp = processor.getRequest().getRequestProcessor();
rp.setGlobalProcessor(null);
ObjectName rpName = rp.getRpName();
if (log.isDebugEnabled()) {
log.debug("Unregister " + rpName);
}
Registry.getRegistry(null, null).unregisterComponent(rpName);
rp.setRpName(null);
} catch (Exception e) {
log.warn("Error unregistering request", e);
}
}
}
}
|