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

📄 basejkconfig.java

📁 Tomcat 4.1与WebServer集成组件的源代码包.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * ==================================================================== * * 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.ajp.tomcat4.config;import org.apache.catalina.*;import java.io.*;/**    Base class for automatic jk based configurations based on    the Tomcat server.xml settings and the war contexts    initialized during startup.    <p>    This config interceptor is enabled by inserting a Config    element in the <b>&lt;ContextManager&gt;</b> tag body inside    the server.xml file like so:    <pre>    * < ContextManager ... >    *   ...    *   <<b>???Config</b> <i>options</i> />    *   ...    * < /ContextManager >    </pre>    where <i>options</i> can include any of the following attributes:    <ul>     <li><b>configHome</b> - default parent directory for the following paths.                             If not set, this defaults to TOMCAT_HOME. Ignored                             whenever any of the following paths is absolute.                             </li>     <li><b>workersConfig</b> - path to workers.properties file used by                                 jk connector. If not set, defaults to                                "conf/jk/workers.properties".</li>     <li><b>jkLog</b> - path to log file to be used by jk connector.</li>     <li><b>jkDebug</b> - Loglevel setting.  May be debug, info, error, or emerg.                          If not set, defaults to emerg.</li>     <li><b>jkWorker</b> The desired worker.  Must be set to one of the workers                         defined in the workers.properties file. "ajp12", "ajp13"                         or "inprocess" are the workers found in the default                         workers.properties file. If not specified, defaults                         to "ajp13" if an Ajp13Interceptor is in use, otherwise                         it defaults to "ajp12".</li>     <li><b>forwardAll</b> - If true, forward all requests to Tomcat. This helps                             insure that all the behavior configured in the web.xml                             file functions correctly.  If false, let Apache serve                             static resources. The default is true.                             Warning: When false, some configuration in                             the web.xml may not be duplicated in Apache.                             Review the mod_jk conf file to see what                             configuration is actually being set in Apache.</li>     <li><b>noRoot</b> - If true, the root context is not mapped to                         Tomcat.  If false and forwardAll is true, all requests                         to the root context are mapped to Tomcat. If false and                         forwardAll is false, only JSP and servlets requests to                         the root context are mapped to Tomcat. When false,                         to correctly serve Tomcat's root context you may also                         need to modify the web server to point it's home                         directory to Tomcat's root context directory.                         Otherwise some content, such as the root index.html,                         may be served by the web server before the connector                         gets a chance to claim the request and pass it to Tomcat.                         The default is true.</li>    </ul>    <p>    @author Costin Manolache    @author Larry Isaacs    @author Bill Barker	@version $Revision: 1.3 $ */public class BaseJkConfig  implements LifecycleListener {    protected int debug=0;    protected File configHome = null;    protected File workersConfig = null;    protected File jkLog = null;    protected String jkDebug="emerg";    protected String jkWorker = "ajp13";    protected boolean noRoot=true;    protected boolean forwardAll=true;    protected String tomcatHome;    protected boolean regenerate=false;    protected boolean append=false;    // -------------------- Tomcat callbacks --------------------    // Auto-config should be able to react to dynamic config changes,    // and regenerate the config.    /** Generate the configuration - only when the server is     *  completely initialized ( before starting )     */    public void lifecycleEvent(LifecycleEvent evt)    {	if(Lifecycle.START_EVENT.equals(evt.getType())) {	   execute( evt );	}    }    /** Generate configuration files.  Override with method to generate        web server specific configuration.     */    public void execute(LifecycleEvent evt)    {	initProperties();	PrintWriter mod_jk = null;	try {	    mod_jk = getWriter();	} catch(IOException iex) {	    log("Unable to open config file");	    return;	}	Lifecycle who = evt.getLifecycle();	if( who instanceof Server ) {	    executeServer((Server)who, mod_jk);	} else if ( who instanceof Host ) {	    executeHost((Host)who, mod_jk);	} else if( who instanceof Context ) {	    executeContext((Context)who, mod_jk);	}	mod_jk.close();    }    /** Generate configuration files.  Override with method to generate        web server specific configuration.     */    public void executeServer(Server svr, PrintWriter mod_jk) {	if(! append ) {	    if( ! generateJkHead(mod_jk) )		return;	    generateSSLConfig(mod_jk);	    generateJkTail(mod_jk);	}    }    /** Generate SSL options     */    protected void generateSSLConfig(PrintWriter mod_jk)    {    }    /** Generate general options     */    protected boolean generateJkHead(PrintWriter mod_jk)    {	return true;    }    /** Generate general options     */    protected void generateJkTail(PrintWriter mod_jk)    {    }    /** Generate Virtual Host start     */    protected void generateVhostHead(Host host, PrintWriter mod_jk) {    }    /** Generate Virtual Host end     */    protected void generateVhostTail(Host host, PrintWriter mod_jk) {    }    /** Generate configuration files.  Override with method to generate        web server specific configuration.     */    protected void executeEngine(Engine egn, PrintWriter mod_jk) {	Container [] children = egn.findChildren();	for(int ii=0; ii < children.length; ii++) {	    if( children[ii] instanceof Host ) {		executeHost((Host)children[ii], mod_jk);	    } else if( children[ii] instanceof Context ) {		executeContext((Context)children[ii], mod_jk);	    }	}    }    /** Generate configuration files.  Override with method to generate        web server specific configuration.     */    protected void executeHost(Host hst, PrintWriter mod_jk) {	generateVhostHead(hst, mod_jk);	Container [] children = hst.findChildren();	for(int ii=0; ii < children.length; ii++) {	    if(children[ii] instanceof Context) {		executeContext((Context)children[ii],mod_jk);	    }	}	generateVhostTail(hst, mod_jk);    }    /**        executes the ApacheConfig interceptor. This method generates apache        configuration files for use with  mod_jk.        <p>        @param <b>context</b> a Context object.	@param <b>mod_jk</b> Writer for output.    */    public void executeContext(Context context, PrintWriter mod_jk){	if(context.getPath().length() > 0 || ! noRoot ) {	    String docRoot = context.getServletContext().getRealPath("/");	    if( forwardAll || docRoot == null)		generateStupidMappings( context, mod_jk );	    else		generateContextMappings( context, mod_jk);	}    }    protected void generateStupidMappings(Context context, PrintWriter mod_jk){

⌨️ 快捷键说明

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