📄 ajp13connector.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.ajp.tomcat4;
import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.security.AccessControlException;
import java.util.Stack;
import java.util.Vector;
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.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;
/**
* Implementation of an Ajp13 connector.
*
* @author Kevin Seguin
* @version $Revision: 299218 $ $Date: 2004-02-24 03:48:44 -0500 (Tue, 24 Feb 2004) $
*/
public final class Ajp13Connector
implements Connector, Lifecycle, Runnable {
// ----------------------------------------------------- Instance Variables
/**
* 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;
/**
* 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 set of processors that have ever been created.
*/
private Vector created = new Vector();
/**
* 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 server socket factory for this component.
*/
private ServerSocketFactory factory = null;
/**
* Descriptive information about this Connector implementation.
*/
private static final String info =
"org.apache.catalina.connector.ajp.Ajp13Connector/1.0";
/**
* redirect port.
*/
private int redirectPort = -1;
/**
* enable DNS lookups.
*/
private boolean enableLookups = false;
/**
* 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;
/**
* Timeout value on the incoming connection.
* Note : a value of 0 means no timeout.
*/
private int connectionTimeout = -1;
/**
* Linger value to be used on socket close.
* Note : a value of -1 means no linger used on close.
*/
private int connectionLinger = -1;
/**
* The port number on which we listen for ajp13 requests.
*/
private int port = 8009;
/**
* The set of processors that have been created but are not currently
* being used to process a request.
*/
private Stack processors = new Stack();
/**
* 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;
/**
* The server socket through which we listen for incoming TCP connections.
*/
private ServerSocket serverSocket = null;
/**
* The string manager for this package.
*/
private StringManager sm =
StringManager.getManager(Constants.PACKAGE);
/**
* 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;
/**
* This connector's thread group.
*/
private ThreadGroup threadGroup = null;
/**
* The name to register for the background thread.
*/
private String threadName = null;
/**
* A thread that periodically logs debug info if debug > 0.
*/
private DebugThread debugThread = null;
/**
* The thread synchronization object.
*/
private Object threadSync = new Object();
private Ajp13Logger logger = new Ajp13Logger();
/**
* The service which which the connector is associated
*/
private Service service = null;
private String secret = null;
/**
* Tomcat authentication flag. If true, the authnetication is done by
* Tomcat, otherwise, it is done by the native webserver.
*/
private boolean tomcatAuthentication = true;
// ------------------------------------------------------------- Properties
/**
* 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 linger settings 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;
}
public void setSecret( String s ) {
secret=s;
}
public String getSecret() {
return secret;
}
/**
* 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;
}
/**
* Return the bind IP address for this Connector.
*/
public String getAddress() {
return (this.address);
}
/**
* Set the bind IP address for this Connector.
*
* @param address The bind IP address
*/
public void setAddress(String address) {
this.address = address;
}
/**
* Is this connector available for processing requests?
*/
public boolean isAvailable() {
return (started);
}
/**
* Return the input buffer size for this Connector.
*/
public int getBufferSize() {
return (this.bufferSize);
}
/**
* Set the input buffer size for this Connector.
*
* @param bufferSize The new input buffer size.
*/
public void setBufferSize(int bufferSize) {
this.bufferSize = bufferSize;
}
/**
* Return the Container used for processing requests received by this
* Connector.
*/
public Container getContainer() {
return (container);
}
/**
* Set the Container used for processing requests received by this
* Connector.
*
* @param container The new Container to use
*/
public void setContainer(Container container) {
this.container = container;
}
/**
* Return the current number of processors that have been created.
*/
public int getCurProcessors() {
return (curProcessors);
}
/**
* Return the debugging detail level for this component.
*/
public int getDebug() {
return (debug);
}
/**
* Set the debugging detail level for this component.
*
* @param debug The new debugging detail level
*/
public void setDebug(int debug) {
this.debug = debug;
}
/**
* Return the "enable DNS lookups" flag.
*/
public boolean getEnableLookups() {
return this.enableLookups;
}
/**
* Set the "enable DNS lookups" flag.
*
* @param enableLookups The new "enable DNS lookups" flag value
*/
public void setEnableLookups(boolean enableLookups) {
this.enableLookups = enableLookups;
}
/**
* Return the port number to which a request should be redirected if
* it comes in on a non-SSL port and is subject to a security constraint
* with a transport guarantee that requires SSL.
*/
public int getRedirectPort() {
return this.redirectPort;
}
/**
* Set the redirect port number.
*
* @param redirectPort The redirect port number (non-SSL to SSL)
*/
public void setRedirectPort(int redirectPort) {
this.redirectPort = redirectPort;
}
/**
* Return the server socket factory used by this Container.
*/
public ServerSocketFactory getFactory() {
if (this.factory == null) {
synchronized (this) {
this.factory = new DefaultServerSocketFactory();
}
}
return (this.factory);
}
/**
* Set the server socket factory used by this Container.
*
* @param factory The new server socket factory
*/
public void setFactory(ServerSocketFactory factory) {
this.factory = factory;
}
/**
* Return descriptive information about this Connector implementation.
*/
public String getInfo() {
return (info);
}
/**
* Return the minimum number of processors to start at initialization.
*/
public int getMinProcessors() {
return (minProcessors);
}
/**
* Set the minimum number of processors to start at initialization.
*
* @param minProcessors The new minimum processors
*/
public void setMinProcessors(int minProcessors) {
this.minProcessors = minProcessors;
}
/**
* Return the maximum number of processors allowed, or <0 for unlimited.
*/
public int getMaxProcessors() {
return (maxProcessors);
}
/**
* Set the maximum number of processors allowed, or <0 for unlimited.
*
* @param maxProcessors The new maximum processors
*/
public void setMaxProcessors(int maxProcessors) {
this.maxProcessors = maxProcessors;
}
/**
* Return the port number on which we listen for AJP13 requests.
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -