tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r742952 - in /tuscany/java/sca: distribution/all/src/main/release/launcher/default.config modules/launcher/src/main/java/org/apache/tuscany/sca/launcher/LauncherMain.java
Date Tue, 10 Feb 2009 12:26:03 GMT
Author: antelder
Date: Tue Feb 10 12:25:54 2009
New Revision: 742952

URL: http://svn.apache.org/viewvc?rev=742952&view=rev
Log:
Simplify launcher default config so it can automatically determine to use unmanaged jar

Modified:
    tuscany/java/sca/distribution/all/src/main/release/launcher/default.config
    tuscany/java/sca/modules/launcher/src/main/java/org/apache/tuscany/sca/launcher/LauncherMain.java

Modified: tuscany/java/sca/distribution/all/src/main/release/launcher/default.config
URL: http://svn.apache.org/viewvc/tuscany/java/sca/distribution/all/src/main/release/launcher/default.config?rev=742952&r1=742951&r2=742952&view=diff
==============================================================================
--- tuscany/java/sca/distribution/all/src/main/release/launcher/default.config (original)
+++ tuscany/java/sca/distribution/all/src/main/release/launcher/default.config Tue Feb 10
12:25:54 2009
@@ -1,5 +1,5 @@
 classpath=modules/**
-mainClass=org.apache.tuscany.sca.node.NodeMain2
+mainClass=[firstArgJarManifestMainClass]|org.apache.tuscany.sca.node.NodeMain2
 -Djava.util.logging.config.file={TUSCANY_HOME}/samples/logging.properties
 
 

Modified: tuscany/java/sca/modules/launcher/src/main/java/org/apache/tuscany/sca/launcher/LauncherMain.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/launcher/src/main/java/org/apache/tuscany/sca/launcher/LauncherMain.java?rev=742952&r1=742951&r2=742952&view=diff
==============================================================================
--- tuscany/java/sca/modules/launcher/src/main/java/org/apache/tuscany/sca/launcher/LauncherMain.java
(original)
+++ tuscany/java/sca/modules/launcher/src/main/java/org/apache/tuscany/sca/launcher/LauncherMain.java
Tue Feb 10 12:25:54 2009
@@ -95,6 +95,10 @@
         } else {
             mainClassName = launcherProperties.getProperty(CONFIG_MAIN_CLASS);
         }
+
+        if (mainClassName.startsWith(CONFIG_ARG_JAR_MAIN + "|")) {
+            mainClassName = mainClassName.substring(CONFIG_ARG_JAR_MAIN.length()+1);
+        }
         
         return mainClassName;
     }
@@ -120,8 +124,10 @@
             String pn = (String) e.nextElement();
             if (pn.startsWith(CONFIG_CLASSPATH)) {
                 jarURLs.addAll(getJARs(launcherProperties.getProperty(pn), launcherProperties));
-            } else if (pn.equals(CONFIG_MAIN_CLASS) && launcherProperties.getProperty(pn).equals(CONFIG_ARG_JAR_MAIN))
{
-                jarURLs.add(firstArgJarManifestMainClass(launcherProperties));
+            } else if (pn.equals(CONFIG_MAIN_CLASS) && launcherProperties.getProperty(pn).startsWith(CONFIG_ARG_JAR_MAIN))
{
+                if (firstArgJarHasManifestMainClass(launcherProperties)) {
+                    jarURLs.add(firstArgJarManifestMainClass(launcherProperties));
+                }
             }
         }
         ClassLoader parentCL = Thread.currentThread().getContextClassLoader();
@@ -150,6 +156,19 @@
         return f.toURL();
     }
 
+    private static boolean firstArgJarHasManifestMainClass(Properties launcherProperties)
throws IOException {
+        String[] args = (String[])launcherProperties.get(LAUNCHER_ARGS);
+        if (args.length < 1) {
+            return false;
+        }
+        File f = new File(args[0]);
+        if (!f.exists()) {
+            return false;
+        }
+        JarFile jar = new JarFile(f);
+        String mfc = jar.getManifest().getMainAttributes().getValue("Main-Class");
+        return mfc != null && mfc.length() > 0;
+    }
     /**
      * Gets the jars matching a config classpath property
      * property values may be an explicit jar name or use an asterix wildcard for



Mime
View raw message