Filewatcher File Search
FTP Search
  
Directory (beta)
  
Content Search (beta)
   
pkg://jakarta-commons-launcher-0.9-3jpp_1fc.src.rpm:47047/launcher-0.9-src.tar.gz  info  downloads

commons-launcher/src/ 40755      0      0           0  7556204456  12146 5ustar     0      0 commons-launcher/src/bin/ 40755      0      0           0  7556204456  12716 5ustar     0      0 commons-launcher/src/conf/ 40755      0      0           0  7556204456  13073 5ustar     0      0 commons-launcher/src/java/ 40755      0      0           0  7556204456  13067 5ustar     0      0 commons-launcher/src/java/org/ 40755      0      0           0  7556204456  13656 5ustar     0      0 commons-launcher/src/java/org/apache/ 40755      0      0           0  7556204456  15077 5ustar     0      0 commons-launcher/src/java/org/apache/commons/ 40755      0      0           0  7556204456  16552 5ustar     0      0 commons-launcher/src/java/org/apache/commons/launcher/ 40755      0      0           0  7556204456  20353 5ustar     0      0 commons-launcher/src/java/org/apache/commons/launcher/types/ 40755      0      0           0  7556204456  21517 5ustar     0      0 commons-launcher/xdocs/ 40755      0      0           0  7556204456  12477 5ustar     0      0 commons-launcher/LICENSE100644      0      0        5231  7556150224  12453 0ustar     0      0 /*
 * ====================================================================
 *
 * The Apache Software License, Version 1.1
 *
 * Copyright (c) 1999-2002 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", "Commons", 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/>.
 *
 */
commons-launcher/LICENSE.txt100644      0      0        5231  7556150224  13271 0ustar     0      0 /*
 * ====================================================================
 *
 * The Apache Software License, Version 1.1
 *
 * Copyright (c) 1999-2002 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", "Commons", 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/>.
 *
 */
commons-launcher/PROPOSAL.html100644      0      0        3531  7556150224  13574 0ustar     0      0 <html>
<head>
<title>Proposal for Launcher Package</title>
</head>
<body bgcolor="white">

<div align="center">
<h1>Proposal for <em>Launcher</em> Package</h1>
</div>

<h3>(1) Scope of the Package</h3>

<p>The <em>Launcher</em> Component is designed to be a cross platform Java
application launcher.</p>

<h3>(1.5) Interaction With Other Packages</h3>

<p><em>Launcher</em> relies only on standard JDK 1.2 (or later) APIs for
production deployment.  It utilizes the JUnit unit testing framework for
developing and executing unit tests, but this is of interest only to
developers of the component.  Launcher will be a dependency for
several existing components in the open source world.</p>

<p>No external configuration files are utilized.</p>


<h3>(2) Initial Source of the Package</h3>

<p>The original Java classes come from the Jakarta Tomcat 4.1 project.</p>

<p>The proposed package name for the new component is
<code>org.apache.commons.launcher</code>.</p>


<h3>(3)  Required Jakarta-Commons Resources</h3>

<ul>
<li>CVS Repository - New directory <code>launcher</code> in the
    <code>jakarta-commons</code> CVS repository.</li>
<li>Mailing List - Discussions will take place on the general
    <em>commons-dev@jakarta.apache.org</em> mailing list.  To help
    list subscribers identify messages of interest, it is suggested that
    the message subject of messages about this component be prefixed with
    [Launcher].</li>
<li>Bugzilla - New component "Launcher" under the "Commons" product
    category, with appropriate version identifiers as needed.</li>
<li>Jyve FAQ - New category "commons-launcher" (when available).</li>
</ul>


<h3>(4) Initial Committers</h3>

<p>The initial committers on the Launcher component shall be:</p>
<ul>
<li>Patrick Luby</li>
<li>Remy Maucherat</li>



</body>
</html>
commons-launcher/RELEASE-NOTES.txt100644      0      0         771  7556150224  14141 0ustar     0      0 $Id: RELEASE-NOTES.txt,v 1.1.1.1 2002/10/25 09:03:16 remm Exp $

			Commons Laucher Package
			   Version 1.0-dev
			    Release Notes


INTRODUCTION:

This document contains the release notes for this version of the Commons
Laucher package, and highlights changes since the previous version.  The
current release adds new features and bug fixes, and is being done now to
follow the release early/release often mentality.


NEW FEATURES:

* Initial import to Commons


BUG FIXES:


commons-launcher/STATUS.html100644      0      0        3345  7556150224  13363 0ustar     0      0 <html>
<head>
<title>Status File for Jakarta Commons "Launcher" Component</title>
</head>
<body bgcolor="white">


<div align="center">
<h1>The Jakarta Commons <em>Launcher</em> Component</h1>
$Id: STATUS.html,v 1.1.1.1 2002/10/25 09:03:15 remm Exp $<br />
<a href="#Introduction">[Introduction]</a>
<a href="#Dependencies">[Dependencies]</a>
<a href="#Release Info">[Release Info]</a>
<a href="#Committers">[Committers]</a>
<br /><br />
</div>


<a name="Introduction"></a>
<h3>1.  INTRODUCTION</h3>

<p>The <em>Launcher</em> Component is designed to be a cross platform Java
application launcher.</p>
<p>This code was originally developped as part of the Tomcat project.</p>


<a name="Dependencies"></a>
<h3>2.  DEPENDENCIES</h3>

<p>The <em>Launcher</em> component is dependent upon the following external
components for development and use:</p>
<ul>
<li><a href="http://java.sun.com/j2se">Java Development Kit</a>
    (Version 1.2 or later)</li>
<li><a href="http://www.junit.org">JUnit Testing Framework</a>
    (Version 3.7 or later) - for unit tests only, not required
    for deployment</li>
</ul>


<a name="Release Info"></a>
<h3>3.  RELEASE INFO</h3>

<p>Current Release: Launcher is yet to be released.  We hope it will be RSN.</p>

<p></p>


<a name="Committers"></a>
<h3>4.  COMMITTERS</h3>

<p>The following individuals are the primary developers and maintainers of this
component.  Developers who plan to use <em>Launcher</em> in their own
projects are encouraged to collaborate on the future development of this
component to ensure that it continues to meet a variety of needs.</p>
<ul>
<li>Patrick Luby</li>
<li>Costin Manolache</li>
<li>Remy Maucherat</li>
</ul>


</body>
</html>
commons-launcher/build-maven.xml100644      0      0       13115  7556150224  14413 0ustar     0      0 <?xml version="1.0"?>

<project name="maven" default="maven:jar" basedir=".">

  <!-- Give user a chance to override without editing this file
       (and without typing -D each time they invoke a target) -->

  <!-- Allow any user specific values to override the defaults -->
  <property file="${user.home}/build.properties" />
  <!-- Allow user defaults for this build -->
  <property file="build.properties" />
  <!-- Set default values for the project -->
  <property file="project.properties" />

  <!-- maven:start -->
  
  <!-- ================================================================== -->
  <!-- D E L E G A T O R S                                                -->
  <!-- ================================================================== -->
        

    <target name="maven:site">
      <ant antfile="${maven.home}/plugins/docs/build.xml" target="site"/>
    </target>


    <target name="maven:dist">
      <ant antfile="${maven.home}/plugins/core/build.xml" target="dist"/>
    </target>


    <target name="maven:env">
      <ant antfile="${maven.home}/plugins/core/build.xml" target="env"/>
    </target>


    <target name="maven:test">
      <ant antfile="${maven.home}/plugins/test/build.xml" target="test"/>
    </target>


    <target name="maven:announce">
      <ant antfile="${maven.home}/plugins/core/build.xml" target="announce"/>
    </target>


    <target name="maven:activity-log">
      <ant antfile="${maven.home}/plugins/docs/build.xml" target="activity-log"/>
    </target>


    <target name="maven:compile">
      <ant antfile="${maven.home}/plugins/core/build.xml" target="compile"/>
    </target>


    <target name="maven:validate-war">
      <ant antfile="${maven.home}/plugins/j2ee/build.xml" target="validate-war"/>
    </target>


    <target name="maven:pdf">
      <ant antfile="${maven.home}/plugins/docs/build.xml" target="pdf"/>
    </target>


    <target name="maven:iutest">
      <ant antfile="${maven.home}/plugins/iutest/build.xml" target="iutest"/>
    </target>


    <target name="maven:deploy-site">
      <ant antfile="${maven.home}/plugins/docs/build.xml" target="deploy-site"/>
    </target>


    <target name="maven:deploy-dist">
      <ant antfile="${maven.home}/plugins/core/build.xml" target="deploy-dist"/>
    </target>


    <target name="maven:war">
      <ant antfile="${maven.home}/plugins/j2ee/build.xml" target="war"/>
    </target>


    <target name="maven:verify-project">
      <ant antfile="${maven.home}/plugins/core/build.xml" target="verify-project"/>
    </target>


    <target name="maven:cvs-change-log">
      <ant antfile="${maven.home}/plugins/docs/build.xml" target="cvs-change-log"/>
    </target>


    <target name="maven:ear">
      <ant antfile="${maven.home}/plugins/j2ee/build.xml" target="ear"/>
    </target>


    <target name="maven:cross-ref">
      <ant antfile="${maven.home}/plugins/docs/build.xml" target="cross-ref"/>
    </target>


    <target name="maven:update-jars">
      <ant antfile="${maven.home}/plugins/core/build.xml" target="update-jars"/>
    </target>


    <target name="maven:validate-pom">
      <ant antfile="${maven.home}/plugins/core/build.xml" target="validate-pom"/>
    </target>


    <target name="maven:install-jar">
      <ant antfile="${maven.home}/plugins/core/build.xml" target="install-jar"/>
    </target>


    <target name="maven:fo">
      <ant antfile="${maven.home}/plugins/docs/build.xml" target="fo"/>
    </target>


    <target name="maven:javadocs">
      <ant antfile="${maven.home}/plugins/docs/build.xml" target="javadocs"/>
    </target>


    <target name="maven:validate-struts-war">
      <ant antfile="${maven.home}/plugins/struts/build.xml" target="validate-struts-war"/>
    </target>


    <target name="maven:task-list">
      <ant antfile="${maven.home}/plugins/docs/build.xml" target="task-list"/>
    </target>


    <target name="maven:ejb">
      <ant antfile="${maven.home}/plugins/j2ee/build.xml" target="ejb"/>
    </target>


    <target name="maven:docs">
      <ant antfile="${maven.home}/plugins/docs/build.xml" target="docs"/>
    </target>


    <target name="maven:clean">
      <ant antfile="${maven.home}/plugins/core/build.xml" target="clean"/>
    </target>


    <target name="maven:dist-build">
      <ant antfile="${maven.home}/plugins/core/build.xml" target="dist-build"/>
    </target>


    <target name="maven:metrics">
      <ant antfile="${maven.home}/plugins/metrics/build.xml" target="metrics"/>
    </target>


    <target name="maven:docs-quick">
      <ant antfile="${maven.home}/plugins/docs/build.xml" target="docs-quick"/>
    </target>


    <target name="maven:run-singletest">
      <ant antfile="${maven.home}/plugins/test/build.xml" target="run-singletest"/>
    </target>


    <target name="maven:check-source">
      <ant antfile="${maven.home}/plugins/core/build.xml" target="check-source"/>
    </target>


    <target name="maven:generate-reactor">
      <ant antfile="${maven.home}/plugins/reactor/build.xml" target="generate-reactor"/>
    </target>


    <target name="maven:jar">
      <ant antfile="${maven.home}/plugins/core/build.xml" target="jar"/>
    </target>


    <target name="maven:maven-update">
      <ant antfile="${maven.home}/plugins/core/build.xml" target="maven-update"/>
    </target>


    <target name="maven:gump-descriptor">
      <ant antfile="${maven.home}/plugins/core/build.xml" target="gump-descriptor"/>
    </target>


  <!-- maven:end -->

</project>
commons-launcher/build.properties.sample100644      0      0         315  7556150224  16121 0ustar     0      0 # The directory containing your binary distribution of JUnit, 
# version 3.7 or later
junit.home = /usr/local/junit3.7

# The pathname of the "junit.jar" JAR file
junit.jar = ${junit.home}/junit.jar
commons-launcher/project.xml100644      0      0       11062  7556150224  13655 0ustar     0      0 <?xml version="1.0" encoding="UTF-8"?>

<project>
  <pomVersion>3</pomVersion>
  <name>commons-launcher</name>
  <id>commons-launcher</id>
  <currentVersion>1.0-dev-0</currentVersion>
  <organization>
    <name>Apache Software Foundation</name>
    <url>http://www.apache.org</url>
  </organization>
  <inceptionYear>2002</inceptionYear>
  <package>org.apache.commons.launcher</package>
  <shortDescription>Commons Launcher</shortDescription>

  <!-- Gump integration -->
  <gumpRepositoryId>jakarta</gumpRepositoryId>
  
  <description>
        Launcher are a set of Java classes which aim at making a cross
        platform Java application launcher.
  </description>
  
  <url>http://jakarta.apache.org/commons/sandbox/launcher/</url>
  <issueTrackingUrl>http://nagoya.apache.org/scarab/servlet/scarab/</issueTrackingUrl>
  <siteAddress>jakarta.apache.org</siteAddress>
  <siteDirectory>/www/jakarta.apache.org/commons/sandbox/launcher/</siteDirectory>
  <distributionDirectory>/www/jakarta.apache.org/builds/jakarta-commons-sandbox/launcher/</distributionDirectory>
  <repository>
    <connection>scm:cvs:pserver:anoncvs@cvs.apache.org:/home/cvspublic:jakarta-commons-sandbox/launcher</connection>
    <url>http://cvs.apache.org/viewcvs/jakarta-commons-sandbox/launcher/</url>
  </repository>
  
  <versions>
    <version>
      <id>b0</id>
      <name>0.0-b0</name>
      <tag>HEAD</tag>
    </version>
  </versions>
  <branches></branches>
  
  <mailingLists>
    <mailingList>
      <name>Commons User List</name>
      <subscribe>commons-user-subscribe@jakarta.apache.org</subscribe>
      <unsubscribe>commons-user-unsubscribe@jakarta.apache.org</unsubscribe>
      <archive>http://archives.apache.org/eyebrowse/SummarizeList?listName=commons-user@jakarta.apache.org</archive>
    </mailingList>
    <mailingList>
      <name>Commons Dev List</name>
      <subscribe>commons-dev-subscribe@jakarta.apache.org</subscribe>
      <unsubscribe>commons-dev-unsubscribe@jakarta.apache.org</unsubscribe>
      <archive>http://nagoya.apache.org/eyebrowse/SummarizeList?listName=commons-dev@jakarta.apache.org</archive>
    </mailingList>
  </mailingLists>
  
  <developers>
    <!-- I have just put myself for the moment -->
    <developer>
      <name>Jean-Frederic Clere</name>
      <id>jfclere</id>
      <email>jfrederic.clere@fujitsu-siemens.com</email>
      <organization>FSC</organization>
    </developer>

  </developers>

  <dependencies>
    
    <!-- for doclets -->
    <dependency>
      <id>javadoc</id>
      <version>1.3</version>
    </dependency>
    
    <dependency>
      <name>xmlParseAPIs</name>
      <type>required</type>
      <version>2.0.2</version>
      <jar>xmlParserAPIs-2.0.2.jar</jar>
    </dependency>
    
    <dependency>
      <name>xercesImpl</name>
      <type>required</type>
      <version>2.0.2</version>
      <jar>xercesImpl-2.0.2.jar</jar>
    </dependency>
    
    <dependency>
      <name>ant</name>
      <version>1.4.1</version>
      <jar>ant-1.4.1.jar</jar>
    </dependency>
    
    <dependency>
      <name>ant-optional</name>
      <version>1.4.1</version>
      <jar>ant-optional-1.4.1.jar</jar>
    </dependency>

    <dependency>
      <name>commons-logging</name>
      <type>required</type>
      <version>1.0</version>
      <jar>commons-logging-1.0.jar</jar>
    </dependency>

    <dependency>
      <name>commons-collections</name>
      <type>required</type>
      <version>2.0</version>
      <jar>commons-collections-2.0.jar</jar>
    </dependency>
  </dependencies>
  <build>
    <nagEmailAddress>commons-dev@jakarta.apache.org</nagEmailAddress>
    <sourceDirectory>src/java</sourceDirectory>
    <unitTestSourceDirectory>src/test</unitTestSourceDirectory>
    <integrationUnitTestSourceDirectory/>
    <aspectSourceDirectory/>
    <!-- Unit test classes -->

    <unitTestPatterns>
      <unitTestPattern>**/Test*.java</unitTestPattern>
    </unitTestPatterns>
    
    <unitTest>
      <includes>
        <include>**/Test*.java</include>
      </includes>
    </unitTest>

    
    <!-- Integration unit test classes -->

    <integrationUnitTestPatterns></integrationUnitTestPatterns>

    <!-- J A R  R E S O U R C E S -->
    <!-- Resources that are packaged up inside the JAR file -->
    <resources>
      <includes>
        <include>**/*.properties</include>
      </includes>
    </resources>

    <jarResources>
      <jarResource>**/*.properties</jarResource>
    </jarResources>
    <jars></jars>
  </build>
</project>
commons-launcher/src/bin/launch-ant.bat100644      0      0        2272  7556150232  15530 0ustar     0      0 @echo off
if "%OS%" == "Windows_NT" setlocal

rem ---------------------------------------------------------------------------
rem
rem Sample script for launching Ant using the Launcher
rem
rem ---------------------------------------------------------------------------

rem Get standard environment variables
set PRG=%0
if exist %PRG%\..\settings.bat goto gotCmdPath
rem %0 must have been found by DOS using the %PATH% so we assume that
rem settings.bat will also be found in the %PATH%
call settings.bat
goto doneSetenv
:gotCmdPath
call %PRG%\..\settings.bat
:doneSetenv

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
:gotJavaHome

rem Get command line arguments and save them with the proper quoting
set CMD_LINE_ARGS=
:setArgs
if ""%1""=="""" goto doneSetArgs
set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1
shift
goto setArgs
:doneSetArgs

rem Execute the Launcher using the "ant" target
"%JAVA_HOME%\bin\java.exe" -classpath %PRG%\..;"%PATH%" LauncherBootstrap -verbose ant %CMD_LINE_ARGS%

:end
commons-launcher/src/bin/launch-ant.sh100644      0      0        1371  7556150232  15373 0ustar     0      0 #!/bin/sh

# -----------------------------------------------------------------------------
#
# Sample script for launching Ant using the Launcher
#
# -----------------------------------------------------------------------------

# Resolve links - $0 may be a softlink
PRG="$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

# Get standard environment variables
PRGDIR=`dirname "$PRG"`
if [ -r "$PRGDIR"/settings.sh ]; then
  . "$PRGDIR"/settings.sh
fi

# Execute the Launcher using the "ant" target
exec "$JAVA_HOME"/bin/java -classpath "$PRGDIR" LauncherBootstrap -verbose ant "$@"
commons-launcher/src/bin/launcher.properties100644      0      0        2342  7556150232  16723 0ustar     0      0 #
# Properties for the LauncherBootstrap class
#
# This file contains the following configurable properties:
# - ant.class.path - This property is a ":" separated list of the URL file
#   fragments where the Ant classes are located. The list must include a JAXP
#   compliant XML parser if you are not using Java(TM) SE 1.4 or higher.
#
# Important notes:
# - Relative URL file fragments, such as "../lib", are supported and strongly
#   encouraged as absolute files prevent cross platform distribution.
# - URL file fragments are the portions of a URL after the "file:" string.
#   This means that you must use "/" characters as directory separators on
#   all platforms. Also, ":" characters in a file fragment, such as in drive
#   portion of absolute Windows files, must be URL encoded as "%3A". Lastly,
#   directories must have a "/" character at the end.
# - All relative URL file fragments in the above properties will be resolved
#   using the URL of the directory that the LauncherBootstrap class was
#   loaded from, not the current working directory. This ensures that the
#   LauncherBootstrap class can properly resolve the files without regard to
#   the current working directory.
#
ant.class.path=@ANTJARLIST@
commons-launcher/src/bin/launcher.xml100644      0      0        6255  7556150232  15336 0ustar     0      0 <!--

  Sample XML file for launching a sample application - Ant - using the Launcher.

  By default, the sample application will be launched in the background.
  To run it in the foreground, execute the Launcher with a "-Dwait=true"
  argument.

  To run the sample application in the JDB debugger, execute the Launcher with
  a "-Ddebug=true" argument.

  To run the sample application in JPDA mode, execute the Launcher with a
  "-Djpda=true" argument.

-->

<project name="Ant Launcher" default="ant" basedir=".">

  <!-- Set the application home to the parent directory of this directory -->
  <property name="app.home" location="${basedir}/.."/>

  <!-- Build the classpath relative to the application home -->
  <path id="base.class.path">
    <fileset dir="${app.home}/lib" includes="*.jar"/>
  </path>

  <!-- Build the sysproperties relative to the application home -->
  <syspropertyset id="base.sys.properties">
    <sysproperty key="ant.home" file="${app.home}"/>
  </syspropertyset>

  <!-- Build the standard jvmargs -->
  <jvmargset id="base.jvm.args">
    <jvmarg value="-sourcepath" if="jdb"/>
    <jvmarg path="${app.home}/../src/java" if="jdb"/>
    <jvmarg value="-Xdebug" if="jpda.settings"/>
    <jvmarg value="-Xrunjdwp:${jpda.settings}" if="jpda.settings"/>
  </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 Ant -->
  <target name="ant" description="Execute Ant using the Launcher"
    depends="setjdb,setjpda">

    <!--
      Execute Ant in a separate process. Note the use if "if" and "unless"
      attributes to control the passing of arguments to Ant.
     -->
    <launch classname="org.apache.tools.ant.Main"
      waitforchild="${wait}"
      debug="${jdb}"
      print="${print}"
      requiretools="true"
      redirectoutput="true"
      output="${app.home}/logs/ant.log"
      displayMinimizedWindow="true"
      disposeMinimizedWindow="true"
      minimizedWindowTitle="Ant">
        <jvmargset refid="base.jvm.args"/>
        <syspropertyset refid="base.sys.properties"/>
        <classpath refid="base.class.path"/>
    </launch>

  </target>

</project>
commons-launcher/src/conf/MANIFEST.MF100644      0      0         277  7556150230  14576 0ustar     0      0 Extension-Name: @package@
Specification-Vendor: Apache Software Foundation
Specification-Version: 1.0
Implementation-Vendor: Apache Software Foundation
Implementation-Version: @version@
commons-launcher/src/java/LauncherBootstrap.java100644      0      0       25775  7556150224  17517 0ustar     0      0 /* ========================================================================= *
 *                                                                           *
 *                 The Apache Software License,  Version 1.1                 *
 *                                                                           *
 *             Copyright (c) 2002 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",  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/>.   *
 *                                                                           *
 * ========================================================================= */

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Properties;
import java.util.StringTokenizer;

/**
 * This class is used as a wrapper for loading the
 * org.apache.commons.launcher.Launcher class and invoking its
 * <code>main(String[])</code> method. This particular
 * class is primary used by the Windows 95, 98, ME, and 2000 platforms to
 * overcome the difficulty of putting a jar file directly into the JVM's
 * classpath when using batch scripts on these platforms.
 * <p>
 * Specifically, the problem on thse platforms is when Windows uses the PATH
 * environment variable to find and run a batch script, %0 will resolve
 * incorrectly in that batch script.
 * <p>
 * The way to work around this Windows limitation is to do the following:
 * <ol>
 * <li>Put this class' class file - LauncherBootstrap.class - in the same
 * directory as the batch script. Do not put this class file in a jar file.
 * <li>Put the jar file containing the launcher's classes in the same
 * directory as the batch script and this class' class file. Be sure that
 * that the jar file is named "commons-launcher.jar".
 * <li>Make the Java command in the batch script invoke Java use the following
 * classpath arguments. Be sure to include the quotes to ensure that paths
 * containing spaces are handled properly:
 * <code>-classpath %0\..;"%PATH%"</code>
 * </ol>
 *
 * @author Patrick Luby
 */
public class LauncherBootstrap {

    //---------------------------------------------------------- Static Fields

    /**
     * Ant classpath property name
     */
    public final static String ANT_CLASSPATH_PROP_NAME = "ant.class.path";

    /**
     * Jar file name
     */
    public final static String LAUNCHER_JAR_FILE_NAME = "commons-launcher.jar";

    /**
     * Properties file name
     */
    public final static String LAUNCHER_PROPS_FILE_NAME = "launcher.properties";

    /**
     * Class name to load
     */
    public final static String LAUNCHER_MAIN_CLASS_NAME = "org.apache.commons.launcher.Launcher";

    /**
     * Cached Laucher class.
     */
    private static Class launcherClass = null;

    //---------------------------------------------------------- Static Methods

    /**
     * The main method.
     *
     * @param args command line arguments
     */
    public static void main(String[] args) {

        try {

            // Try to find the LAUNCHER_JAR_FILE_NAME file in the class
            // loader's and JVM's classpath.
            URL coreURL = LauncherBootstrap.class.getResource("/" + LauncherBootstrap.LAUNCHER_JAR_FILE_NAME);
            if (coreURL == null)
                throw new FileNotFoundException(LauncherBootstrap.LAUNCHER_JAR_FILE_NAME);

            // Coerce the coreURL's directory into a file
            File coreDir = new File(URLDecoder.decode(coreURL.getFile())).getCanonicalFile().getParentFile();

            // Try to find the LAUNCHER_PROPS_FILE_NAME file in the same
            // directory as this class
            File propsFile = new File(coreDir, LauncherBootstrap.LAUNCHER_PROPS_FILE_NAME);
            if (!propsFile.canRead())
                throw new FileNotFoundException(propsFile.getPath());

            // Load the properties in the LAUNCHER_PROPS_FILE_NAME 
            Properties props = new Properties();
            FileInputStream fis = new FileInputStream(propsFile);
            props.load(fis);
            fis.close();

            // Create a class loader that contains the Launcher, Ant, and
            // JAXP classes.
            URL[] antURLs = LauncherBootstrap.fileListToURLs((String)props.get(LauncherBootstrap.ANT_CLASSPATH_PROP_NAME));
            URL[] urls = new URL[1 + antURLs.length];
            urls[0] = coreURL;
            for (int i = 0; i < antURLs.length; i++)
                urls[i + 1] = antURLs[i];
            ClassLoader parentLoader = Thread.currentThread().getContextClassLoader();
            URLClassLoader loader = null;
            if (parentLoader != null)
                loader = new URLClassLoader(urls, parentLoader);
            else
                loader = new URLClassLoader(urls);

            // Load the LAUNCHER_MAIN_CLASS_NAME class
            launcherClass = loader.loadClass(LAUNCHER_MAIN_CLASS_NAME);

            // Get the LAUNCHER_MAIN_CLASS_NAME class' getLocalizedString()
            // method as we need it for printing the usage statement
            Method getLocalizedStringMethod = launcherClass.getDeclaredMethod("getLocalizedString", new Class[]{ String.class });

            // Invoke the LAUNCHER_MAIN_CLASS_NAME class' start() method.
            // If the ant.class.path property is not set correctly in the 
            // LAUNCHER_PROPS_FILE_NAME, this will throw an exception.
            Method startMethod = launcherClass.getDeclaredMethod("start", new Class[]{ String[].class });
            int returnValue = ((Integer)startMethod.invoke(null, new Object[]{ args })).intValue();
            // Always exit cleanly after invoking the start() method
            System.exit(returnValue);

       } catch (Throwable t) {

           t.printStackTrace();
           System.exit(1);

        }

    }

    /**
     * Convert a ":" separated list of URL file fragments into an array of URL
     * objects. Note that any all URL file fragments must conform to the format
     * required by the "file" parameter in the
     * {@link URL(String, String, String)} constructor.
     *
     * @param fileList the ":" delimited list of URL file fragments to be
     *  converted
     * @return an array of URL objects
     * @throws MalformedURLException if the fileList parameter contains any
     *  malformed URLs
     */
    private static URL[] fileListToURLs(String fileList)
        throws MalformedURLException
    {

        if (fileList == null || "".equals(fileList))
            return new URL[0];

        // Parse the path string
        ArrayList list = new ArrayList();
        StringTokenizer tokenizer = new StringTokenizer(fileList, ":");
        URL bootstrapURL = LauncherBootstrap.class.getResource("/" + LauncherBootstrap.class.getName() + ".class");
        while (tokenizer.hasMoreTokens())
            list.add(new URL(bootstrapURL, tokenizer.nextToken()));

        return (URL[])list.toArray(new URL[list.size()]);

    }

}
commons-launcher/src/java/org/apache/commons/launcher/ChildMain.java100644      0      0       32535  7556150224  23164 0ustar     0      0 /* ========================================================================= *
 *                                                                           *
 *                 The Apache Software License,  Version 1.1                 *
 *                                                                           *
 *             Copyright (c) 2002 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",  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.commons.launcher;

import java.awt.Frame;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.lang.reflect.Method;

/**
 * A wrapper class that invokes another class'
 * <code>main(String[])</code>. This particular class uses several system
 * properties to control features:
 * <ul>
 * <li>Redirecting System.out and System.err.
 * <li>Displaying a minimized window in the Windows taskbar.
 * </ul>
 * This class is normally not invoked directly. Instead, it is invoked by the
 * {@link LaunchTask} class.
 *
 * @author Patrick Luby
 */
public class ChildMain extends Thread {

    //----------------------------------------------------------- Static Fields

    /**
     * The appendOutput system property name.
     */
    public final static String APPEND_OUTPUT_PROP_NAME =
        "org.apache.commons.launcher.appendOutput";

    /**
     * The displayMiminizedWindow system property name.
     */
    public final static String DISPLAY_MINIMIZED_WINDOW_PROP_NAME =
        "org.apache.commons.launcher.displayMinimizedWindow";

    /**
     * The disposeMiminizedWindow system property name.
     */
    public final static String DISPOSE_MINIMIZED_WINDOW_PROP_NAME =
        "org.apache.commons.launcher.disposeMinimizedWindow";

    /**
     * The executableName system property name.
     */
    public final static String EXECUTABLE_PROP_NAME =
        "org.apache.commons.launcher.executableName";

    /**
     * The heartbeatFile system property name.
     */
    public final static String HEARTBEAT_FILE_PROP_NAME =
        "org.apache.commons.launcher.heartbeatFile";

    /**
     * The miminizedWindowTitle system property name.
     */
    public final static String MINIMIZED_WINDOW_TITLE_PROP_NAME =
        "org.apache.commons.launcher.minimizedWindowTitle";

    /**
     * The miminizedWindowIcon system property name.
     */
    public final static String MINIMIZED_WINDOW_ICON_PROP_NAME=
        "org.apache.commons.launcher.minimizedWindowIcon";

    /**
     * The outputFile system property name.
     */
    public final static String OUTPUT_FILE_PROP_NAME =
        "org.apache.commons.launcher.outputFile";

    /**
     * The waitForChild system property name.
     */
    public final static String WAIT_FOR_CHILD_PROP_NAME =
        "org.apache.commons.launcher.waitForChild";

    //------------------------------------------------------------------ Fields

    /**
     * Cached command line arguments
     */
    private String[] args = null;

    //------------------------------------------------------------ Constructors

    /**
     * Construct an instance of this {@link Thread} subclass and cache the
     * args parameter for use by the {@link #run()} method.
     *
     * @param group the ThreadGroup to use for this thread
     * @param args the command line arguments
     */
    private ChildMain(ThreadGroup group, String[] args) {

        super(group, ChildMain.class.getName());
        this.args = args;

    }

    //---------------------------------------------------------- Static Methods

    /**
     * Main entry point for the child process. This method should only be
     * invoked by the {@link LaunchTask} class.
     *
     * @param args command line arguments
     */
    public static void main(String[] args) {

        // Invoke the target application in a separate thread so that we
        // caught any uncaught errors thrown by the target application
        Thread mainThread = new ChildMain(new ExitOnErrorThreadGroup(ChildMain.class.getName()), args);
        mainThread.start();

    }

    //----------------------------------------------------------------- Methods

    /**
     * Invoke the target application.
     *
     * @param args command line arguments
     */
    public void run() {

        // If there are no arguments, do nothing
        if (args == null || args.length == 0)
            return;

        // Invoke the target application
        try {

            // Start the thread to check if the parent JVM exits.
            boolean waitForChild = false;
            if (System.getProperty(ChildMain.WAIT_FOR_CHILD_PROP_NAME) != null) {
                waitForChild = true;
                String heartbeatFile = System.getProperty(ChildMain.HEARTBEAT_FILE_PROP_NAME);
                ParentListener heartbeat = new ParentListener(heartbeatFile);
                // Make the thread a daemon thread so that it does not
                // prevent this process from exiting when all of the
                // appliation's threads finish.
                heartbeat.setDaemon(true);
                heartbeat.start();
            }

            // If applicable, redirect output and error streams
            String outputPath = System.getProperty(ChildMain.OUTPUT_FILE_PROP_NAME);
            if (outputPath != null) {
                boolean appendOutput = false;
                if (System.getProperty(ChildMain.APPEND_OUTPUT_PROP_NAME) != null)
                    appendOutput = true;
                PrintStream ps = new PrintStream(new FileOutputStream(outputPath, appendOutput), true);
                System.setOut(ps);
                System.setErr(ps);
            }

            // The first argument should be the class that we really want to
            // invoke. Try to load the class and invoke its main(String[])
            // method with the first argument shifted out.
            Class mainClass = Class.forName(args[0]);
            Class[] paramTypes = new Class[1];
            Object[] paramValues = new Object[1];
            String[] params = new String[args.length - 1];
            // Shift args[0] out of the arguments
            for (int i = 0; i < params.length; i++)
                params[i] = args[i + 1];
            paramTypes[0] = params.getClass();
            paramValues[0] = params;

            // Create the icon window if this is a waitForChild task
            Frame frame = null;
            boolean displayMinimizedWindow = false;
            if (System.getProperty(ChildMain.DISPLAY_MINIMIZED_WINDOW_PROP_NAME) != null)
                displayMinimizedWindow = true;
            String osname = System.getProperty("os.name").toLowerCase();
            if (displayMinimizedWindow && osname.indexOf("windows") >= 0) {
                try {
                    frame = new Frame();
                    String title = System.getProperty(ChildMain.MINIMIZED_WINDOW_TITLE_PROP_NAME);
                    if (title != null)
                        frame.setTitle(title);
                    frame.setState(Frame.ICONIFIED);
                    String icon = System.getProperty(ChildMain.MINIMIZED_WINDOW_TITLE_PROP_NAME);
                    if (icon != null) {
                        Image iconImage = Toolkit.getDefaultToolkit().createImage(icon);
                        if (iconImage != null)
                            frame.setIconImage(iconImage);
                    }

                    // Ensure that window always remains minimized
                    frame.addWindowListener(new ChildWindowAdapter());
                    Rectangle bounds = frame.getGraphicsConfiguration().getBounds();
                    int width = (int)frame.getBounds().getWidth();
                    int height = frame.getInsets().top + frame.getInsets().bottom;
                    int x = (int)bounds.getWidth() - width;
                    int y = (int)bounds.getHeight() - height;
                    frame.setBounds(x, y, width, height);
                    frame.setResizable(false);
                    frame.setVisible(true);
                } catch(Exception fe) {}
            }

            // Invoke the main() method
            Method mainMethod = mainClass.getDeclaredMethod("main", paramTypes);
            mainMethod.invoke(null, paramValues);

            // Close the frame if it exists
            if (frame != null && System.getProperty(ChildMain.DISPOSE_MINIMIZED_WINDOW_PROP_NAME) != null) {
                // Exit this process. Closing or disposing of the window is not
                // enough to allow the process to exit.
                System.exit(0);
            }

        } catch (Throwable t) {
            String message = t.getMessage();
            t.printStackTrace();
            System.exit(1);
        }

    }

    /**
     * A WindowAdapter subclass that causes the application to exit when its
     * {@link #windowClosing(WindowEvent)} method is invoked.
     */
    private static class ChildWindowAdapter extends WindowAdapter {

        /**
         * Invoked when a window is in the process of being closed.
         *
         * @param e the event
         */
        public void windowClosing(WindowEvent e) {

            System.exit(0);

        }

    }

}
commons-launcher/src/java/org/apache/commons/launcher/ExitOnErrorThreadGroup.java100644      0      0       14267  7556150226  25725 0ustar     0      0 /* ========================================================================= *
 *                                                                           *
 *                 The Apache Software License,  Version 1.1                 *
 *                                                                           *
 *             Copyright (c) 2002 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",  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.commons.launcher;

/**
 * A class that subclasses the {@link ThreadGroup} class. This class is used
 * by {@link ChildMain#main(String[])} to run the target application. By using
 * this class, any {@link Error} other than {@link ThreadDeath} thrown by
 * threads created by the target application will be caught the process
 * terminated. By default, the JVM will only print a stack trace of the
 * {@link Error} and destroy the thread. However, when an uncaught
 * {@link Error} occurs, it normally means that the JVM has encountered a
 * severe problem. Hence, an orderly shutdown is a reasonable approach.
 * <p>
 * Note: not all threads created by the target application are guaranteed to
 * use this class. Target application's may bypass this class by creating a
 * thread using the {@link Thread#Thread(ThreadGroup, String)} or other similar
 * constructors.
 *
 * @author Patrick Luby
 */
public class ExitOnErrorThreadGroup extends ThreadGroup {

    //------------------------------------------------------------ Constructors

    /**
     * Constructs a new thread group. The parent of this new group is the
     * thread group of the currently running thread.
     *
     * @param name the name of the new thread group
     */
    public ExitOnErrorThreadGroup(String name) {

        super(name);

    }

    //----------------------------------------------------------------- Methods

    /**
     * Trap any uncaught {@link Error} other than {@link ThreadDeath} and exit.
     *
     * @param t the thread that is about to exit
     * @param e the uncaught exception
     */
    public void uncaughtException(Thread t, Throwable e) {

        if (e instanceof ThreadDeath)
            return;

        Launcher.error(e);
        System.exit(1);

    }

}
commons-launcher/src/java/org/apache/commons/launcher/LaunchCommand.java100644      0      0       42637  7556150226  24053 0ustar     0      0 /* ========================================================================= *
 *                                                                           *
 *                 The Apache Software License,  Version 1.1                 *
 *                                                                           *
 *             Copyright (c) 2002 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",  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.commons.launcher;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;

/**
 * A class that represents the holds the various argument types that are used
 * in a Java command. In addition, it holds many of the flags that are used
 * by the {@link LaunchTask} class when executing a JVM process.
 *
 * @author Patrick Luby
 */
public class LaunchCommand {

    //------------------------------------------------------------------ Fields

    /**
     * Cached appendOutput flag.
     */
    private boolean appendOutput = false;

    /**
     * Cached classpath.
     */
    private String classpath = null;

    /**
     * Cached debug flag.
     */
    private boolean debug = false;

    /**
     * Cached displayMinimizedWindow flag.
     */
    private boolean displayMinimizedWindow = false;

    /**
     * Cached disposeMinimizedWindow flag.
     */
    private boolean disposeMinimizedWindow = true;

    /**
     * Cached failOnError flag.
     */
    private boolean failOnError = true;

    /**
     * Cached main class name.
     */
    private String mainClassName = null;

    /**
     * Cached minimizedWindowIcon.
     */
    private File minimizedWindowIcon = null;

    /**
     * Cached minimizedWindowTitle.
     */
    private String minimizedWindowTitle = null;

    /**
     * Cached output file.
     */
    private File outputFile = null;

    /**
     * Cached print flag.
     */
    private boolean print = false;

    /**
     * Cached requireTools flag.
     */
    private boolean requireTools = false;

    /**
     * Cached redirect flag.
     */
    private boolean redirect = false;

    /**
     * Cached arg elements
     */
    private ArrayList args = null;

    /**
     * Cached jvmarg elements
     */
    private ArrayList jvmArgs = null;

    /**
     * Cached sysproperty elements
     */
    private HashMap sysProperties = null;

    /**
     * Cached useSystemIn flag.
     */
    private boolean useSystemIn = true;

    /**
     * Cached waitForChild flag.
     */
    private boolean waitForChild = true;

    //----------------------------------------------------------------- Methods

    /**
     * Get the class name.
     *
     * @return the class to execute <code>main(String[])</code>
     */
    public String getClassname() {

        return mainClassName;

    }

    /**
     * Get the classpath.
     *
     * @return the classpath
     */
    public String getClasspath() {

        return classpath;

    }

    /**
     * Get the debug flag.
     *
     * @return the debug flag
     */
    public boolean getDebug() {

        return debug;

    }

    /**
     * Get the displayMinimizedWindow flag.
     *
     * @return the displayMinimizedWindow flag
     */
    public boolean getDisplayminimizedwindow() {

        return displayMinimizedWindow;

    }

    /**
     * Get the disposeMinimizedWindow flag.
     *
     * @return the disposeMinimizedWindow flag
     */
    public boolean getDisposeminimizedwindow() {

        return disposeMinimizedWindow;

    }

    /**
     * Get the failOnError flag.
     *
     * @return the failOnError flag
     */
    public boolean getFailonerror() {

        return failOnError;

    }

    /**
     * Get the title for the minimized window that will be displayed in the
     * Windows taskbar.
     *
     * @return the title to set for any minimized window that is displayed
     *  in the Windows taskbar
     */
    public String getMinimizedwindowtitle() {

        return minimizedWindowTitle;

    }

    /**
     * Get the icon file for the minimized window that will be displayed in the
     * Windows taskbar.
     *
     * @return the icon file to use for any minimized window that is displayed
     *  in the Windows taskbar
     */
    public File getMinimizedwindowicon() {

        return minimizedWindowIcon;

    }

    /**
     * Get the file that the child JVM's System.out and System.err will be
     * redirected to.
     *
     * @return the File to redirect System.out and System.err to
     */
    public File getOutput() {

        return outputFile;

    }

    /**
     * Get the appendOutput flag.
     *
     * @return the appendOutput flag
     */
    public boolean getAppendoutput() {

        return appendOutput;

    }

    /**
     * Get the redirect flag.
     *
     * @return the redirect flag
     */
    public boolean getRedirectoutput() {

        return redirect;

    }

    /**
     * Get the list of nested arg elements.
     *
     * @return the list of {@link String} objects
     */
    public ArrayList getArgs() {

        return args;

    }

    /**
     * Get the list of nested jvmarg elements.
     *
     * @return the list of {@link String} objects
     */
    public ArrayList getJvmargs() {

        return jvmArgs;

    }

    /**
     * Get the print flag.
     *
     * @return the print flag
     */
    public boolean getPrint() {

        return print;

    }

    /**
     * Get the requireTools flag.
     *
     * @return the requireTools flag
     */
    public boolean getRequiretools() {

        return requireTools;

    }

    /**
     * Get the list of nested sysproperty elements.
     *
     * @return the {@link String} objects
     */
    public HashMap getSysproperties() {

        return sysProperties;

    }

    /**
     * Get the useSystemIn flag.
     *
     * @return the useSystemIn flag
     */
    public boolean getUsesystemin() {

        return useSystemIn;

    }

    /**
     * Get the waitForChild flag.
     *
     * @return the waitForChild flag
     */
    public boolean getWaitforchild() {

        return waitForChild;

    }

    /**
     * Set the print flag.
     *
     * @param print the print flag
     */
    public void setPrint(boolean print) {

        this.print = print;

    }

    /**
     * Set the requireTools flag.
     *
     * @param requireTools the requireTools flag
     */
    public void setRequiretools(boolean requireTools) {

        this.requireTools = requireTools;

    }

    /**
     * Set the useSystemIn flag. Setting this flag to false will cause this
     * task to not read System.in. This will cause the child JVM to never
     * receive any bytes when it reads System.in. Setting this flag to false
     * is useful in some Unix environments where processes cannot be put in
     * the background when they read System.in.
     *
     * @param useSystemIn the useSystemIn flag
     */
    public void setUsesystemin(boolean useSystemIn) {

        this.useSystemIn = useSystemIn;

    }

    /**
     * Set the waitForChild flag. Setting this flag to true will cause this
     * task to wait for the child JVM to finish executing before the task
     * completes. Setting this flag to false will cause this task to complete
     * immediately after it starts the execution of the child JVM. Setting it
     * false emulates the "&" background operator in most Unix shells and is
     * most of set to false when launching server or GUI applications.
     *
     * @param waitForChild the waitForChild flag
     */
    public void setWaitforchild(boolean waitForChild) {

        this.waitForChild = waitForChild;

    }

    /**
     * Set the class name.
     *
     * @param mainClassName the class to execute <code>main(String[])</code>
     */
    public void setClassname(String mainClassName) {

        this.mainClassName = mainClassName;

    }

    /**
     * Set the classpath.
     *
     * @param classpath the classpath
     */
    public void setClasspath(String classpath) {

        this.classpath = classpath;

    }

    /**
     * Set the debug flag.
     *
     * @param debug the debug flag 
     */
    public void setDebug(boolean debug) {

        this.debug = debug;

    }

    /**
     * Set the displayMinimizedWindow flag. Note that this flag has no effect
     * on non-Windows platforms. On Windows platform, setting this flag to true
     * will cause a minimized window to be displayed in the Windows task bar
     * while the child process is executing. This flag is usually set to true
     * for server applications that also have their "waitForChild" attribute
     * set to false via the {@link #setWaitforchild(boolean)} method.
     *
     * @param displayMinimizedWindow true if a minimized window should be
     *  displayed in the Windows task bar while the child process is executing 
     */
    public void setDisplayminimizedwindow(boolean displayMinimizedWindow) {

        this.displayMinimizedWindow = displayMinimizedWindow;

    }

    /**
     * Set the disposeMinimizedWindow flag. Note that this flag has no effect
     * on non-Windows platforms. On Windows platform, setting this flag to true
     * will cause any minimized window that is display by setting the
     * "displayMinimizedWindow" attribute to true via the
     * {@link #setDisplayminimizedwindow(boolean)} to be automatically
     * disposed of when the child JVM's <code>main(String[])</code> returns.
     * This flag is normally used for applications that don't explicitly call
     * {@link System#exit(int)}. If an application does not explicitly call
     * {@link System#exit(int)}, an minimized windows need to be disposed of
     * for the child JVM to exit.
     *
     * @param disposeMinimizedWindow true if a minimized window in the Windows
     *  taskbar should be automatically disposed of after the child JVM's
     *  <code>main(String[])</code> returns
     */
    public void setDisposeminimizedwindow(boolean disposeMinimizedWindow) {

        this.disposeMinimizedWindow = displayMinimizedWindow;

    }

    /**
     * Set the failOnError flag.
     *
     * @param failOnError the failOnError flag 
     */
    public void setFailonerror(boolean failOnError) {

        this.failOnError = failOnError;

    }

    /**
     * Set the title for the minimized window that will be displayed in the
     * Windows taskbar. Note that this property has no effect on non-Windows
     * platforms.
     *
     * @param minimizedWindowTitle the title to set for any minimized window
     *  that is displayed in the Windows taskbar
     */
    public void setMinimizedwindowtitle(String minimizedWindowTitle) {

        this.minimizedWindowTitle = minimizedWindowTitle;

    }

    /**
     * Set the icon file for the minimized window that will be displayed in the
     * Windows taskbar. Note that this property has no effect on non-Windows
     * platforms.
     *
     * @param minimizedWindowIcon the icon file to use for any minimized window
     *  that is displayed in the Windows taskbar
     */
    public void setMinimizedwindowicon(File minimizedWindowIcon) {

        this.minimizedWindowIcon = minimizedWindowIcon;

    }

    /**
     * Set the file that the child JVM's System.out and System.err will be
     * redirected to. Output will only be redirected if the redirect flag
     * is set to true via the {@link #setRedirectoutput(boolean)} method.
     *
     * @param outputFile a File to redirect System.out and System.err to
     */
    public void setOutput(File outputFile) {

        this.outputFile = outputFile;

    }

    /**
     * Set the appendOutput flag. Setting this flag to true will cause the child
     * JVM to append System.out and System.err to the file specified by the
     * {@link #setOutput(File)} method. Setting this flag to false will cause
     * the child to overwrite the file.
     *
     * @param appendOutput true if output should be appended to the output file
     */
    public void setAppendoutput(boolean appendOutput) {

        this.appendOutput = appendOutput;

    }

    /**
     * Set the list of nested arg elements.
     *
     * @param args a list of {@link String} objects
     */
    public void setArgs(ArrayList args) {

        this.args = args;

    }

    /**
     * Set the list of nested jvmarg elements.
     *
     * @param jvmArgs a list of {@link String} objects
     */
    public void setJvmargs(ArrayList jvmArgs) {

        this.jvmArgs = jvmArgs;

    }

    /**
     * Set the list of nested sysproperty elements.
     *
     * @param sysProperties a map of {@link String} objects
     */
    public void setSysproperties(HashMap sysProperties) {

        this.sysProperties = sysProperties;

    }

    /**
     * Set the redirect flag. Setting this flag to true will cause the child
     * JVM's System.out and System.err to be redirected to file set using the
     * {@link #setOutput(File)} method. Setting this flag to false will
     * cause no redirection.
     *
     * @param redirect true if System.out and System.err should be redirected
     */
    public void setRedirectoutput(boolean redirect) {

        this.redirect = redirect;

    }

}
commons-launcher/src/java/org/apache/commons/launcher/LaunchFilter.java100644      0      0       13662  7556150226  23716 0ustar     0      0 /* ========================================================================= *
 *                                                                           *
 *                 The Apache Software License,  Version 1.1                 *
 *                                                                           *
 *             Copyright (c) 2002 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",  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.commons.launcher;

import org.apache.tools.ant.BuildException;

/**
 * An interface that provides a means for application developers to perform
 * dynamic configuration and error checking of the attributes and nested
 * elements associated with a "launch" task that connot be easily done within 
 * the constraints of Ant.
 * <p>
 * An implementor of this interface can be attached to a "launch" task by
 * setting the following "launch" task attributes in the Launcher's XML
 * file:
 * <ul>
 * <li><code>filterclassname</code> - The name of the class that implements
 * this interface
 * <li><code>filterclasspath</code> - (Optional) The classpath for the class
 * that implements
 * </ul>
 *
 * @author Patrick Luby
 */
public interface LaunchFilter {

    //----------------------------------------------------------------- Methods

    /**
     * Perform error checking and editing of the JVM command line arguments
     * that an instance of the {@link LaunchTask} class has constructed.
     * Implementors will receive an instance of the {@link LaunchCommand} from
     * the {@link LaunchTask} instance that invokes this method. The
     * implementor of this method can then retrieve and edit any of the
     * JVM command line arguments via the {@link LaunchCommand} class' public
     * methods.
     *
     * @param launchCommand a configured {@link LaunchCommand} instance
     * @throws BuildException if any errors occur
     */
    public void filter(LaunchCommand launchCommand) throws BuildException;

}
commons-launcher/src/java/org/apache/commons/launcher/LaunchTask.java100644      0      0      121774  7556150226  23417 0ustar     0      0 /* ========================================================================= *
 *                                                                           *
 *                 The Apache Software License,  Version 1.1                 *
 *                                                                           *
 *             Copyright (c) 2002 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",  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.commons.launcher;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.StringTokenizer;
import org.apache.commons.launcher.types.ArgumentSet;
import org.apache.commons.launcher.types.ConditionalArgument;
import org.apache.commons.launcher.types.ConditionalVariable;
import org.apache.commons.launcher.types.JVMArgumentSet;
import org.apache.commons.launcher.types.SysPropertySet;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.types.Reference;

/**
 * A class that eliminates the need for a batch or shell script to launch a Java
 * class. Some situations where elimination of a batch or shell script may be 
 * desirable are:
 * <ul>
 * <li>You want to avoid having to determining where certain application paths
 *  are e.g. your application's home directory, etc. Determining this
 *  dynamically in a Windows batch scripts is very tricky on some versions of
 *  Windows or when softlinks are used on Unix platforms.
 * <li>You want to avoid having to handle native file and path separators or
 *  native path quoting issues.
 * <li>You need to enforce certain system properties e.g.
 *  <code>java.endorsed.dirs</code> when running with JDK 1.4.
 * <li>You want to allow users to pass in custom JVM arguments or system
 *  properties without having to parse and reorder arguments in your script.
 *  This can be tricky and/or messy in batch and shell scripts.
 * <li>You want to bootstrap system properties from a configuration file instead
 *  hard-coding them in your batch and shell scripts.
 * <li>You want to provide localized error messages which is very tricky to do
 *  in batch and shell scripts.
 * </ul>
 *
 * @author Patrick Luby
 */
public class LaunchTask extends Task {

    //----------------------------------------------------------- Static Fields

    /**
     * The argument property name.
     */
    public final static String ARG_PROP_NAME = "launch.arg.";

    /**
     * The name of this task.
     */
    public final static String TASK_NAME = "launch";

    /**
     * Cached synchronous child processes for all instances of this class.
     */
    private static ArrayList childProcesses = new ArrayList();

    //------------------------------------------------------------------ Fields

    /**
     * Cached appendOutput flag.
     */
    private boolean appendOutput = false;

    /**
     * Cached synchronously executing child process.
     */
    private Process childProc = null;

    /**
     * Cached classpath.
     */
    private Path classpath = null;

    /**
     * Cached debug flag.
     */
    private boolean debug = false;

    /**
     * Cached displayMinimizedWindow flag.
     */
    private boolean displayMinimizedWindow = false;

    /**
     * Cached disposeMinimizedWindow flag.
     */
    private boolean disposeMinimizedWindow = true;

    /**
     * Cached failOnError flag.
     */
    private boolean failOnError = false;

    /**
     * Cached filter instance.
     */
    private LaunchFilter filter = null;

    /**
     * Cached filterClassName.
     */
    private String filterClassName = null;

    /**
     * Cached filterClasspath.
     */
    private Path filterClasspath = null;

    /**
     * Cached main class name.
     */
    private String mainClassName = null;

    /**
     * Cached minimizedWindowIcon.
     */
    private File minimizedWindowIcon = null;

    /**
     * Cached minimizedWindowTitle.
     */
    private String minimizedWindowTitle = null;

    /**
     * Cached output file.
     */
    private File outputFile = null;

    /**
     * Cached print flag.
     */
    private boolean print = false;

    /**
     * Cached redirect flag.
     */
    private boolean redirect = false;

    /**
     * Cached requireTools flag.
     */
    private boolean requireTools = false;

    /**
     * Cached arg elements
     */
    private ArgumentSet taskArgumentSet = new ArgumentSet();

    /**
     * Cached jvmarg elements
     */
    private JVMArgumentSet taskJVMArgumentSet = new JVMArgumentSet();

    /**
     * Cached sysproperty elements
     */
    private SysPropertySet taskSysPropertySet = new SysPropertySet();

    /**
     * Cached useArgs flag.
     */
    private boolean useArgs = true;

    /**
     * Cached useSystemIn flag.
     */
    private boolean useSystemIn = true;

    /**
     * Cached waitForChild flag.
     */
    private boolean waitForChild = true;

    //---------------------------------------------------------- Static Methods

    /**
     * Get the synchronous child processes for all instances of this class.
     *
     * @return the instances of this class.
     */
    public static Process[] getChildProcesses() {

        return (Process[])childProcesses.toArray(new Process[childProcesses.size()]);

    }

    //----------------------------------------------------------------- Methods

    /**
     * Add a nested arg element. Note that Ant will not invoke the specified
     * arg object's setter methods until after Ant invokes this method so
     * processing of the specified arg object is handled in the
     * {@link #execute()} method.
     *
     * @param arg the arg element
     */
    public void addArg(ConditionalArgument arg) {

        taskArgumentSet.addArg(arg);

    }

    /**
     * Add a nested argset element.
     *
     * @param set the argset element
     */
    public void addArgset(ArgumentSet set) {

        taskArgumentSet.addArgset(set);

    }

    /**
     * Add a nested jvmarg element. Note that Ant will not invoke the specified
     * jvmarg object's setter methods until after Ant invokes this method so
     * processing of the specified jvmarg object is handled in the
     * {@link #execute()} method.
     *
     * @param jvmArg the jvmarg element
     */
    public void addJvmarg(ConditionalArgument jvmArg) {

        taskJVMArgumentSet.addJvmarg(jvmArg);

    }

    /**
     * Add a nested jvmargset element.
     *
     * @param set the jvmargset element
     */
    public void addJvmargset(JVMArgumentSet set) {

        taskJVMArgumentSet.addJvmargset(set);

    }

    /**
     * Add a nested sysproperty element. Note that Ant will not invoke the
     * specified sysproperty object's setter methods until after Ant invokes
     * this method so processing of the specified sysproperty object is handled
     * in the {@link #execute()} method.
     *
     * @param var the sysproperty element
     */
    public void addSysproperty(ConditionalVariable var) {

        taskSysPropertySet.addSysproperty(var);

    }

    /**
     * Add a nested syspropertyset element.
     *
     * @param set the syspropertyset element
     */
    public void addSyspropertyset(SysPropertySet set) {

        taskSysPropertySet.addSyspropertyset(set);

    }

    /**
     * Create a nested classpath element.
     *
     * @return the Path object that contains all nested classpath elements
     */
    public Path createClasspath() {

        if (classpath == null)
            classpath = new Path(project);
        return classpath;

    }

    /**
     * Create a nested filter classpath element.
     *
     * @return the Path object that contains all nested filter classpath
     *  elements
     */
    public Path createFilterclasspath() {

        if (filterClasspath == null)
            filterClasspath = new Path(project);
        return filterClasspath;

    }

    /**
     * Construct a Java command and execute it using the settings that Ant
     * parsed from the Launcher's XML file. This method is called by the Ant
     * classes.
     *
     * @throws BuildException if there is a configuration or other error
     */
    public void execute() throws BuildException {

        try {

            // Check that the Launcher class was used to start Ant as this
            // task is not designed to use in a standalone Ant installation
            if (!Launcher.isStarted())
                throw new BuildException(Launcher.getLocalizedString("no.run.standalone", this.getClass().getName()));

            // Don't do anything if the launching process has been stopped
            if (Launcher.isStopped())
                throw new BuildException();

            if (mainClassName == null)
                throw new BuildException(Launcher.getLocalizedString("classname.null", this.getClass().getName()));

            // Copy all of the nested jvmarg elements into the jvmArgs object
            ArrayList taskJVMArgs = taskJVMArgumentSet.getList();
            ArrayList jvmArgs = new ArrayList(taskJVMArgs.size());
            for (int i = 0; i < taskJVMArgs.size(); i++) {
                ConditionalArgument value = (ConditionalArgument)taskJVMArgs.get(i);
                // Test "if" and "unless" conditions
                if (testIfCondition(value.getIf()) && testUnlessCondition(value.getUnless())) {
                    String[] list = value.getParts();
                    for (int j = 0; j < list.length; j++)
                        jvmArgs.add(list[j]);
                }
            }

            // Copy all of the nested sysproperty elements into the sysProps
            // object
            ArrayList taskSysProps = taskSysPropertySet.getList();
            HashMap sysProps = new HashMap(taskSysProps.size());
            for (int i = 0; i < taskSysProps.size(); i++) {
                ConditionalVariable variable = (ConditionalVariable)taskSysProps.get(i);
                // Test "if" and "unless" conditions
                if (testIfCondition(variable.getIf()) && testUnlessCondition(variable.getUnless()))
                    sysProps.put(variable.getKey(), variable.getValue());
            }

            // Copy all of the nested arg elements into the appArgs object
            ArrayList taskArgs = taskArgumentSet.getList();
            ArrayList appArgs = new ArrayList(taskArgs.size());
            for (int i = 0; i < taskArgs.size(); i++) {
                ConditionalArgument value = (ConditionalArgument)taskArgs.get(i);
                // Test "if" and "unless" conditions
                if (testIfCondition(value.getIf()) && testUnlessCondition(value.getUnless())) {
                    String[] list = value.getParts();
                    for (int j = 0; j < list.length; j++)
                        appArgs.add(list[j]);
                }
            }

            // Add the Launcher's command line arguments to the appArgs object
            if (useArgs) {
                int currentArg = 0;
                String arg = null;
                while ((arg = project.getUserProperty(LaunchTask.ARG_PROP_NAME + Integer.toString(currentArg++))) != null)
                    appArgs.add(arg);
            }

            // Make working copies of some of the flags since they may get
            // changed by a filter class
            String filteredClasspath = null;
            if (classpath != null)
                filteredClasspath = classpath.toString();
            String filteredMainClassName = mainClassName;
            boolean filteredRedirect = redirect;
            File filteredOutputFile = outputFile;
            boolean filteredAppendOutput = appendOutput;
            boolean filteredDebug = debug;
            boolean filteredDisplayMinimizedWindow = displayMinimizedWindow;
            boolean filteredDisposeMinimizedWindow = disposeMinimizedWindow;
            boolean filteredFailOnError = failOnError;
            String filteredMinimizedWindowTitle = minimizedWindowTitle;
            File filteredMinimizedWindowIcon = minimizedWindowIcon;
            boolean filteredPrint = print;
            boolean filteredRequireTools = requireTools;
            boolean filteredU