Return-Path: Mailing-List: contact tomcat-dev-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list tomcat-dev@jakarta.apache.org Received: (qmail 36035 invoked by uid 500); 2 Jun 2000 11:12:36 -0000 Delivered-To: apmail-jakarta-tomcat-cvs@apache.org Received: (qmail 36030 invoked by uid 1115); 2 Jun 2000 11:12:36 -0000 Date: 2 Jun 2000 11:12:35 -0000 Message-ID: <20000602111235.36029.qmail@locus.apache.org> From: shachor@locus.apache.org To: jakarta-tomcat-cvs@apache.org Subject: cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/task IISConfig.java NSConfig.java ApacheConfig.java shachor 00/06/02 04:12:35 Modified: src/share/org/apache/tomcat/task ApacheConfig.java Added: src/share/org/apache/tomcat/task IISConfig.java NSConfig.java Log: Auto generation of configuration files for Apache - mod_jk.config IIS - .reg file for Tomcat registry entries and uri to worker map Netscape - The mising portions in obj.conf Revision Changes Path 1.10 +7 -61 jakarta-tomcat/src/share/org/apache/tomcat/task/ApacheConfig.java Index: ApacheConfig.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/task/ApacheConfig.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- ApacheConfig.java 2000/06/01 13:46:46 1.9 +++ ApacheConfig.java 2000/06/02 11:12:34 1.10 @@ -76,8 +76,7 @@ public static final String APACHE_CONFIG = "/conf/tomcat-apache.conf"; public static final String MOD_JK_CONFIG = "/conf/mod_jk.conf"; public static final String WORKERS_CONFIG = "/conf/workers.properties"; - public static final String URL_WORKERS_MAP_CONFIG = "/conf/uriworkermap.properties"; - public static final String JK_LOG_LOCATION = "/log/mod_jk.log"; + public static final String JK_LOG_LOCATION = "/logs/mod_jk.log"; public ApacheConfig() { } @@ -95,14 +94,8 @@ FileWriter configW=new FileWriter(tomcatHome + APACHE_CONFIG); PrintWriter pw=new PrintWriter(configW); - PrintWriter mod_jk = new PrintWriter(new FileWriter(tomcatHome + MOD_JK_CONFIG)); - PrintWriter uri_worker = new PrintWriter(new FileWriter(tomcatHome + URL_WORKERS_MAP_CONFIG)); + PrintWriter mod_jk = new PrintWriter(new FileWriter(tomcatHome + MOD_JK_CONFIG + "-auto")); - uri_worker.println("###################################################################"); - uri_worker.println("# Auto generated configuration. Dated: " + new Date()); - uri_worker.println("###################################################################"); - uri_worker.println(); - mod_jk.println("###################################################################"); mod_jk.println("# Auto generated configuration. Dated: " + new Date()); mod_jk.println("###################################################################"); @@ -116,7 +109,7 @@ mod_jk.println("LoadModule jk_module modules/mod_jk.dll"); mod_jk.println(); mod_jk.println("JkWorkersFile \"" + new File(tomcatHome, WORKERS_CONFIG).toString().replace('\\', '/') + "\""); - mod_jk.println("JkWorkersFile \"" + new File(tomcatHome, JK_LOG_LOCATION).toString().replace('\\', '/') + "\""); + mod_jk.println("JkLogFile \"" + new File(tomcatHome, JK_LOG_LOCATION).toString().replace('\\', '/') + "\""); } else { // XXX XXX change it to mod_jserv_${os.name}.so, put all so in tomcat // home @@ -124,7 +117,7 @@ mod_jk.println("LoadModule jk_module libexec/mod_jk.so"); mod_jk.println(); mod_jk.println("JkWorkersFile " + new File(tomcatHome, WORKERS_CONFIG)); - mod_jk.println("JkWorkersFile " + new File(tomcatHome, JK_LOG_LOCATION)); + mod_jk.println("JkLogFile " + new File(tomcatHome, JK_LOG_LOCATION)); } @@ -157,14 +150,6 @@ mod_jk.println("JkMount /servlet/* ajp12"); mod_jk.println(); - uri_worker.println("#"); - uri_worker.println("# Root context mounts for Tomcat"); - uri_worker.println("#"); - uri_worker.println("/servlet/*=ajp12"); - uri_worker.println("/*.jsp=ajp12"); - uri_worker.println(); - - // Set up contexts // XXX deal with Virtual host configuration !!!! Enumeration enum = cm.getContexts(); @@ -226,7 +211,7 @@ mod_jk.println("#"); mod_jk.println("# The following line mounts all JSP files and the /servlet/ uri to tomcat"); mod_jk.println("#"); - mod_jk.println("JkMount " + path +"/servlet ajp12"); + mod_jk.println("JkMount " + path +"/servlet/* ajp12"); mod_jk.println("JkMount " + path +"/*.jsp ajp12"); @@ -246,32 +231,6 @@ mod_jk.println("#######################################################"); mod_jk.println(); - // Static files will be served by Apache - uri_worker.println("#########################################################"); - uri_worker.println("# Auto configuration for the " + path + " context starts."); - uri_worker.println("#########################################################"); - uri_worker.println(); - - - uri_worker.println("#"); - uri_worker.println("# The following line mounts all JSP file and the /servlet/ uri to tomcat"); - uri_worker.println("#"); - uri_worker.println(path +"/servlet/*=ajp12"); - uri_worker.println(path +"/*.jsp=ajp12"); - uri_worker.println(); - - uri_worker.println("#######################################################"); - uri_worker.println("# Auto configuration for the " + path + " context ends."); - uri_worker.println("#######################################################"); - uri_worker.println(); - - // SetHandler broken in jserv ( no zone is sent ) - // pw.println(""); - // pw.println(" AllowOverride None"); - // pw.println(" SetHandler jserv-servlet"); - // pw.println(""); - // pw.println(); - // XXX check security if( false ) { pw.println(""); @@ -283,18 +242,9 @@ pw.println(""); } - // SetHandler broken in jserv ( no zone is sent ) - // pw.println(""); - // pw.println(" AllowOverride None"); - // pw.println(" AddHandler jserv-servlet .jsp"); - // pw.println(" Options Indexes"); - // pw.println(""); + // XXX ErrorDocument - // XXX ErrorDocument - // XXX mime types - AddEncoding, AddLanguage, TypesConfig - - } else { // the root context // XXX use a non-conflicting name @@ -304,16 +254,12 @@ } pw.close(); - mod_jk.close(); - uri_worker.close(); - + mod_jk.close(); } catch( Exception ex ) { // ex.printStackTrace(); //throw new TomcatException( "Error generating Apache config", ex ); System.out.println("Error generating automatic apache configuration " + ex); ex.printStackTrace(System.out); } - } - } 1.1 jakarta-tomcat/src/share/org/apache/tomcat/task/IISConfig.java Index: IISConfig.java =================================================================== /* * ==================================================================== * * 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 * . * * [Additional notices, if required by prior licensing conditions] * */ package org.apache.tomcat.task; import org.apache.tomcat.core.*; import org.apache.tomcat.util.*; import java.io.*; import java.net.*; import java.util.*; import javax.servlet.http.*; /** * Used by ContextManager to generate automatic IIS configurations * * @author Gal Shachor shachor@il.ibm.com */ public class IISConfig { // implements XXX public static final String WORKERS_CONFIG = "/conf/workers.properties"; public static final String URL_WORKERS_MAP_CONFIG = "/conf/uriworkermap.properties"; public static final String JK_LOG_LOCATION = "/logs/iis_redirect.log"; public static final String IIS_REG_FILE = "/conf/iis_redirect.reg"; public IISConfig() { } public void execute(ContextManager cm) throws TomcatException { try { String tomcatHome = cm.getHome(); PrintWriter regfile = new PrintWriter(new FileWriter(tomcatHome + IIS_REG_FILE + "-auto")); PrintWriter uri_worker = new PrintWriter(new FileWriter(tomcatHome + URL_WORKERS_MAP_CONFIG + "-auto")); regfile.println("REGEDIT4"); regfile.println(); regfile.println("[HKEY_LOCAL_MACHINE\\SOFTWARE\\Apache Software Foundation\\Jakarta Isapi Redirector\\1.0]"); regfile.println("\"extension_uri\"=\"/jakarta/isapi_redirect.dll\""); regfile.println("\"log_file\"=\"" + dubleSlash(new File(tomcatHome, JK_LOG_LOCATION).toString()) +"\""); regfile.println("\"log_level\"=\"debug\""); regfile.println("\"worker_file\"=\"" + dubleSlash(new File(tomcatHome, WORKERS_CONFIG).toString()) +"\""); regfile.println("\"worker_mount_file\"=\"" + dubleSlash(new File(tomcatHome, URL_WORKERS_MAP_CONFIG).toString()) +"\""); uri_worker.println("###################################################################"); uri_worker.println("# Auto generated configuration. Dated: " + new Date()); uri_worker.println("###################################################################"); uri_worker.println(); uri_worker.println("#"); uri_worker.println("# Default worker to be used through our mappings"); uri_worker.println("#"); uri_worker.println("default.worker=ajp12"); uri_worker.println(); uri_worker.println("#"); uri_worker.println("# Root context mounts for Tomcat"); uri_worker.println("#"); uri_worker.println("/servlet/*=$(default.worker)"); uri_worker.println("/*.jsp=$(default.worker)"); uri_worker.println(); // Set up contexts // XXX deal with Virtual host configuration !!!! Enumeration enum = cm.getContexts(); while (enum.hasMoreElements()) { Context context = (Context)enum.nextElement(); String path = context.getPath(); String vhost = context.getHost(); if(vhost != null) { // Vhosts are not supported yet for IIS continue; } if(path.length() > 1) { // Static files will be served by Apache uri_worker.println("#########################################################"); uri_worker.println("# Auto configuration for the " + path + " context starts."); uri_worker.println("#########################################################"); uri_worker.println(); uri_worker.println("#"); uri_worker.println("# The following line mounts all JSP file and the /servlet/ uri to tomcat"); uri_worker.println("#"); uri_worker.println(path +"/servlet/*=$(default.worker)"); uri_worker.println(path +"/*.jsp=$(default.worker)"); uri_worker.println(); uri_worker.println("#"); uri_worker.println("# If you want tomcat to serve all the resources (including static) that"); uri_worker.println("# are part of the " + path + " context, uncomment the following line"); uri_worker.println("#"); uri_worker.println("# " + path +"/*=$(default.worker)"); uri_worker.println("#######################################################"); uri_worker.println("# Auto configuration for the " + path + " context ends."); uri_worker.println("#######################################################"); uri_worker.println(); } } regfile.close(); uri_worker.close(); } catch(Exception ex) { System.out.println("Error generating automatic IIS configuration " + ex); ex.printStackTrace(System.out); } } protected String dubleSlash(String in) { StringBuffer sb = new StringBuffer(); for(int i = 0 ; i < in.length() ; i++) { char ch = in.charAt(i); if('\\' == ch) { sb.append("\\\\"); } else { sb.append(ch); } } return sb.toString(); } } 1.1 jakarta-tomcat/src/share/org/apache/tomcat/task/NSConfig.java Index: NSConfig.java =================================================================== /* * ==================================================================== * * 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 * . * * [Additional notices, if required by prior licensing conditions] * */ package org.apache.tomcat.task; import org.apache.tomcat.core.*; import org.apache.tomcat.util.*; import java.io.*; import java.net.*; import java.util.*; import javax.servlet.http.*; /** * Used by ContextManager to generate automatic Netscape configurations * * @author Gal Shachor shachor@il.ibm.com */ public class NSConfig { // implements XXX public static final String WORKERS_CONFIG = "/conf/workers.properties"; public static final String NS_CONFIG = "/conf/obj.conf"; public static final String JK_LOG_LOCATION = "/logs/netscape_redirect.log"; public NSConfig() { } public void execute(ContextManager cm) throws TomcatException { try { String tomcatHome = cm.getHome(); PrintWriter objfile = new PrintWriter(new FileWriter(tomcatHome + NS_CONFIG + "-auto")); objfile.println("###################################################################"); objfile.println("# Auto generated configuration. Dated: " + new Date()); objfile.println("###################################################################"); objfile.println(); objfile.println("#"); objfile.println("# You will need to merge the content of this file with your "); objfile.println("# regular obj.conf and then restart (=stop + start) your Netscape server. "); objfile.println("#"); objfile.println(); objfile.println("#"); objfile.println("# Loading the redirector into your server"); objfile.println("#"); objfile.println(); objfile.println("Init fn=\"load-modules\" funcs=\"jk_init,jk_service\" shlib=\"\""); objfile.println("Init fn=\"jk_init\" worker_file=\"" + new File(tomcatHome, WORKERS_CONFIG).toString().replace('\\', '/') + "\" log_level=\"debug\" log_file=\"" + new File(tomcatHome, JK_LOG_LOCATION).toString().replace('\\', '/') + "\""); objfile.println(); objfile.println(""); objfile.println("#"); objfile.println("# Redirecting the root context requests to tomcat."); objfile.println("#"); objfile.println("NameTrans fn=\"assign-name\" from=\"/servlet/*\" name=\"servlet\""); objfile.println("NameTrans fn=\"assign-name\" from=\"/*.jsp\" name=\"servlet\""); objfile.println(); // Set up contexts // XXX deal with Virtual host configuration !!!! Enumeration enum = cm.getContexts(); while (enum.hasMoreElements()) { Context context = (Context)enum.nextElement(); String path = context.getPath(); String vhost = context.getHost(); if(vhost != null) { // Vhosts are not supported yet for IIS continue; } if(path.length() > 1) { // Calculate the absolute path of the document base String docBase = context.getDocBase(); if (!FileUtil.isAbsolute(docBase)) docBase = tomcatHome + "/" + docBase; docBase = FileUtil.patch(docBase).replace('\\', '/'); // Static files will be served by Apache objfile.println("#########################################################"); objfile.println("# Auto configuration for the " + path + " context starts."); objfile.println("#########################################################"); objfile.println(); objfile.println("#"); objfile.println("# The following line mounts all JSP file and the /servlet/ uri to tomcat"); objfile.println("#"); objfile.println("NameTrans fn=\"assign-name\" from=\"" + path + "/servlet/*\" name=\"servlet\""); objfile.println("NameTrans fn=\"assign-name\" from=\"" + path + "/*.jsp\" name=\"servlet\""); objfile.println("NameTrans fn=pfx2dir from=\"" + path + "\" dir=\"" + docBase + "\""); objfile.println(); objfile.println("#######################################################"); objfile.println("# Auto configuration for the " + path + " context ends."); objfile.println("#######################################################"); objfile.println(); } } objfile.println("#######################################################"); objfile.println("# Protecting the web inf directory."); objfile.println("#######################################################"); objfile.println("PathCheck fn=\"deny-existence\" path=\"*/WEB-INF/*\""); objfile.println(); objfile.println(""); objfile.println(); objfile.println("#######################################################"); objfile.println("# New object to execute your servlet requests."); objfile.println("#######################################################"); objfile.println(""); objfile.println("ObjectType fn=force-type type=text/html"); objfile.println("Service fn=\"jk_service\" worker=\"ajp12\" path=\"/*\""); objfile.println(""); objfile.println(); objfile.close(); } catch(Exception ex) { System.out.println("Error generating automatic Netscape configuration " + ex); ex.printStackTrace(System.out); } } }