craigmcc 01/11/13 08:57:22 Modified: . build.xml catalina build.xml catalina/src/bin digest.bat digest.sh Added: catalina/src/bin tool-wrapper.bat tool-wrapper.sh catalina/src/share/org/apache/catalina/startup Tool.java Log: Add a wrapper for command-line tools that should operate in the same class loader context as Catalina, which builds a classloader from the standard directories. See the "digest.bat" and "digest.sh" files for an example of how this can be used. This will radically simplify the development of shell scripts for any future command line tools that we wish to include. Revision Changes Path 1.51 +2 -0 jakarta-tomcat-4.0/build.xml Index: build.xml =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/build.xml,v retrieving revision 1.50 retrieving revision 1.51 diff -u -r1.50 -r1.51 --- build.xml 2001/11/06 08:43:51 1.50 +++ build.xml 2001/11/13 16:57:21 1.51 @@ -307,6 +307,7 @@ <include name="${final.name}/bin/jspc.sh" /> <include name="${final.name}/bin/startup.sh" /> <include name="${final.name}/bin/shutdown.sh" /> + <include name="${final.name}/bin/tool-wrapper.sh" /> </tarfileset> <tarfileset dir="${tomcat.dist}"> <include name="${final.name}/**" /> @@ -316,6 +317,7 @@ <exclude name="${final.name}/bin/jspc.sh" /> <exclude name="${final.name}/bin/startup.sh" /> <exclude name="${final.name}/bin/shutdown.sh" /> + <exclude name="${final.name}/bin/tool-wrapper.sh" /> </tarfileset> </tar> <delete dir="${tomcat.dist}/${final.name}" /> 1.88 +6 -1 jakarta-tomcat-4.0/catalina/build.xml Index: build.xml =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/build.xml,v retrieving revision 1.87 retrieving revision 1.88 diff -u -r1.87 -r1.88 --- build.xml 2001/11/08 21:56:09 1.87 +++ build.xml 2001/11/13 16:57:21 1.88 @@ -593,6 +593,7 @@ <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"/> + <chmod perm="+x" file="${catalina.build}/bin/tool-wrapper.sh"/> <!-- Common Extensions --> <copy todir="${catalina.build}/common/lib" file="${servlet.jar}"/> @@ -791,9 +792,10 @@ <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.build}/bin/digest.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"/> + <chmod perm="+x" file="${catalina.deploy}/bin/tool-wrapper.sh"/> <!-- Common Extensions --> <copy todir="${catalina.deploy}/common/lib"> @@ -831,6 +833,7 @@ <include name="org/apache/catalina/startup/Bootstrap.class" /> <include name="org/apache/catalina/startup/BootstrapService.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" /> <include name="org/apache/catalina/loader/Extension.class" /> <include name="org/apache/catalina/loader/Reloader.class" /> @@ -847,6 +850,7 @@ <exclude name="org/apache/catalina/startup/Bootstrap.class" /> <exclude name="org/apache/catalina/startup/BootstrapService.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" /> <exclude name="org/apache/catalina/loader/Extension.class" /> <exclude name="org/apache/catalina/loader/Reloader.class" /> @@ -964,6 +968,7 @@ <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"/> + <chmod perm="+x" file="${catalina.dist}/bin/tool-wrapper.sh"/> <!-- Common Extensions --> <mkdir dir="${catalina.dist}/common/classes"/> 1.3 +7 -57 jakarta-tomcat-4.0/catalina/src/bin/digest.bat Index: digest.bat =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/bin/digest.bat,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- digest.bat 2001/09/10 20:12:58 1.2 +++ digest.bat 2001/11/13 16:57:21 1.3 @@ -1,6 +1,6 @@ @echo off rem --------------------------------------------------------------------------- -rem digest.bat - Digest password using the algorithm specificied +rem digest.bat - Digest password using the algorithm specified rem rem CATALINA_HOME (Optional) May point at your Catalina "build" directory. rem If not present, the current working directory is assumed. @@ -10,69 +10,19 @@ rem This script is assumed to run from the bin directory or have the rem CATALINA_HOME env variable set. rem -rem $Id: digest.bat,v 1.2 2001/09/10 20:12:58 ccain Exp $ +rem $Id: digest.bat,v 1.3 2001/11/13 16:57:21 craigmcc Exp $ rem --------------------------------------------------------------------------- - -rem ----- Save Environment Variables That May Change -------------------------- - set _CATALINA_HOME=%CATALINA_HOME% -set _CLASSPATH=%CLASSPATH% -set _CP=%CP% - -rem ----- Verify and Set Required Environment Variables ----------------------- - -if not "%JAVA_HOME%" == "" goto gotJavaHome -echo You must set JAVA_HOME to point at your Java Development Kit installation -goto cleanup -:gotJavaHome - if not "%CATALINA_HOME%" == "" goto gotCatalinaHome set CATALINA_HOME=. -if exist "%CATALINA_HOME%\server\lib\catalina.jar" goto okCatalinaHome +if exist "%CATALINA_HOME%\bin\tool-wrapper.bat" goto gotCatalinaHome set CATALINA_HOME=.. -:gotCatalinaHome -if exist "%CATALINA_HOME%\server\lib\catalina.jar" goto okCatalinaHome -echo Cannot find catalina.jar in %CATALINA_HOME%\server\lib -echo Please check your CATALINA_HOME setting or run this script from the bin directory +if exist "%CATALINA_HOME%\bin\tool-wrapper.bat" goto gotCatalinaHome +echo Unable to determine the value of CATALINA_HOME goto cleanup -:okCatalinaHome - - -rem ----- Prepare Appropriate Java Execution Commands ------------------------- - -set _RUNJAVA="%JAVA_HOME%\bin\java" - -rem ----- Set Up The Runtime Classpath ---------------------------------------- - -set CP=%CATALINA_HOME%\server\lib\catalina.jar -set CLASSPATH=%CP% -echo Using CLASSPATH: %CLASSPATH% - - -rem ----- Execute The Requested Command --------------------------------------- - -if "%1" == "-a" (if "%2" neq "" (if "%3" neq "" goto doRun)) - -:doUsage -echo Usage: digest -a [algorithm] [credentials] -echo Commands: -echo algorithm - The algorithm to use, i.e. MD5, SHA1 -echo credentials - The credential to digest -goto cleanup - -:doRun -%_RUNJAVA% org.apache.catalina.realm.JDBCRealm %1 %2 %3 -goto cleanup - - -rem ----- Restore Environment Variables --------------------------------------- - +:gotCatalinaHome +"%CATALINA_HOME%\bin\tool-wrapper" -server org.apache.catalina.realm.RealmBase %1 %2 %3 %4 %5 %6 %7 %8 %9 :cleanup set CATALINA_HOME=%_CATALINA_HOME% set _CATALINA_HOME= -set CLASSPATH=%_CLASSPATH% -set _CLASSPATH= -set CP=%_CP% -set _CP= -:finish 1.5 +3 -92 jakarta-tomcat-4.0/catalina/src/bin/digest.sh Index: digest.sh =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/bin/digest.sh,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- digest.sh 2001/09/12 00:54:28 1.4 +++ digest.sh 2001/11/13 16:57:21 1.5 @@ -10,97 +10,8 @@ # This script is assumed to run from the bin directory or have the # CATALINA_HOME env variable set. # -# $Id: digest.sh,v 1.4 2001/09/12 00:54:28 craigmcc Exp $ +# $Id: digest.sh,v 1.5 2001/11/13 16:57:21 craigmcc Exp $ # ----------------------------------------------------------------------------- - -# ----- Verify and Set Required Environment Variables ------------------------- - -if [ -z "$CATALINA_HOME" ] ; then - ## resolve links - $0 may be a link to home - PRG=$0 - progname=`basename $0` - - while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '.*/.*' > /dev/null; then - PRG="$link" - else - PRG="`dirname $PRG`/$link" - fi - done - - CATALINA_HOME_1=`dirname "$PRG"`/.. - echo "Guessing CATALINA_HOME from digest.sh to ${CATALINA_HOME_1}" - if [ -d ${CATALINA_HOME_1}/conf ] ; then - CATALINA_HOME=${CATALINA_HOME_1} - echo "Setting CATALINA_HOME to $CATALINA_HOME" - fi -fi - -if [ -z "$JAVA_HOME" ] ; then - echo You must set JAVA_HOME to point at your Java Development Kit installation - exit 1 -fi - - -# ----- Cygwin Unix Paths Setup ----------------------------------------------- - -# Cygwin support. $cygwin _must_ be set to either true or false. -case "`uname`" in - CYGWIN*) cygwin=true ;; - *) cygwin=false ;; -esac - -# For Cygwin, ensure paths are in UNIX format before anything is touched -if $cygwin ; then - [ -n "$CATALINA_HOME" ] && - CATALINA_HOME=`cygpath --unix "$CATALINA_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --unix "$JAVA_HOME"` -fi - - -# ----- Set Up The System Classpath ------------------------------------------- - -CP="$CATALINA_HOME/server/lib/catalina.jar" - -if [ -f "$JAVA_HOME/lib/tools.jar" ] ; then - CP=$CP:"$JAVA_HOME/lib/tools.jar" -fi - - -# ----- Cygwin Windows Paths Setup -------------------------------------------- - -# convert the existing path to windows -if $cygwin ; then - CP=`cygpath --path --windows "$CP"` - CATALINA_HOME=`cygpath --path --windows "$CATALINA_HOME"` - JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` -fi - - -# ----- Execute The Requested Command ----------------------------------------- - -echo "Using CLASSPATH: $CP" -echo "Using CATALINA_HOME: $CATALINA_HOME" -echo "Using JAVA_HOME: $JAVA_HOME" - -if [ "$1" != "-a" ] || [ -z "$2" ] || [ -z "$3" ] ; then - - echo "Usage: digest -a [algorithm] [credentials]" - echo "Commands:" - echo " algorithm - The algorithm to use, i.e. MD5, SHA1" - echo " credentials - The credentials to digest" - - exit 1 - -else - - shift - - $JAVA_HOME/bin/java -classpath $CP \ - org.apache.catalina.realm.JDBCRealm -a "$@" - -fi +BASEDIR=`dirname $0` +$BASEDIR/tool-wrapper.sh -server org.apache.catalina.realm.RealmBase "$@" 1.1 jakarta-tomcat-4.0/catalina/src/bin/tool-wrapper.bat Index: tool-wrapper.bat =================================================================== @echo off rem --------------------------------------------------------------------------- rem tool-wrapper.bat - Wrapper for command line tools rem rem Environment Variable Prequisites: rem rem CATALINA_HOME (Optional) Catalina binary distribution directory. rem If not present, the directory above this "bin" directory rem is assumed. rem rem JAVA_HOME (Required) Java Development Kit installation directory. rem rem TOOL_OPTS (Optional) Java execution options for the tool. rem rem $Id: tool-wrapper.bat,v 1.1 2001/11/13 16:57:21 craigmcc Exp $ rem --------------------------------------------------------------------------- rem ----- Save Environment Variables That May Change -------------------------- set _CATALINA_HOME=%CATALINA_HOME% set _CLASSPATH=%CLASSPATH% rem ----- Verify and Set Required Environment Variables ----------------------- if not "%JAVA_HOME%" == "" goto gotJava echo You must set JAVA_HOME to point at your Java Development Kit installation goto cleanup :gotJava if not "%CATALINA_HOME%" == "" goto gotHome set CATALINA_HOME=. if exist "%CATALINA_HOME%\bin\tool-wrapper.bat" goto okHome set CATALINA_HOME=.. :gotHome if exist "%CATALINA_HOME%\bin\tool-wrapper.bat" goto okHome echo Cannot find tool-wrapper.bat in %CATALINA_HOME%\bin echo Please check your CATALINA_HOME setting goto cleanup :okHome rem ----- Prepare Appropriate Java Execution Commands ------------------------- if not "%OS%" == "Windows_NT" goto noTitle set _RUNJAVA="%JAVA_HOME%\bin\java" goto gotTitle :noTitle set _RUNJAVA="%JAVA_HOME%\bin\java" :gotTitle rem ----- Set Up The Runtime Classpath ---------------------------------------- set CLASSPATH=%CATALINA_HOME%\bin\bootstrap.jar;%JAVA_HOME%\lib\tools.jar rem echo Using CLASSPATH: %CLASSPATH% rem echo Using CATALINA_HOME: %CATALINA_HOME% rem echo Using JAVA_HOME: %JAVA_HOME% rem ----- Execute The Requested Command --------------------------------------- %_RUNJAVA% %TOOL_OPTS% -Dcatalina.home="%CATALINA_HOME%" org.apache.catalina.startup.Tool %1 %2 %3 %4 %5 %6 %7 %8 %9 rem ----- Restore Environment Variables --------------------------------------- :cleanup set CATALINA_HOME=%_CATALINA_HOME% set _CATALINA_HOME= set CLASSPATH=%_CLASSPATH% set _CLASSPATH= set _RUNJAVA= :finish 1.1 jakarta-tomcat-4.0/catalina/src/bin/tool-wrapper.sh Index: tool-wrapper.sh =================================================================== #!/bin/sh # ----------------------------------------------------------------------------- # tool-wrapper.sh - Wrapper for command line tools # # Environment Variable Prequisites: # # CATALINA_HOME (Optional) Catalina binary distribution directory. # If not present, the directory above this "bin" directory # is assumed. # # JAVA_HOME (Required) Java Development Kit installation directory. # # TOOL_OPTS (Optional) Java execution options for the tool. # # $Id: tool-wrapper.sh,v 1.1 2001/11/13 16:57:21 craigmcc Exp $ # ----------------------------------------------------------------------------- # ----- Verify and Set Required Environment Variables ------------------------- if [ -z "$CATALINA_HOME" ] ; then ## resolve links - $0 may be a link to home PRG=$0 progname=`basename $0` while [ -h "$PRG" ] ; do ls=`ls -ld "$PRG"` link=`expr "$ls" : '.*-> \(.*\)$'` if expr "$link" : '.*/.*' > /dev/null; then PRG="$link" else PRG="`dirname $PRG`/$link" fi done CATALINA_HOME_1=`dirname "$PRG"`/.. echo "Guessing CATALINA_HOME from catalina.sh to ${CATALINA_HOME_1}" if [ -d ${CATALINA_HOME_1}/conf ] ; then CATALINA_HOME=${CATALINA_HOME_1} echo "Setting CATALINA_HOME to $CATALINA_HOME" fi fi if [ -z "$TOOL_OPTS" ] ; then TOOL_OPTS="" fi if [ -z "$JAVA_HOME" ] ; then echo You must set JAVA_HOME to point at your Java Development Kit installation exit 1 fi # ----- Cygwin Unix Paths Setup ----------------------------------------------- # Cygwin support. $cygwin _must_ be set to either true or false. case "`uname`" in CYGWIN*) cygwin=true ;; *) cygwin=false ;; esac # For Cygwin, ensure paths are in UNIX format before anything is touched if $cygwin ; then [ -n "$CATALINA_HOME" ] && CATALINA_HOME=`cygpath --unix "$CATALINA_HOME"` [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` fi # ----- Set Up The System Classpath ------------------------------------------- CP="$CATALINA_HOME/bin/bootstrap.jar" if [ -f "$JAVA_HOME/lib/tools.jar" ] ; then CP=$CP:"$JAVA_HOME/lib/tools.jar" fi # ----- Cygwin Windows Paths Setup -------------------------------------------- # convert the existing path to windows if $cygwin ; then CP=`cygpath --path --windows "$CP"` CATALINA_HOME=`cygpath --path --windows "$CATALINA_HOME"` JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` fi # ----- Execute The Requested Command ----------------------------------------- # echo "Using CLASSPATH: $CP" # echo "Using CATALINA_HOME: $CATALINA_HOME" # echo "Using JAVA_HOME: $JAVA_HOME" $JAVA_HOME/bin/java $TOOL_OPTS -classpath $CP \ -Dcatalina.home=$CATALINA_HOME \ org.apache.catalina.startup.Tool "$@" 1.1 jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/Tool.java Index: Tool.java =================================================================== /* * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/Tool.java,v 1.1 2001/11/13 16:57:22 craigmcc Exp $ * $Revision: 1.1 $ * $Date: 2001/11/13 16:57:22 $ * * ==================================================================== * * 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.io.File; import java.io.IOException; import java.lang.reflect.Method; import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import org.apache.catalina.loader.Extension; import org.apache.catalina.loader.StandardClassLoader; /** * <p>General purpose wrapper for command line tools that should execute in an * environment with the common class loader environment set up by Catalina. * This should be executed from a command line script that conforms to * the following requirements:</p> * <ul> * <li>Passes the <code>catalina.home</code> system property configured with * the pathname of the Tomcat installation directory.</li> * <li>Sets the system classpath to include <code>bootstrap.jar</code> and * <code>$JAVA_HOME/lib/tools.jar</code>.</li> * </ul> * * <p>The command line to execute the tool looks like:</p> * <pre> * java -classpath $CLASSPATH org.apache.catalina.startup.Tool \ * ${options} ${classname} ${arguments} * </pre> * * <p>with the following replacement contents: * <ul> * <li><strong>${options}</strong> - Command line options for this Tool wrapper. * The following options are supported: * <ul> * <li><em>-ant</em> : Set the <code>ant.home</code> system property * to corresponding to the value of <code>catalina.home</code> * (useful when your command line tool runs Ant).</li> * <li><em>-common</em> : Add <code>common/classes</code> and * <code>common/lib</codE) to the class loader repositories.</li> * <li><em>-debug</em> : Enable debugging messages from this wrapper.</li> * <li><em>-server</em> : Add <code>server/classes</code> and * <code>server/lib</code> to the class loader repositories.</li> * <li><em>-shared</em> : Add <code>shared/classes</code> and * <code>shared/lib</code> to the class loader repositories.</li> * </ul> * <li><strong>${classname}</strong> - Fully qualified Java class name of the * application's main class.</li> * <li><strong>${arguments}</strong> - Command line arguments to be passed to * the application's <code>main()</code> method.</li> * </ul> * * @author Craig R. McClanahan * @version $Revision: 1.1 $ $Date: 2001/11/13 16:57:22 $ */ public final class Tool { // ------------------------------------------------------- Static Variables /** * Set <code>ant.home</code> system property? */ private static boolean ant = false; /** * The pathname of our installation base directory. */ private static String catalinaHome = System.getProperty("catalina.home"); /** * Include common classes in the repositories? */ private static boolean common = false; /** * Enable debugging detail messages? */ private static boolean debug = false; /** * Include server classes in the repositories? */ private static boolean server = false; /** * Include shared classes in the repositories? */ private static boolean shared = false; // ----------------------------------------------------------- Main Program /** * The main program for the bootstrap. * * @param args Command line arguments to be processed */ public static void main(String args[]) { // Verify that "catalina.home" was passed. if (catalinaHome == null) { log("Must set 'catalina.home' system property"); System.exit(1); } // Process command line options int index = 0; while (true) { if (index > args.length) { usage(); System.exit(1); } if ("-ant".equals(args[index])) ant = true; else if ("-common".equals(args[index])) common = true; else if ("-debug".equals(args[index])) debug = true; else if ("-server".equals(args[index])) server = true; else if ("-shared".equals(args[index])) shared = true; else break; index++; } if (index > args.length) { usage(); System.exit(1); } // Set "ant.home" if requested if (ant) System.setProperty("ant.home", catalinaHome); // Construct the class loader we will be using ClassLoader classLoader = null; try { if (debug) { log("Constructing class loader"); ClassLoaderFactory.setDebug(1); } ArrayList packed = new ArrayList(); ArrayList unpacked = new ArrayList(); unpacked.add(new File(catalinaHome, "classes")); packed.add(new File(catalinaHome, "lib")); if (common) { unpacked.add(new File(catalinaHome, "common" + File.separator + "classes")); packed.add(new File(catalinaHome, "common" + File.separator + "lib")); } if (server) { unpacked.add(new File(catalinaHome, "server" + File.separator + "classes")); packed.add(new File(catalinaHome, "server" + File.separator + "lib")); } if (shared) { unpacked.add(new File(catalinaHome, "shared" + File.separator + "classes")); packed.add(new File(catalinaHome, "shared" + File.separator + "lib")); } classLoader = ClassLoaderFactory.createClassLoader ((File[]) unpacked.toArray(new File[0]), (File[]) packed.toArray(new File[0]), null); } catch (Throwable t) { log("Class loader creation threw exception", t); System.exit(1); } Thread.currentThread().setContextClassLoader(classLoader); // Load our application class Class clazz = null; String className = args[index++]; try { if (debug) log("Loading application class " + className); clazz = classLoader.loadClass(className); } catch (Throwable t) { log("Exception creating instance of " + className, t); System.exit(1); } // Locate the static main() method of the application class Method method = null; String params[] = new String[args.length - index]; System.arraycopy(args, index, params, 0, params.length); try { if (debug) log("Identifying main() method"); String methodName = "main"; Class paramTypes[] = new Class[1]; paramTypes[0] = params.getClass(); method = clazz.getMethod(methodName, paramTypes); } catch (Throwable t) { log("Exception locating main() method", t); System.exit(1); } // Invoke the main method of the application class try { if (debug) log("Calling main() method"); Object paramValues[] = new Object[1]; paramValues[0] = params; method.invoke(null, paramValues); } catch (Throwable t) { log("Exception calling main() method", t); System.exit(1); } } /** * Log a debugging detail message. * * @param message The message to be logged */ private static void log(String message) { System.out.print("Tool: "); System.out.println(message); } /** * Log a debugging detail message with an exception. * * @param message The message to be logged * @param exception The exception to be logged */ private static void log(String message, Throwable exception) { log(message); exception.printStackTrace(System.out); } /** * Display usage information about this tool. */ private static void usage() { log("Usage: java org.apache.catalina.startup.Tool [<options>] <class> [<arguments>]"); } }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>