coyoteconnector.java
来自「This temp directory is used by the JVM f」· Java 代码 · 共 1,909 行 · 第 1/4 页
JAVA
1,909 行
/*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* [Additional notices, if required by prior licensing conditions]
*
*/
package org.apache.coyote.tomcat5;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Iterator;
import javax.management.MBeanRegistration;
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
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.core.StandardEngine;
import org.apache.catalina.net.ServerSocketFactory;
import org.apache.catalina.util.LifecycleSupport;
import org.apache.catalina.util.StringManager;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.modeler.Registry;
import org.apache.coyote.Adapter;
import org.apache.coyote.ProtocolHandler;
import org.apache.tomcat.util.IntrospectionUtils;
import org.apache.tomcat.util.http.mapper.Mapper;
/**
* Implementation of a Coyote connector for Tomcat 5.x.
*
* @author Craig R. McClanahan
* @author Remy Maucherat
* @version $Revision: 1.39 $ $Date: 2004/01/26 20:19:10 $
*/
public class CoyoteConnector
implements Connector, Lifecycle, MBeanRegistration
{
private static Log log = LogFactory.getLog(CoyoteConnector.class);
// ----------------------------------------------------- Instance Variables
/**
* Holder for our configured properties.
*/
private HashMap properties = new HashMap();
/**
* 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;
/**
* Compression value.
*/
private String compression = "off";
/**
* 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;
/*
* Is generation of X-Powered-By response header enabled/disabled?
*/
private boolean xpoweredBy;
/**
* Descriptive information about this Connector implementation.
*/
private static final String info =
"org.apache.coyote.tomcat5.CoyoteConnector/2.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 number of processors allowed, or <0 for unlimited.
*/
private int maxProcessors = 20;
/**
* 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 = 0;
/**
* 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);
/**
* 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 size of a HTTP header. 4KB is the default.
*/
private int maxHttpHeaderSize = 4 * 1024;
/**
* Maximum number of Keep-Alive requests to honor per connection.
*/
private int maxKeepAliveRequests = 100;
/**
* Maximum size of a POST which will be automatically parsed by the
* container. 2MB by default.
*/
private int maxPostSize = 2 * 1024 * 1024;
/**
* Has this component been initialized yet?
*/
private boolean initialized = false;
/**
* Has this component been started yet?
*/
private boolean started = false;
/**
* The shutdown signal to our background thread
*/
private boolean stopped = false;
/**
* The background thread.
*/
private Thread thread = null;
/**
* Use TCP no delay ?
*/
private boolean tcpNoDelay = true;
/**
* Coyote Protocol handler class name.
* Defaults to the Coyote HTTP/1.1 protocolHandler.
*/
private String protocolHandlerClassName =
"org.apache.coyote.http11.Http11Protocol";
/**
* Coyote protocol handler.
*/
private ProtocolHandler protocolHandler = null;
/**
* Coyote adapter.
*/
private Adapter adapter = null;
/**
* Mapper.
*/
private Mapper mapper = new Mapper();
/**
* Mapper listener.
*/
private MapperListener mapperListener = new MapperListener(mapper);
/**
* URI encoding.
*/
private String URIEncoding = null;
/**
* URI encoding as body.
*/
private boolean useBodyEncodingForURI = false;
// ------------------------------------------------------------- Properties
/**
* Return a configured property.
*/
public Object getProperty(String name) {
return properties.get(name);
}
/**
* Set a configured property.
*/
public void setProperty(String name, Object value) {
properties.put(name, value);
}
/**
* remove a configured property.
*/
public void removeProperty(String name) {
properties.remove(name);
}
/**
* 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;
setProperty("service", service);
}
/**
* Get the value of compression.
*/
public String getCompression() {
return (compression);
}
/**
* Set the value of compression.
*
* @param compression The new compression value, which can be "on", "off"
* or "force"
*/
public void setCompression(String compression) {
this.compression = compression;
setProperty("compression", compression);
}
/**
* Return the connection linger for this Connector.
*/
public int getConnectionLinger() {
return (connectionLinger);
}
/**
* Set the connection linger for this Connector.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?