diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2009-02-10 12:25:54 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2009-02-10 12:25:54 +0000 |
commit | 55b540f9e811904e259aae9be278bc4e41302619 (patch) | |
tree | 3671a14bd70eff29120842fd76edf801110fbe8d /java/sca/modules/launcher | |
parent | 432342ef94e6c9cae00024a2abd0ac2f5422173c (diff) |
Simplify launcher default config so it can automatically determine to use unmanaged jar
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@742952 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/launcher')
-rw-r--r-- | java/sca/modules/launcher/src/main/java/org/apache/tuscany/sca/launcher/LauncherMain.java | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/java/sca/modules/launcher/src/main/java/org/apache/tuscany/sca/launcher/LauncherMain.java b/java/sca/modules/launcher/src/main/java/org/apache/tuscany/sca/launcher/LauncherMain.java index 35e6060d0f..026ed04055 100644 --- a/java/sca/modules/launcher/src/main/java/org/apache/tuscany/sca/launcher/LauncherMain.java +++ b/java/sca/modules/launcher/src/main/java/org/apache/tuscany/sca/launcher/LauncherMain.java @@ -95,6 +95,10 @@ public class LauncherMain { } 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 @@ public class LauncherMain { 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 @@ public class LauncherMain { 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
|