📄 coyoteconnector.java
字号:
/*
* Copyright 1999-2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.coyote.tomcat4;
import org.apache.tomcat.util.IntrospectionUtils;
import org.apache.coyote.Adapter;
import org.apache.coyote.ProtocolHandler;
import org.apache.catalina.Connector;
import org.apache.catalina.Container;
import org.apache.catalina.Lifecycle;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.LifecycleListener;
import org.apache.catalina.Logger;
import org.apache.catalina.Request;
import org.apache.catalina.Response;
import org.apache.catalina.Service;
import org.apache.catalina.net.DefaultServerSocketFactory;
import org.apache.catalina.net.ServerSocketFactory;
import org.apache.catalina.util.LifecycleSupport;
import org.apache.catalina.util.StringManager;
import org.apache.commons.modeler.Registry;
import javax.management.MBeanRegistration;
import javax.management.ObjectName;
import javax.management.MBeanServer;
/**
* Implementation of a Coyote connector for Tomcat 4.x.
*
* @author Craig R. McClanahan
* @author Remy Maucherat
* @version $Revision: 301061 $ $Date: 2005-09-20 18:18:40 -0400 (Tue, 20 Sep 2005) $
*/
public final class CoyoteConnector
implements Connector, Lifecycle, MBeanRegistration {
// ----------------------------------------------------- Instance Variables
/**
* The <code>Service</code> we are associated with (if any).
*/
private Service service = null;
/**
* The accept count for this Connector.
*/
private int acceptCount = 10;
/**
* The IP address on which to bind, if any. If <code>null</code>, all
* addresses on the server will be bound.
*/
private String address = null;
/**
* Do we allow TRACE ?
*/
private boolean allowTrace = false;
/**
* The input buffer size we should create on input streams.
*/
private int bufferSize = 2048;
/**
* The Container used for processing requests received by this Connector.
*/
protected Container container = null;
/**
* The current number of processors that have been created.
*/
private int curProcessors = 0;
/**
* The debugging detail level for this component.
*/
private int debug = 0;
/**
* The "enable DNS lookups" flag for this Connector.
*/
private boolean enableLookups = false;
/**
* The server socket factory for this component.
*/
private ServerSocketFactory factory = null;
/**
* Descriptive information about this Connector implementation.
*/
private static final String info =
"org.apache.coyote.tomcat4.CoyoteConnector2/1.0";
/**
* The lifecycle event support for this component.
*/
protected LifecycleSupport lifecycle = new LifecycleSupport(this);
/**
* The minimum number of processors to start at initialization time.
*/
protected int minProcessors = 5;
/**
* The maximum amount of spare processors.
*/
protected int maxSpareProcessors = 5;
/**
* The maximum number of processors allowed, or <0 for unlimited.
*/
private int maxProcessors = 20;
/**
* The maximum permitted size of the request and response HTTP headers.
*/
private int maxHttpHeaderSize = 4 * 1024;
/**
* Linger value on the incoming connection.
* Note : a value inferior to 0 means no linger.
*/
private int connectionLinger = Constants.DEFAULT_CONNECTION_LINGER;
/**
* Timeout value on the incoming connection.
* Note : a value of 0 means no timeout.
*/
private int connectionTimeout = Constants.DEFAULT_CONNECTION_TIMEOUT;
/**
* Timeout value on the incoming connection during request processing.
* Note : a value of 0 means no timeout.
*/
private int connectionUploadTimeout =
Constants.DEFAULT_CONNECTION_UPLOAD_TIMEOUT;
/**
* Timeout value on the server socket.
* Note : a value of 0 means no timeout.
*/
private int serverSocketTimeout = Constants.DEFAULT_SERVER_SOCKET_TIMEOUT;
/**
* The port number on which we listen for requests.
*/
private int port = 8080;
/**
* The server name to which we should pretend requests to this Connector
* were directed. This is useful when operating Tomcat behind a proxy
* server, so that redirects get constructed accurately. If not specified,
* the server name included in the <code>Host</code> header is used.
*/
private String proxyName = null;
/**
* The server port to which we should pretent requests to this Connector
* were directed. This is useful when operating Tomcat behind a proxy
* server, so that redirects get constructed accurately. If not specified,
* the port number specified by the <code>port</code> property is used.
*/
private int proxyPort = 0;
/**
* The redirect port for non-SSL to SSL redirects.
*/
private int redirectPort = 443;
/**
* The request scheme that will be set on all requests received
* through this connector.
*/
private String scheme = "http";
/**
* The secure connection flag that will be set on all requests received
* through this connector.
*/
private boolean secure = false;
/** For jk, do tomcat authentication if true, trust server if false
*/
private boolean tomcatAuthentication = true;
/**
* The string manager for this package.
*/
private StringManager sm =
StringManager.getManager(Constants.Package);
/**
* Has this component been initialized yet?
*/
private boolean initialized = false;
/**
* Has this component been started yet?
*/
private boolean started = false;
/**
* Use TCP no delay ?
*/
private boolean tcpNoDelay = true;
/**
* Flag to disable setting a seperate time-out for uploads.
* If <code>true</code>, then the <code>timeout</code> parameter is
* ignored. If <code>false</code>, then the <code>timeout</code>
* parameter is used to control uploads.
*/
private boolean disableUploadTimeout = false;
/**
* Maximum number of Keep-Alive requests to honor per connection.
*/
private int maxKeepAliveRequests = 100;
/**
* Compression value.
*/
private String compressableMimeTypes = "text/html,text/xml,text/plain";
private String compression = "off";
/**
* Coyote Protocol handler class name.
* Defaults to the Coyote HTTP/1.1 protocolHandler.
*/
private String protocolHandlerClassName =
"org.apache.coyote.http11.Http11Protocol";
/**
* Use URI validation for Tomcat 4.0.x.
*/
private boolean useURIValidationHack = true;
/**
* Coyote protocol handler.
*/
private ProtocolHandler protocolHandler = null;
/**
* Coyote adapter.
*/
private Adapter adapter = null;
/**
* URI encoding.
*/
private String URIEncoding = null;
/**
* URI encoding as body.
*/
private boolean useBodyEncodingForURI = true;
// ------------------------------------------------------------- Properties
/**
* Return the <code>Service</code> with which we are associated (if any).
*/
public Service getService() {
return (this.service);
}
/**
* Set the <code>Service</code> with which we are associated (if any).
*
* @param service The service that owns this Engine
*/
public void setService(Service service) {
this.service = service;
}
/**
* Return the connection linger for this Connector.
*/
public int getConnectionLinger() {
return (connectionLinger);
}
/**
* Set the connection linger for this Connector.
*
* @param connectionLinger The new connection linger
*/
public void setConnectionLinger(int connectionLinger) {
this.connectionLinger = connectionLinger;
}
/**
* Return the connection timeout for this Connector.
*/
public int getConnectionTimeout() {
return (connectionTimeout);
}
/**
* Set the connection timeout for this Connector.
*
* @param connectionTimeout The new connection timeout
*/
public void setConnectionTimeout(int connectionTimeout) {
this.connectionTimeout = connectionTimeout;
}
/**
* Return the connection upload timeout for this Connector.
*/
public int getConnectionUploadTimeout() {
return (connectionUploadTimeout);
}
/**
* Set the connection upload timeout for this Connector.
*
* @param connectionUploadTimeout The new connection upload timeout
*/
public void setConnectionUploadTimeout(int connectionUploadTimeout) {
this.connectionUploadTimeout = connectionUploadTimeout;
}
/**
* Return the server socket timeout for this Connector.
*/
public int getServerSocketTimeout() {
return (serverSocketTimeout);
}
/**
* Set the server socket timeout for this Connector.
*
* @param serverSocketTimeout The new server socket timeout
*/
public void setServerSocketTimeout(int serverSocketTimeout) {
this.serverSocketTimeout = serverSocketTimeout;
}
/**
* Return the accept count for this Connector.
*/
public int getAcceptCount() {
return (acceptCount);
}
/**
* Set the accept count for this Connector.
*
* @param count The new accept count
*/
public void setAcceptCount(int count) {
this.acceptCount = count;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -