⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 warpconnector.java

📁 Tomcat 4.1与WebServer集成组件的源代码包.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* ========================================================================= * *                                                                           * *                 The Apache Software License,  Version 1.1                 * *                                                                           * *          Copyright (c) 1999-2001 The Apache Software Foundation.          * *                           All rights reserved.                            * *                                                                           * * ========================================================================= * *                                                                           * * Redistribution and use in source and binary forms,  with or without modi- * * fication, are permitted provided that the following conditions are met:   * *                                                                           * * 1. Redistributions of source code  must retain the above copyright notice * *    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 Software Foundation.                                            * *                                                                           * * 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 indivi- * * duals on behalf of the  Apache Software Foundation.  For more information * * on the Apache Software Foundation, please see <http://www.apache.org/>.   * *                                                                           * * ========================================================================= */package org.apache.catalina.connector.warp;import java.io.IOException;import java.net.InetAddress;import java.net.ServerSocket;import java.net.Socket;import java.util.Random;import java.util.Vector;import org.apache.catalina.Connector;import org.apache.catalina.Container;import org.apache.catalina.Context;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;public class WarpConnector implements Connector, Lifecycle, Runnable {    /* ==================================================================== */    /* Instance variables                                                   */    /* ==================================================================== */    /* -------------------------------------------------------------------- */    /* Local variables */    /** The running thread accepting connections */    private Thread thread=null;    /** The server socket. */    private ServerSocket server=null;    /** Our <code>WarpLogger</code>. */    private WarpLogger logger=null;    /** Our list of deployed web applications. */    private Vector applications=new Vector();    /** The unique ID of this connector instance. */    protected int uniqueId=-1;    /* -------------------------------------------------------------------- */    /* Bean variables */    /** The <code>Container</code> instance processing requests. */    private Container container=null;    /** The "enable DNS lookups" flag. */    private boolean enableLookups=false;    /** The <code>ServerSocketFactory</code> used by this connector. */    private ServerSocketFactory factory=null;    /** The redirect port value for SSL requests. */    private int redirectPort=443;    /** The request scheme value. */    private String scheme="warp";    /** The secure flag of this <code>Connector</code>. */    private boolean secure=false;    /** The <code>Service</code> we are associated with (if any). */    private Service service=null;    /** Descriptive information of this <code>Connector</code>. */    private String info=null;    /** The address we need to bind to. */    private String address=null;    /** The port we need to bind to. */    private int port=8008;    /** The server socket backlog length. */    private int acceptCount=10;    /** The server appBase for hosts created via WARP. */    private String appBase="webapps";    /** The debug level. */    private int debug=0;    /* -------------------------------------------------------------------- */    /* Lifecycle variables */    /** The lifecycle event support for this component. */    private LifecycleSupport lifecycle=new LifecycleSupport(this);    /** The "initialized" flag. */    private boolean initialized=false;    /** The "started" flag. */    private boolean started=false;    /* ==================================================================== */    /* Constructor                                                          */    /* ==================================================================== */    /**     * Construct a new instance of a <code>WarpConnector</code>.     */    public WarpConnector() {        super();        this.logger=new WarpLogger(this);        this.uniqueId=new Random().nextInt();        if (Constants.DEBUG)            logger.debug("Instance created (ID="+this.uniqueId+")");    }    /* ==================================================================== */    /* Bean methods                                                         */    /* ==================================================================== */    /**     * Return the <code>Container</code> instance which will process all     * requests received by this <code>Connector</code>.     */    public Container getContainer() {        return(this.container);    }    /**     * Set the <code>Container</code> instance which will process all requests     * received by this <code>Connector</code>.     *     * @param container The new Container to use     */    public void setContainer(Container container) {        this.container=container;        this.logger.setContainer(container);        if (Constants.DEBUG) {            if (container==null) logger.debug("Setting null container");            else logger.debug("Setting container "+container.getClass());        }    }    /**     * 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;        if (Constants.DEBUG) logger.debug("Setting lookup to "+enableLookups);    }    /**     * Return the <code>ServerSocketFactory</code> used by this     * <code>Connector</code> to generate <code>ServerSocket</code> instances.     */    public ServerSocketFactory getFactory() {        if (this.factory==null) {            synchronized(this) {                if (Constants.DEBUG) logger.debug("Creating factory");                this.factory=new DefaultServerSocketFactory();            }        }        return(this.factory);    }    /**     * Set the <code>ServerSocketFactory</code> used by this     * <code>Connector</code> to generate <code>ServerSocket</code> instances.     *     * @param factory The new server socket factory     */    public void setFactory(ServerSocketFactory factory) {        if (factory==null) throw new NullPointerException();        this.factory=factory;        if (Constants.DEBUG)            logger.debug("Setting factory "+factory.getClass().getName());    }    /**     * 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) {        if ((redirectPort<1) || (redirectPort>65535))            throw new IllegalArgumentException("Invalid port "+redirectPort);        this.redirectPort=redirectPort;        if (Constants.DEBUG)            logger.debug("Setting redirection port to "+redirectPort);    }    /**     * Return the scheme that will be assigned to requests received     * through this connector.  Default value is "warp".     */    public String getScheme() {        return(this.scheme);    }    /**     * Set the scheme that will be assigned to requests received through     * this connector.     *     * @param scheme The new scheme     */    public void setScheme(String scheme) {        if (scheme==null) throw new NullPointerException();        this.scheme=scheme;        if (Constants.DEBUG) logger.debug("Setting scheme to "+scheme);    }    /**     * Return the secure connection flag that will be assigned to requests     * received through this connector.  Default value is "false".     */    public boolean getSecure() {        return(this.secure);    }    /**     * Set the secure connection flag that will be assigned to requests     * received through this connector.     *     * @param secure The new secure connection flag     */    public void setSecure(boolean secure) {        this.secure=secure;        if (Constants.DEBUG) logger.debug("Setting secure to "+secure);    }    /**     * 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).

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -