From 9c2568da6dcc511852fcda7399407a7ff3047940 Mon Sep 17 00:00:00 2001 From: antelder Date: Thu, 29 Jan 2009 07:50:39 +0000 Subject: Updates to the launcher classpath and properties processing git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@738786 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/tuscany/sca/launcher/LauncherMain.java | 42 ++++++++++++---------- 1 file changed, 24 insertions(+), 18 deletions(-) (limited to 'java/sca/modules/launcher/src') 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 514e00fc60..c3b05b5ae6 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 @@ -22,6 +22,7 @@ package org.apache.tuscany.sca.launcher; import java.io.File; import java.io.FileFilter; import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.FilenameFilter; import java.io.IOException; import java.lang.reflect.InvocationTargetException; @@ -40,7 +41,7 @@ public class LauncherMain { private static final String DEFAULT_PROPERTY_FILENAME = "default.config"; - public static void main(String[] args) throws SecurityException, IllegalArgumentException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, URISyntaxException { + public static void main(String[] args) throws SecurityException, IllegalArgumentException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, URISyntaxException, FileNotFoundException { Properties launcherProperties = getLauncherProperties(args); @@ -99,7 +100,7 @@ public class LauncherMain { } } - private static ClassLoader getClassLoader(Properties launcherProperties) { + private static ClassLoader getClassLoader(Properties launcherProperties) throws URISyntaxException { Set jarURLs = new HashSet(); for (Enumeration e = launcherProperties.propertyNames(); e.hasMoreElements();) { String pn = (String) e.nextElement(); @@ -118,18 +119,29 @@ public class LauncherMain { * Gets the jars matching a config classpath property * property values may be an explicit jar name or use an asterix wildcard for * all jars in a folder, or a double asterix '**' for all jars in a folder and its subfolders + * @throws URISyntaxException */ - private static Set getJARs(String classpathValue) { - Set jarURLs = new HashSet(); + private static Set getJARs(String classpathValue) throws URISyntaxException { + Set jarURLs = new HashSet(); + if (classpathValue.endsWith("**")) { File folder = new File(classpathValue.substring(0, classpathValue.length()-2)); + if (!folder.isAbsolute()) { + folder = new File(getLauncherFolder().getParent(), folder.getName()); + } jarURLs.addAll(getFolderJars(folder)); jarURLs.addAll(getSubFolderJars(folder)); } else if (classpathValue.endsWith("*")) { File folder = new File(classpathValue.substring(0, classpathValue.length()-1)); + if (!folder.isAbsolute()) { + folder = new File(getLauncherFolder(), folder.getName()); + } jarURLs.addAll(getFolderJars(folder)); } else { File f = new File(classpathValue); + if (!f.isAbsolute()) { + f = new File(getLauncherFolder(), classpathValue); + } try { jarURLs.add(f.toURI().toURL()); } catch (MalformedURLException e) { @@ -182,32 +194,26 @@ public class LauncherMain { * Read the config properties for this launcher invocation * (Either default.config or the 1st cmd line argument suffixed with ".config" if that file exists */ - private static Properties getLauncherProperties(String[] args) throws URISyntaxException { + private static Properties getLauncherProperties(String[] args) throws URISyntaxException, FileNotFoundException { Properties properties = new Properties(); - - String fileName; + + File f; if (args.length > 0) { - File f = new File(args[0]); - if (!f.exists()) { - f = new File(getLauncherFolder(), args[0] + ".config"); - } -// File f = new File(getLauncherFolder(), args[0] + ".config"); + f = new File(getLauncherFolder(), args[0] + ".config"); if (f.exists()) { - fileName = f.toString(); String[] args2 = new String[args.length-1]; System.arraycopy(args, 1, args2, 0, args.length-1); args = args2; } else { - fileName = DEFAULT_PROPERTY_FILENAME; + f = new File(getLauncherFolder(), DEFAULT_PROPERTY_FILENAME); } } else { - fileName = DEFAULT_PROPERTY_FILENAME; + f = new File(getLauncherFolder(), DEFAULT_PROPERTY_FILENAME); } - File f = new File(fileName); - if (!f.isAbsolute()) { - f = new File(getLauncherFolder(), fileName); + if (!f.exists()) { + throw new FileNotFoundException(f.getName()); } try { -- cgit v1.2.3