directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: r209556 - in /directory/sandbox/trunk/osgi-core/trunk/launcher: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/launcher/
Date Thu, 07 Jul 2005 00:58:07 GMT
Author: erodriguez
Date: Wed Jul  6 17:58:06 2005
New Revision: 209556

URL: http://svn.apache.org/viewcvs?rev=209556&view=rev
Log:
Example code for programmatically configuring an initial OSCAR container.

Added:
    directory/sandbox/trunk/osgi-core/trunk/launcher/kerberos.sh   (with props)
    directory/sandbox/trunk/osgi-core/trunk/launcher/launcher.bat
    directory/sandbox/trunk/osgi-core/trunk/launcher/launcher.bundle.properties
    directory/sandbox/trunk/osgi-core/trunk/launcher/launcher.system.properties
    directory/sandbox/trunk/osgi-core/trunk/launcher/notes.txt
    directory/sandbox/trunk/osgi-core/trunk/launcher/src/
    directory/sandbox/trunk/osgi-core/trunk/launcher/src/main/
    directory/sandbox/trunk/osgi-core/trunk/launcher/src/main/java/
    directory/sandbox/trunk/osgi-core/trunk/launcher/src/main/java/org/
    directory/sandbox/trunk/osgi-core/trunk/launcher/src/main/java/org/apache/
    directory/sandbox/trunk/osgi-core/trunk/launcher/src/main/java/org/apache/launcher/
    directory/sandbox/trunk/osgi-core/trunk/launcher/src/main/java/org/apache/launcher/Launcher.java

Added: directory/sandbox/trunk/osgi-core/trunk/launcher/kerberos.sh
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/osgi-core/trunk/launcher/kerberos.sh?rev=209556&view=auto
==============================================================================
--- directory/sandbox/trunk/osgi-core/trunk/launcher/kerberos.sh (added)
+++ directory/sandbox/trunk/osgi-core/trunk/launcher/kerberos.sh Wed Jul  6 17:58:06 2005
@@ -0,0 +1,70 @@
+#!/bin/sh
+#
+# The Kerberos command script
+#
+# Environment Variables
+#
+#   KERBEROS_JAVA_HOME The java implementation to use.  Default is
+#                      assumed to be located at /usr/bin/java.
+#
+#   KERBEROS_HOME      The path that the KERBEROS server is to be run
+#                      within. Default is the parent directory.
+#
+#   KERBEROS_LIB       The path containing the Java archives.
+#
+
+THIS="$0"
+
+while [ -h "$THIS" ]; do
+  ls=`ls -ld "$THIS"`
+  LINK=`expr "$ls" : '.*-> \(.*\)$'`
+  if expr "$LINK" : '.*/.*' > /dev/null; then
+    THIS="$LINK"
+  else
+    THIS=`dirname "$THIS"`/"$LINK"
+  fi
+done
+
+if [ "$KERBEROS_HOME" = '' ] ; then
+   THIS_DIR=`dirname "$THIS"`
+   KERBEROS_HOME=`cd "$THIS_DIR/.." ; pwd`
+fi
+
+cd $KERBEROS_HOME
+
+if [ "$KERBEROS_LIB" = '' ] ; then
+   KERBEROS_LIB="$KERBEROS_HOME/lib"
+fi
+
+for JAR in `ls $KERBEROS_LIB/*.jar`; do
+   if [ "$CLASS_PATH" != '' ] ; then
+      CLASS_PATH="$CLASS_PATH:$JAR"
+   elif [ "$JAR" != '' ] ; then
+      CLASS_PATH="$KERBEROS_LIB:$JAR"
+   fi
+done
+
+if [ "$KERBEROS_JAVA_HOME" = '' ] ; then
+   if [ "$JAVA_HOME" = '' ] ; then
+      KERBEROS_JAVA_HOME='/usr'
+   else
+      KERBEROS_JAVA_HOME="$JAVA_HOME"
+   fi
+fi
+
+case "$1" in
+   start)
+      if [ -f "$KERBEROS_JAVA_HOME/bin/java" ] ; then
+         $KERBEROS_JAVA_HOME/bin/java -server -classpath $CLASS_PATH -Dserver.properties=server.properties
org.apache.kerberos.kdc.server.udp.Main > /dev/null 2>&1 &
+      fi
+   ;;
+   stop)
+      if [ -f /usr/bin/pkill ] ; then
+         /usr/bin/pkill -f KERBEROS
+      fi 
+   ;;
+   *)
+   echo "Usage: $0 { start | stop }"
+esac
+exit 0
+

Propchange: directory/sandbox/trunk/osgi-core/trunk/launcher/kerberos.sh
------------------------------------------------------------------------------
    svn:executable = *

Added: directory/sandbox/trunk/osgi-core/trunk/launcher/launcher.bat
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/osgi-core/trunk/launcher/launcher.bat?rev=209556&view=auto
==============================================================================
--- directory/sandbox/trunk/osgi-core/trunk/launcher/launcher.bat (added)
+++ directory/sandbox/trunk/osgi-core/trunk/launcher/launcher.bat Wed Jul  6 17:58:06 2005
@@ -0,0 +1,17 @@
+@echo off
+rem find VTMP_HOME
+if "%VTMP_HOME%"=="" goto noHome
+
+set VTMPPROFILE=%1
+if "%VTMPPROFILE%"=="" set VTMPPROFILE=vtmp
+
+"%JAVA_HOME%\bin\java" -Xmx400m -Dvtmp.home="%VTMP_HOME%" -jar "%VTMP_HOME%\lib\launch.jar"
vtmp %VTMPPROFILE%
+
+goto :end
+
+:noHome
+echo VTMP_HOME is not set. Please set VTMP_HOME.
+goto end
+
+:end
+

Added: directory/sandbox/trunk/osgi-core/trunk/launcher/launcher.bundle.properties
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/osgi-core/trunk/launcher/launcher.bundle.properties?rev=209556&view=auto
==============================================================================
--- directory/sandbox/trunk/osgi-core/trunk/launcher/launcher.bundle.properties (added)
+++ directory/sandbox/trunk/osgi-core/trunk/launcher/launcher.bundle.properties Wed Jul  6
17:58:06 2005
@@ -0,0 +1,44 @@
+#--------------------------------------------------------------
+# Properties used by VMON 
+#--------------------------------------------------------------
+
+# The following property controls the TCP/IP port used to service HTTP requests.
+# The principle usage of this is by VMON, listening for client from VWIN, 
+# VCOM clients etc. 
+#
+#   (The unusual naming is because VersaTest makes use of the standard OSGi
+#    Web Service property for this purpose, to avoid duplication).
+#
+org.osgi.service.http.port=8080
+
+#--------------------------------------------------------------
+# Properties used by logging 
+#--------------------------------------------------------------
+
+# The following properties control the location and size of the LOG modules 
+# configuration files, log directory, and internal "history" buffer size
+#
+module.log.config=${vtmp.home}/etc/log.lcf
+module.log.dir=${vtmp.home}/var/log
+module.log.history=200
+
+# The following property controls the format patterns of log messages sent to 
+# LOGGER destinations
+#
+module.vlog.logger.pattern=%d{yyMMdd HH:mm:ss,S} %m
+
+module.vlog.qamode.pattern=%m
+
+
+# The following property controls the format pattern of VWIN log message texts.
+# (timing information is included by default).
+#
+module.vlog.vwin.pattern=%m
+
+# **************************************************
+# *** DO NOT MODIFY PROPERITES BELOW THIS POINT ****
+# **************************************************
+
+oscar.shell.console=on
+osgi.shell.telnet=on
+

Added: directory/sandbox/trunk/osgi-core/trunk/launcher/launcher.system.properties
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/osgi-core/trunk/launcher/launcher.system.properties?rev=209556&view=auto
==============================================================================
--- directory/sandbox/trunk/osgi-core/trunk/launcher/launcher.system.properties (added)
+++ directory/sandbox/trunk/osgi-core/trunk/launcher/launcher.system.properties Wed Jul  6
17:58:06 2005
@@ -0,0 +1,17 @@
+#--------------------------------------------------------------
+#	System Properties used by the Oscar OSGi implementation
+#--------------------------------------------------------------
+
+oscar.strict.osgi=false
+
+oscar.auto.install="file:${vtmp.home}/lib/oscar/osgi-service.jar" "file:${vtmp.home}/lib/oscar/osgi-util.jar"
"file:${vtmp.home}/lib/vt.jar"  "file:${vtmp.home}/lib/seclib.jar" "file:${vtmp.home}/lib/userlib.jar"
"file:${vtmp.home}/lib/comms.jar"
+
+#oscar.auto.start="file:${vtmp.home}/lib/modules/log.jar" "file:${vtmp.home}/lib/modules/watchdog.jar"
"file:${vtmp.home}/lib/modules/vmonmgr.jar" "file:${vtmp.home}/lib/modules/vtmp.jar" "file:${vtmp.home}/lib/modules/vmonmp.jar"
"file:${vtmp.home}/lib/modules/discovery.jar"
+oscar.startlevel.framework=4
+oscar.auto.start.1="file:${vtmp.home}/lib/modules/log.jar" "file:${vtmp.home}/lib/modules/watchdog.jar"

+oscar.auto.start.2="file:${vtmp.home}/lib/modules/vmonmgr.jar" "file:${vtmp.home}/lib/modules/vtmp.jar"

+oscar.auto.start.3="file:${vtmp.home}/lib/modules/discovery.jar"
+oscar.auto.start.4="file:${vtmp.home}/lib/modules/vmonmp.jar" 
+
+oscar.localcache.bufsize=32000
+

Added: directory/sandbox/trunk/osgi-core/trunk/launcher/notes.txt
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/osgi-core/trunk/launcher/notes.txt?rev=209556&view=auto
==============================================================================
--- directory/sandbox/trunk/osgi-core/trunk/launcher/notes.txt (added)
+++ directory/sandbox/trunk/osgi-core/trunk/launcher/notes.txt Wed Jul  6 17:58:06 2005
@@ -0,0 +1,74 @@
+Basically, we work as follows:
+
+   * the most important property/setting for us is 'vtmp.home' this is
+     a key base directory, set and used by both developers during code
+     modification depending on build tree and at runtime to control the
+     runtime tree: 'vtmp' is our application abbreviation, so think of
+     this as 'app.home'
+
+   * as developers, we all use a common Ant based build script. This
+     builds jars to a set of key directories depending on purpose:
+
+       ${vtmp.home}/lib - general libraries (a few of these are
+       dual-role and can also be OSGi bundles)
+       ${vtmp.home}/lib/modules - OSGi service bundles
+       ${vtmp.home}/lib/uiservices - GUI service OSGi bundles
+       ${vtmp.home}/lib/oscar- standard Oscar service OSGi bundles
+
+   the ${vtmp.home} is a property expansion I'll explain more later
+
+   * we also have an 'etc' directory where we store config settings,
+     the most important being our Oscar properties files. I've attached
+     a cut-down example of our 'vtmp.system.properties' and
+     'vtmp.bundle.properties' files. You'll notice that all bundle
+     references are relative to ${vtmp.home}. This is a feature of
+     Oscar I convince Richard to include which allows a system/bundle
+     property to be expanded relative to a System property ;)
+
+   * so when we launch Oscar, we just need to set 'vtmp.home' first and
+     it'll load from whichever directory we need (see attached
+     'vtmp.bat' for example)
+
+   * All of our variant programs are launched through a common launcher
+     which, generally, just sets up the appropriate settings and
+     launches Oscar. I've attached a snippet of our VtLauncher.java
+
+   * when we're developing, we work build and test out of the normal
+     filesystem with ${vtmp.home} set to our development tree e.g.
+     e:\data\vtmp, ~/vtmp. The launcher works fine with this as long as
+     vtmp.home is set
+
+   * for distrubition purposes we have a common approach - the Ant
+     build script creates two compressed files a dist.zip (ZIP) and a
+     dist.tgz (tarball). Aside from the compression format, the ZIP has
+     all text files munged to Windows line endings and the TGZ to Unix
+     line endings. The compressed 'dist' file contains :
+
+       ${vmp.home}/lib/* - dir tree of jars
+       ${vmp.home}/etc/* - dir tree of Oscar properties files
+       ${vmp.home}/bin/* - tree of various BAT and other execution wrappers
+       ${vmp.home}/doc/* - doc and help files
+
+   * As far as development/builds that's the end of the story - after
+     that we're into install/deployment tools. Regardless of the tool
+     or approach, the build process exports a standard format: a .zip
+     or .tgz file. The installer then needs to take over in terms of
+     install process
+
+   * What the install tools dom is generally pretty simple:
+
+       * prompt the user for an install.dir
+
+       * expand the .ZIP or .TGZ files
+
+       * munge execution files and/or set environment variables so the
+         vtmp.home = install.dir
+
+       * create platform specific executable wrappers (e.g. .EXE on
+         Windoze) for top level app binaries - in all cases these are
+         simply variations on starting VtLauncher.jar with different
+         paramters
+
+   We happen to use InstallAnywhere (ZeroG) but that's pretty much
+   irrelevant - the approach would work with any installer tool 
+

Added: directory/sandbox/trunk/osgi-core/trunk/launcher/src/main/java/org/apache/launcher/Launcher.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/osgi-core/trunk/launcher/src/main/java/org/apache/launcher/Launcher.java?rev=209556&view=auto
==============================================================================
--- directory/sandbox/trunk/osgi-core/trunk/launcher/src/main/java/org/apache/launcher/Launcher.java
(added)
+++ directory/sandbox/trunk/osgi-core/trunk/launcher/src/main/java/org/apache/launcher/Launcher.java
Wed Jul  6 17:58:06 2005
@@ -0,0 +1,387 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+
+package org.apache.launcher;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.ungoverned.oscar.Oscar;
+
+/**
+ * Launcher.
+ */
+public class Launcher
+{
+    /**  Description of the Field */
+    private final static String DFLT_HOME_KEY = "launcher.home";
+    private final static String DFLT_PROFILE  = "launcher";
+    
+    /** Array of launchable program "names", together with classes which contain their main
methods */
+    private static String[] launchables = { 
+        "app1", "app2", "app3", "app4" 
+        };
+
+    private static String[] mainClasses = { 
+        "com.myco.app1", "com.myco.app2", "com.myco.app3", "com.myco.app4"
+        };
+    
+    private static String launcherHome = "";
+    
+    /**
+     * The main program for the VtLauncher class.
+     *
+     * @param  argv  The command line arguments
+     */
+    public static void main( String[] argv )
+    {
+        if ( argv.length < 1 )
+        {
+            System.err.println( "Fatal error: must specify program to launch" );
+        }
+
+        launcherHome = System.getProperty( DFLT_HOME_KEY );
+        if ( launcherHome == null ) 
+        {
+            throw new IllegalArgumentException ( "launcher.home not set" );
+        }
+
+        // add properties for log4j.root and vtalk.root for those programs
+        // that need it
+        String sp = File.separator;
+        String p = File.pathSeparator;
+        System.setProperty( "log4j.root", 
+                            launcherHome + sp + "lib" + sp + "log4j.jar" );
+        System.setProperty( "vtalk.root", 
+                            launcherHome + sp + "lib" + sp + "vt.jar" + p +
+                            launcherHome + sp + "lib" + sp + "userlib.jar" + p +
+                            launcherHome + sp + "lib" + sp + "comms.jar" + p +
+                            launcherHome + sp + "lib" + sp + "osgi.jar" );
+
+        // Set the SAX driver property for XMLRPC to be the Piccolo driver. 
+        // Its slightly more compliant than the default one (MinML) supplied 
+        // with apache-xmlrpc but is slightly slower. Piccolo handles String 
+        // that are set to all spaces, MinML compresses these to empty strings.
+        // Piccolo is available from http://piccolo.sourceforge.net/.
+        String saxDriver = System.getProperty("sax.driver");
+        if ( ( saxDriver != null ) && ( saxDriver.trim().length() > 0 ) )
+        {
+            // Property passed through to the XML-RPC code XMLRpc.java
+        }
+        else
+        {
+            // Set the driver to piccolo
+            System.setProperty( "sax.driver","com.bluecast.xml.Piccolo" );
+        }
+        
+        // Strip off launch target name from args
+        String launchTarget = argv[ 0 ];
+        String[] launchArgs = new String[ argv.length-1 ];
+        System.arraycopy( argv, 1, launchArgs, 0, argv.length-1 );
+        
+        try
+        {
+            if ( launchTarget.equals( "launcher " ) )
+            {
+                launchVtmp( launchArgs );
+            }
+            else if ( launchTarget.startsWith( "vwin" ) )
+            {
+                launchVwin( launchTarget, launchArgs );
+            }
+            else
+            {
+                launchProg( launchTarget, launchArgs, null );
+            }
+        }
+        catch (Exception e)
+        {
+            System.err.println( "Error launching: " + launchTarget + "," + e );
+            e.printStackTrace( System.err );
+        }
+    }
+    
+    private static void addJarURLs( List list, File dir )
+            throws Exception
+    {
+        File[] all = dir.listFiles();
+        
+        for ( int ix = 0; ix < all.length; ix++ )
+        {
+            // ick, sure there's a better way to do this
+            if ( all[ ix ].toString().toLowerCase().endsWith( ".jar" ) )
+            {
+                list.add( all[ ix ].toURL() );
+            }
+        }
+    }
+    
+    private static ClassLoader createClassLoader()
+            throws Exception
+    {
+        //TODO: consider making this use/load encrypted class files
+
+        List urlList = new ArrayList();
+        addJarURLs( urlList, new File( launcherHome + File.separator + "bin" ) );
+        addJarURLs( urlList, new File( launcherHome + File.separator + "lib" ) );
+        
+        // see if we can find tools.jar (used by VCOMP)
+        File javaHome = new File( System.getProperty( "java.home" ) );
+        File toolsJar = new File( javaHome, "lib" + File.separator + "tools.jar" );
+        
+        if ( !toolsJar.exists() )
+        {
+            toolsJar = new File( javaHome.getParent(), "lib" + File.separator + "tools.jar"
);
+        }
+        //TODO: should we put out warning if not found?
+        urlList.add( toolsJar.toURL() );
+        
+        URL[] urls = (URL[]) urlList.toArray( new URL[ 0 ] );
+        return new URLClassLoader( urls );
+    }
+    
+    private static void deleteOscarHome( String profile )
+        throws IOException
+    {
+        StringBuffer temp = new StringBuffer( 10 );
+
+        String userHome = System.getProperty( "user.home" );
+        File home = new File( userHome );
+
+        temp.append( ".oscar" + File.separator + profile );
+        File oscarHome = new File( home, temp.toString() );
+        
+        Launcher.deleteFiles( oscarHome );
+    }
+
+    /**
+     * Delete all files and directories under the file.
+     *
+     * @param  file             root of files to delete
+     * @exception  IOException  Exception on delete
+     */
+    private static void deleteFiles( File file )
+         throws IOException
+    {
+        File[] list = null;
+        int idx = 0;
+        
+        if ( ! file.exists() )
+        {
+            return;
+        }
+        
+        if ( file.isDirectory() )
+        {
+            list = file.listFiles();
+
+            for ( idx = 0; idx < list.length; idx++ )
+            {
+                deleteFiles( list[ idx ] );
+            }
+            if ( !file.delete() )
+            {
+                throw new IOException( "Unable to delete file " + file.getAbsolutePath()
);
+            }
+        }
+        else
+        {
+            if ( !file.delete() )
+            {
+                throw new IOException( "Unable to delete file " + file.getAbsolutePath()
);
+            }
+        }
+    }
+
+    /**
+     * Launcher for the VT/MP platform itself.
+     *
+     * @param  argv  The command line arguments
+     */
+    private static void launchVtmp( String[] argv )
+            throws Exception
+    {
+        String profile = DFLT_PROFILE;
+        if ( argv.length > 0 )
+        {
+            profile = new String( argv[0] );
+        }
+        
+        // always assume coldstart for now        
+        try 
+        {
+            Launcher.deleteOscarHome( profile );
+        } 
+        catch (IOException e)
+        {
+            System.out.println( "Error removing bundle cache : " + e );
+            //System.exit(-1);
+        }
+
+        // use same name for properties files and oscar profile
+        launchOscar( profile, profile, true );
+    }
+    
+    /**
+     * Launcher for the VWIN.
+     *
+     * @param  argv  The command line arguments
+     */
+    private static void launchVwin( String target, String[] argv ) 
+            throws Exception
+    {
+        boolean coldstart = true;
+        String clientConfig = null;
+        
+        int i = 0;
+        
+        while ( i < argv.length )
+        {
+            if ( argv[ i ].compareToIgnoreCase( "warmstart" ) == 0 )
+            {
+                coldstart = false;
+            }
+            else
+            {
+                clientConfig = argv[ i ];
+                File clientConfigFile = new File( clientConfig );
+                try {
+                    File dir = clientConfigFile.getParentFile();
+                    if ( dir != null && ! dir.exists() )
+                    {
+                        dir.mkdirs();
+                    }
+                    
+                    clientConfigFile.createNewFile();
+                    // Setup the property so that VWIN uses the
+                    // specified client config
+                    System.setProperty( "launcher.ui.vwin.property_file", clientConfigFile.getAbsolutePath()
);
+                } catch (Exception e)
+                {
+                    System.err.println( "Error accessing client config file " + clientConfigFile
+ " : " + e );
+                    return;
+                }
+                
+            }
+            i++;
+        }
+
+        // Try to use a profile
+        int profileOccurence = 1;
+        String profile = target;
+        boolean profileInUse = false;
+        if ( coldstart )
+        {
+            do 
+            { 
+                try 
+                {
+                    Launcher.deleteOscarHome( profile );
+                    profileInUse = false;
+                } 
+                catch (IOException e)
+                {
+                    profileInUse = true;
+                    profile = target + "o" + profileOccurence;
+                    profileOccurence++;
+                    if ( profileOccurence > 100 )
+                    {
+                        System.out.println( "Error starting profile: " + target + " : " +
e );
+                        return;
+                    }
+                    
+                }
+            } while ( profileInUse );
+        }
+
+        launchOscar( target, profile, false );
+    }
+
+    /**
+     * Launcher for Oscar
+     */
+    private static void launchOscar( String propsName, String profile, boolean embedded )
+            throws Exception
+    {
+        String sysProps = launcherHome + File.separator + "etc" + File.separator 
+                 + propsName + ".system.properties";
+        String bundleProps = launcherHome + File.separator + "etc" + File.separator 
+                 + propsName + ".bundle.properties";
+        
+        // used for 1.0.2+ versions of Oscar
+        System.setProperty( "oscar.cache.profile", profile );
+        System.setProperty( "oscar.system.properties", sysProps ); 
+        System.setProperty( "oscar.bundle.properties", bundleProps );
+        System.setProperty( "oscar.strict.osgi","false" );
+        System.setProperty( "oscar.embedded.execution", embedded ? "true" : "false" );
+        
+        Oscar main = new Oscar();                
+    }
+
+    /**
+     * Launcher for all other VT/MP support programs
+     *
+     * @param  argv  The command line arguments
+     */
+    private static void launchProg( String target, String[] argv, ClassLoader loader )
+            throws Exception
+    {
+        //TODO: include debug detect/defeat code
+        if ( loader == null )
+        {
+            loader = createClassLoader();
+        }
+        
+        // for sax, xerces etc.
+        Thread.currentThread().setContextClassLoader( loader );
+        
+        Class cls = null;
+        
+        if ( target.equals( "custom" ) )
+        {
+            // use -D specified main class
+            cls = loader.loadClass( System.getProperty( "launch.custom" ) );
+        }
+        else
+        {
+            // find program's main class from lookup table 
+            for ( int ix = 0; ix < mainClasses.length && cls == null; ix++ )
+            {
+                if ( launchables[ ix ].equals( target ) )
+                {
+                    cls = loader.loadClass( mainClasses[ ix ] );
+                }
+            }
+        }
+        
+        if ( cls != null )
+        {
+            // launch the program's main method
+            Method entry = cls.getMethod( "main", new Class[] { String[].class } );
+            entry.invoke( null, new Object[] { argv } );
+            return;
+        }
+        
+        throw new ClassNotFoundException( "main class for " + target );
+    }
+}
+



Mime
View raw message