patrickl 2002/07/31 21:59:24 Modified: catalina build.xml catalina/src/bin shutdown.bat shutdown.sh startup.bat startup.sh catalina/src/conf catalina.policy Added: catalina/src/bin catalina.xml catalina/src/share/org/apache/catalina/startup CatalinaLaunchFilter.java Removed: catalina/src/bin catalina.sh Log: Converted the catalina.[sh|bat] scripts to use commons-launcher. Also, since all of the scripting options in the catalina.[sh|bat] scripts to catalina.xml, the catalina.[sh|bat] scripts are no longer needed and have been removed. Revision Changes Path 1.7 +3 -3 jakarta-tomcat-catalina/catalina/build.xml Index: build.xml =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/build.xml,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- build.xml 30 Jul 2002 20:03:08 -0000 1.6 +++ build.xml 1 Aug 2002 04:59:24 -0000 1.7 @@ -700,6 +700,7 @@ <target name="build-static" depends="flags,flags.display,build-prepare,copy-activation.jar,copy-dbcp.jar,copy-jaas.jar,copy-jdbc20ext.jar,copy-jmx.jar,copy-jndi.jar,copy-jsse.jar,copy-jta.jar,copy-ldap.jar,copy-modeler.jar,copy-pool.jar,copy-tyrex.jar,copy-xerces2.jars"> <!-- Copy the launcher classes --> + <copy todir="${catalina.build}/common/lib" file="${ant.jar}"/> <copy todir="${catalina.build}/bin" file="${commons-daemon.jar}"/> <copy todir="${catalina.build}/bin" file="${commons-daemon-launcher.jar}"/> <copy todir="${catalina.build}/bin" file="${commons-daemon-launcher-bootstrap.class}"/> @@ -710,7 +711,6 @@ </copy> <fixcrlf srcdir="${catalina.build}/bin" includes="*.sh" eol="lf"/> <fixcrlf srcdir="${catalina.build}/bin" includes="*.bat" eol="crlf"/> - <chmod perm="+x" file="${catalina.build}/bin/catalina.sh"/> <chmod perm="+x" file="${catalina.build}/bin/digest.sh"/> <chmod perm="+x" file="${catalina.build}/bin/startup.sh"/> <chmod perm="+x" file="${catalina.build}/bin/shutdown.sh"/> @@ -999,7 +999,6 @@ </copy> <fixcrlf srcdir="${catalina.deploy}/bin" includes="*.sh" eol="lf"/> <fixcrlf srcdir="${catalina.deploy}/bin" includes="*.bat" eol="crlf"/> - <chmod perm="+x" file="${catalina.deploy}/bin/catalina.sh"/> <chmod perm="+x" file="${catalina.deploy}/bin/digest.sh"/> <chmod perm="+x" file="${catalina.deploy}/bin/startup.sh"/> <chmod perm="+x" file="${catalina.deploy}/bin/shutdown.sh"/> @@ -1041,6 +1040,7 @@ <fileset dir="${catalina.build}/server/classes"> <include name="org/apache/catalina/startup/Bootstrap.class" /> <include name="org/apache/catalina/startup/BootstrapService.class" /> + <include name="org/apache/catalina/startup/CatalinaLaunchFilter.class" /> <include name="org/apache/catalina/startup/ClassLoaderFactory.class" /> <include name="org/apache/catalina/startup/Tool.class" /> <include name="org/apache/catalina/loader/StandardClassLoader*.class" /> @@ -1058,6 +1058,7 @@ <exclude name="org/apache/naming/**" /> <exclude name="org/apache/catalina/startup/Bootstrap.class" /> <exclude name="org/apache/catalina/startup/BootstrapService.class" /> + <exclude name="org/apache/catalina/startup/CatalinaLaunchFilter.class" /> <exclude name="org/apache/catalina/startup/ClassLoaderFactory.class" /> <exclude name="org/apache/catalina/startup/Tool.class" /> <exclude name="org/apache/catalina/loader/StandardClassLoader*.class" /> @@ -1174,7 +1175,6 @@ </copy> <fixcrlf srcdir="${catalina.dist}/bin" includes="*.sh" eol="lf"/> <fixcrlf srcdir="${catalina.dist}/bin" includes="*.bat" eol="crlf"/> - <chmod perm="+x" file="${catalina.dist}/bin/catalina.sh"/> <chmod perm="+x" file="${catalina.dist}/bin/digest.sh"/> <chmod perm="+x" file="${catalina.dist}/bin/startup.sh"/> <chmod perm="+x" file="${catalina.dist}/bin/shutdown.sh"/> 1.2 +21 -22 jakarta-tomcat-catalina/catalina/src/bin/shutdown.bat Index: shutdown.bat =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/bin/shutdown.bat,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- shutdown.bat 18 Jul 2002 16:48:14 -0000 1.1 +++ shutdown.bat 1 Aug 2002 04:59:24 -0000 1.2 @@ -1,33 +1,31 @@ @echo off if "%OS%" == "Windows_NT" setlocal + rem --------------------------------------------------------------------------- -rem Stop script for the CATALINA Server rem -rem $Id$ +rem Script for shutting down Catalina using the Launcher +rem rem --------------------------------------------------------------------------- -rem Guess CATALINA_HOME if not defined -if not "%CATALINA_HOME%" == "" goto gotHome -set CATALINA_HOME=. -if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome -set CATALINA_HOME=.. -:gotHome -if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome -echo The CATALINA_HOME environment variable is not defined correctly -echo This environment variable is needed to run this program -goto end -:okHome - -set EXECUTABLE=%CATALINA_HOME%\bin\catalina.bat +rem Get standard environment variables +set PRG=%0 +if exist %PRG%\..\setenv.bat goto gotCmdPath +rem %0 must have been found by DOS using the %PATH% so we assume that +rem setenv.bat will also be found in the %PATH% +call setenv.bat +goto doneSetenv +:gotCmdPath +call %PRG%\..\setenv.bat +:doneSetenv -rem Check that target executable exists -if exist "%EXECUTABLE%" goto okExec -echo Cannot find %EXECUTABLE% -echo This file is needed to run this program +rem Make sure prerequisite environment variables are set +if not "%JAVA_HOME%" == "" goto gotJavaHome +echo The JAVA_HOME environment variable is not defined +echo This environment variable is needed to run this program goto end -:okExec +:gotJavaHome -rem Get remaining unshifted command line arguments and save them in the +rem Get command line arguments and save them with the proper quoting set CMD_LINE_ARGS= :setArgs if ""%1""=="""" goto doneSetArgs @@ -36,6 +34,7 @@ goto setArgs :doneSetArgs -call "%EXECUTABLE%" stop %CMD_LINE_ARGS% +rem Execute the Launcher using the "catalina" target +"%JAVA_HOME%\bin\java.exe" -classpath %PRG%\..;"%PATH%" LauncherBootstrap -launchfile catalina.xml -verbose catalina %CMD_LINE_ARGS% stop :end 1.2 +11 -13 jakarta-tomcat-catalina/catalina/src/bin/shutdown.sh Index: shutdown.sh =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/bin/shutdown.sh,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- shutdown.sh 18 Jul 2002 16:48:14 -0000 1.1 +++ shutdown.sh 1 Aug 2002 04:59:24 -0000 1.2 @@ -1,14 +1,15 @@ #!/bin/sh + # ----------------------------------------------------------------------------- -# Stop script for the CATALINA Server # -# $Id$ +# Script for shutting down Catalina using the Launcher +# # ----------------------------------------------------------------------------- -# resolve links - $0 may be a softlink +# Resolve links - $0 may be a softlink PRG="$0" -while [ -h "$PRG" ] ; do +while [ -h "$PRG" ]; do ls=`ls -ld "$PRG"` link=`expr "$ls" : '.*-> \(.*\)$'` if expr "$link" : '.*/.*' > /dev/null; then @@ -17,15 +18,12 @@ PRG=`dirname "$PRG"`/"$link" fi done - -PRGDIR=`dirname "$PRG"` -EXECUTABLE=catalina.sh -# Check that target executable exists -if [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then - echo "Cannot find $PRGDIR/$EXECUTABLE" - echo "This file is needed to run this program" - exit 1 +# Get standard environment variables +PRGDIR=`dirname "$PRG"` +if [ -r "$PRGDIR"/setenv.sh ]; then + . "$PRGDIR"/setenv.sh fi -exec "$PRGDIR"/"$EXECUTABLE" stop "$@" +# Execute the Launcher using the "catalina" target +exec "$JAVA_HOME"/bin/java -classpath "$PRGDIR" LauncherBootstrap -launchfile catalina.xml -verbose catalina "$@" stop 1.2 +21 -22 jakarta-tomcat-catalina/catalina/src/bin/startup.bat Index: startup.bat =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/bin/startup.bat,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- startup.bat 18 Jul 2002 16:48:14 -0000 1.1 +++ startup.bat 1 Aug 2002 04:59:24 -0000 1.2 @@ -1,33 +1,31 @@ @echo off if "%OS%" == "Windows_NT" setlocal + rem --------------------------------------------------------------------------- -rem Start script for the CATALINA Server rem -rem $Id$ +rem Script for starting Catalina using the Launcher +rem rem --------------------------------------------------------------------------- -rem Guess CATALINA_HOME if not defined -if not "%CATALINA_HOME%" == "" goto gotHome -set CATALINA_HOME=. -if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome -set CATALINA_HOME=.. -:gotHome -if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome -echo The CATALINA_HOME environment variable is not defined correctly -echo This environment variable is needed to run this program -goto end -:okHome - -set EXECUTABLE=%CATALINA_HOME%\bin\catalina.bat +rem Get standard environment variables +set PRG=%0 +if exist %PRG%\..\setenv.bat goto gotCmdPath +rem %0 must have been found by DOS using the %PATH% so we assume that +rem setenv.bat will also be found in the %PATH% +call setenv.bat +goto doneSetenv +:gotCmdPath +call %PRG%\..\setenv.bat +:doneSetenv -rem Check that target executable exists -if exist "%EXECUTABLE%" goto okExec -echo Cannot find %EXECUTABLE% -echo This file is needed to run this program +rem Make sure prerequisite environment variables are set +if not "%JAVA_HOME%" == "" goto gotJavaHome +echo The JAVA_HOME environment variable is not defined +echo This environment variable is needed to run this program goto end -:okExec +:gotJavaHome -rem Get remaining unshifted command line arguments and save them in the +rem Get command line arguments and save them with the proper quoting set CMD_LINE_ARGS= :setArgs if ""%1""=="""" goto doneSetArgs @@ -36,6 +34,7 @@ goto setArgs :doneSetArgs -call "%EXECUTABLE%" start %CMD_LINE_ARGS% +rem Execute the Launcher using the "catalina" target +"%JAVA_HOME%\bin\java.exe" -classpath %PRG%\..;"%PATH%" LauncherBootstrap -launchfile catalina.xml -verbose catalina %CMD_LINE_ARGS% start :end 1.2 +11 -13 jakarta-tomcat-catalina/catalina/src/bin/startup.sh Index: startup.sh =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/bin/startup.sh,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- startup.sh 18 Jul 2002 16:48:14 -0000 1.1 +++ startup.sh 1 Aug 2002 04:59:24 -0000 1.2 @@ -1,14 +1,15 @@ #!/bin/sh + # ----------------------------------------------------------------------------- -# Start Script for the CATALINA Server # -# $Id$ +# Script for starting Catalina using the Launcher +# # ----------------------------------------------------------------------------- -# resolve links - $0 may be a softlink +# Resolve links - $0 may be a softlink PRG="$0" -while [ -h "$PRG" ] ; do +while [ -h "$PRG" ]; do ls=`ls -ld "$PRG"` link=`expr "$ls" : '.*-> \(.*\)$'` if expr "$link" : '.*/.*' > /dev/null; then @@ -17,15 +18,12 @@ PRG=`dirname "$PRG"`/"$link" fi done - -PRGDIR=`dirname "$PRG"` -EXECUTABLE=catalina.sh -# Check that target executable exists -if [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then - echo "Cannot find $PRGDIR/$EXECUTABLE" - echo "This file is needed to run this program" - exit 1 +# Get standard environment variables +PRGDIR=`dirname "$PRG"` +if [ -r "$PRGDIR"/setenv.sh ]; then + . "$PRGDIR"/setenv.sh fi -exec "$PRGDIR"/"$EXECUTABLE" start "$@" +# Execute the Launcher using the "catalina" target +exec "$JAVA_HOME"/bin/java -classpath "$PRGDIR" LauncherBootstrap -launchfile catalina.xml -verbose catalina "$@" start 1.1 jakarta-tomcat-catalina/catalina/src/bin/catalina.xml Index: catalina.xml =================================================================== <!-- XML file for launching Catalina applications using the Launcher. To run any of the applications in the JDB debugger, execute the Launcher with a "-Ddebug=true" argument. To run any of the applications in JPDA mode, execute the Launcher with a "-Djpda=true" argument. --> <project name="Catalina Launcher" default="catalina" basedir="."> <!-- Set the application home to the parent directory of this directory --> <property name="app.home" location="${basedir}/.."/> <property name="bootstrap.jar" location="${app.home}/bin/bootstrap.jar"/> <!-- Import the user's custom properties --> <property file="${app.home}/bin/catalina.properties"/> <!-- Set user configurable properties --> <property name="catalina.base" location="${app.home}"/> <property name="catalina.tmpdir" location="${app.home}/temp"/> <property name="catalina.out" location="${app.home}/logs/catalina.out"/> <property name="catalina.policy" location="${app.home}/conf/catalina.policy"/> <property name="catalina.jvm.args" value=""/> <property name="catalina.source.path" value="${app.home}/../../jakarta-servletapi-5/src/share:${app.home}/../../jakarta-tomcat-jasper/jasper2/src/share:${app.home}/../../jakarta-tomcat-connectors/coyote/src/java:${app.home}/../../jakarta-tomcat-catalina/catalina/src/share"/> <!-- Build the classpath relative to the application home --> <path id="base.class.path"> <pathelement location="${bootstrap.jar}"/> </path> <!-- Build the sysproperties relative to the application home --> <syspropertyset id="base.sys.properties"> <sysproperty key="java.endorsed.dirs" file="${app.home}/common/endorsed"/> <sysproperty key="java.io.tmpdir" file="${catalina.tmpdir}"/> <sysproperty key="catalina.home" file="${app.home}"/> <sysproperty key="catalina.base" file="${catalina.base}"/> </syspropertyset> <!-- Build the standard jvmargs --> <jvmargset id="base.jvm.args"> <jvmarg line="${catalina.jvm.args}"/> <jvmarg value="-Xdebug" if="jpda.settings"/> <jvmarg value="-Xrunjdwp:${jpda.settings}" if="jpda.settings"/> <jvmarg value="-sourcepath" if="jdb"/> <jvmarg path="${catalina.source.path}" if="jdb"/> </jvmargset> <!-- Target that sets JDB properties when the "debug" property is set --> <target name="setjdb" description="Set JDB properties" if="debug"> <property name="jdb" value="true"/> </target> <!-- Target that sets JPDA properties when the "jpda" property is set --> <target name="setjpda" description="Set JPDA properties" if="jpda"> <condition property="jpda.transport" value="dt_shmem"> <os family="windows"/> </condition> <condition property="jpda.transport" value="dt_socket"> <not> <os family="windows"/> </not> </condition> <condition property="jpda.address" value="jdbconn"> <equals arg1="${jpda.transport}" arg2="dt_shmem"/> </condition> <condition property="jpda.address" value="8000"> <not> <equals arg1="${jpda.transport}" arg2="dt_shmem"/> </not> </condition> <property name="jpda.suspend" value="y"/> <property name="jpda.settings" value="transport=${jpda.transport},address=${jpda.address},server=y,suspend=${jpda.suspend}"/> </target> <!-- Target that executes Catalina --> <target name="catalina" description="Execute Catalina" depends="setjdb,setjpda"> <!-- Set default title for minimized window --> <property name="catalina.window.title" value="Catalina"/> <!-- Launch Catalina. Note that the "filterclassname" attribute will force the "waitforchild" attribute to "true" if any invalid arguments are used or if "start" is not the last argument. --> <launch classname="org.apache.catalina.startup.Bootstrap" waitforchild="${wait}" debug="${jdb}" print="${print}" filterclassname="org.apache.catalina.startup.CatalinaLaunchFilter" filterclasspath="${bootstrap.jar}" usesystemin="false" requiretools="true" redirectoutput="true" output="${catalina.out}" displayMinimizedWindow="true" minimizedWindowTitle="${catalina.window.title}"> <jvmargset refid="base.jvm.args"/> <syspropertyset refid="base.sys.properties"/> <sysproperty key="java.security.manager" value="" if="security"/> <sysproperty key="java.security.policy" value="=${catalina.policy}" if="security"/> <classpath refid="base.class.path"/> </launch> </target> </project> 1.3 +6 -1 jakarta-tomcat-catalina/catalina/src/conf/catalina.policy Index: catalina.policy =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/conf/catalina.policy,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- catalina.policy 30 Jul 2002 03:58:27 -0000 1.2 +++ catalina.policy 1 Aug 2002 04:59:24 -0000 1.3 @@ -40,6 +40,11 @@ // ========== CATALINA CODE PERMISSIONS ======================================= +// These permissions apply to the launcher code +grant codeBase "file:${catalina.home}/bin/commons-launcher.jar" { + permission java.security.AllPermission; +}; + // These permissions apply to the server startup code grant codeBase "file:${catalina.home}/bin/bootstrap.jar" { permission java.security.AllPermission; 1.1 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/CatalinaLaunchFilter.java Index: CatalinaLaunchFilter.java =================================================================== /* * $Header: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/CatalinaLaunchFilter.java,v 1.1 2002/08/01 04:59:24 patrickl Exp $ * $Revision: 1.1 $ * $Date: 2002/08/01 04:59:24 $ * * ==================================================================== * * 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 [EMAIL PROTECTED] * * 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.catalina.startup; import java.util.ArrayList; import org.apache.commons.launcher.LaunchCommand; import org.apache.commons.launcher.LaunchFilter; import org.apache.tools.ant.BuildException; /** * This class implements the LaunchFilter interface. This class is designed to * unconditionally force the "waitforchild" attribute for certain Catalina * applications to true. * * @author Patrick Luby */ public class CatalinaLaunchFilter implements LaunchFilter { //----------------------------------------------------------- Static Fields /** * The Catalina bootstrap class name. */ private static String CATALINA_BOOTSTRAP_CLASS_NAME = "org.apache.catalina.startup.Bootstrap"; //----------------------------------------------------------------- Methods /** * This method allows dynamic configuration and error checking of the * attributes and nested elements in a "launch" task that is launching a * Catalina application. This method evaluates the nested command line * arguments and, depending on which class is specified in the task's * "classname" attribute, may force the application to run * in the foreground by forcing the "waitforchild" attribute to "true". * * @param launchCommand a configured instance of the {@link LaunchTask} * class * @throws BuildException if any errors occur */ public void filter(LaunchCommand launchCommand) throws BuildException { // Get attributes String mainClassName = launchCommand.getClassname(); boolean waitForChild = launchCommand.getWaitforchild(); ArrayList argsList = launchCommand.getArgs(); String[] args = (String[])argsList.toArray(new String[argsList.size()]); // Evaluate main class if (CatalinaLaunchFilter.CATALINA_BOOTSTRAP_CLASS_NAME.equals(mainClassName)) { // If "start" is not the last argument, make "waitforchild" true if (args.length == 0 || !"start".equals(args[args.length - 1])) { launchCommand.setWaitforchild(true); return; } // If "start" is the last argument, make sure that all of the // preceding arguments are OK for running in the background for (int i = 0; i < args.length - 1; i++) { if ("-config".equals(args[i])) { // Skip next argument since it should be a file if (args.length > i + 1) { i++; } else { launchCommand.setWaitforchild(true); return; } } else if ("-debug".equals(args[i])) { // Do nothing } else if ("-nonaming".equals(args[i])) { // Do nothing } else { launchCommand.setWaitforchild(true); return; } } } } }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>