X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.osgi.boot%2Fsrc%2Forg%2Fargeo%2Fosgi%2Fboot%2FLauncher.java;h=7fd3e76093767b6259bbc7cdfb829997a2afc6ed;hb=79e0a2a5d751c7c077e52f9ee54469656dc96a44;hp=ccba757d0ee4bf0cd3f951929ead0b93305d88e1;hpb=807ccba419e96a18f7af67a66f986ae4c91c03d9;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.osgi.boot/src/org/argeo/osgi/boot/Launcher.java b/org.argeo.osgi.boot/src/org/argeo/osgi/boot/Launcher.java index ccba757d0..7fd3e7609 100644 --- a/org.argeo.osgi.boot/src/org/argeo/osgi/boot/Launcher.java +++ b/org.argeo.osgi.boot/src/org/argeo/osgi/boot/Launcher.java @@ -18,29 +18,25 @@ package org.argeo.osgi.boot; import java.io.FileInputStream; import java.io.IOException; import java.lang.reflect.Method; +import java.util.ArrayList; import java.util.List; -import java.util.Vector; import org.eclipse.core.runtime.adaptor.EclipseStarter; import org.osgi.framework.BundleContext; /** Command line interface. */ -@SuppressWarnings({ "rawtypes", "unchecked", "restriction" }) public class Launcher { public static void main(String[] args) { // Try to load system properties - String systemPropertiesFilePath = OsgiBootUtils - .getProperty(OsgiBoot.PROP_ARGEO_OSGI_BOOT_SYSTEM_PROPERTIES_FILE); + String systemPropertiesFilePath = getProperty(OsgiBoot.PROP_ARGEO_OSGI_BOOT_SYSTEM_PROPERTIES_FILE); if (systemPropertiesFilePath != null) { FileInputStream in; try { in = new FileInputStream(systemPropertiesFilePath); System.getProperties().load(in); } catch (IOException e1) { - throw new RuntimeException( - "Cannot load system properties from " - + systemPropertiesFilePath, e1); + throw new RuntimeException("Cannot load system properties from " + systemPropertiesFilePath, e1); } if (in != null) { try { @@ -68,20 +64,18 @@ public class Launcher { } protected static void startMainClass() { - String className = OsgiBootUtils - .getProperty(OsgiBoot.PROP_ARGEO_OSGI_BOOT_APPCLASS); + String className = getProperty(OsgiBoot.PROP_ARGEO_OSGI_BOOT_APPCLASS); if (className == null) return; - String line = System.getProperty(OsgiBoot.PROP_ARGEO_OSGI_BOOT_APPARGS, - ""); + String line = System.getProperty(OsgiBoot.PROP_ARGEO_OSGI_BOOT_APPARGS, ""); String[] uiArgs = readArgumentsFromLine(line); try { // Launch main method using reflection - Class clss = Class.forName(className); - Class[] mainArgsClasses = new Class[] { uiArgs.getClass() }; + Class clss = Class.forName(className); + Class[] mainArgsClasses = new Class[] { uiArgs.getClass() }; Object[] mainArgs = { uiArgs }; Method mainMethod = clss.getMethod("main", mainArgsClasses); mainMethod.invoke(null, mainArgs); @@ -97,7 +91,7 @@ public class Launcher { */ private static String[] readArgumentsFromLine(String lineOrig) { String line = lineOrig.trim();// remove trailing spaces - List args = new Vector(); + List args = new ArrayList(); StringBuffer curr = new StringBuffer(""); boolean inQuote = false; char[] arr = line.toCharArray(); @@ -134,4 +128,21 @@ public class Launcher { return res; } + public static String getProperty(String name, String defaultValue) { + final String value; + if (defaultValue != null) + value = System.getProperty(name, defaultValue); + else + value = System.getProperty(name); + + if (value == null || value.equals("")) + return null; + else + return value; + } + + public static String getProperty(String name) { + return getProperty(name, null); + } + }