X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.slc.detached.launcher%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fdetached%2Flauncher%2FMain.java;h=423b1cbc49f3d09de8bc55ea04a8819bf108ab73;hb=cdbbb88bcb735919c4e23bc2aeafd3b4354d1975;hp=17c4ff4b0530b31be6f2a024d91803bc69cb3de2;hpb=5b44285758940176167cdfa401b1dda753b3a27b;p=gpl%2Fargeo-slc.git diff --git a/org.argeo.slc.detached.launcher/src/main/java/org/argeo/slc/detached/launcher/Main.java b/org.argeo.slc.detached.launcher/src/main/java/org/argeo/slc/detached/launcher/Main.java index 17c4ff4b0..423b1cbc4 100644 --- a/org.argeo.slc.detached.launcher/src/main/java/org/argeo/slc/detached/launcher/Main.java +++ b/org.argeo.slc.detached.launcher/src/main/java/org/argeo/slc/detached/launcher/Main.java @@ -11,6 +11,7 @@ import java.util.List; import java.util.Properties; import java.util.Vector; +import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.felix.framework.Felix; @@ -52,25 +53,33 @@ public class Main { protected static Properties prepareConfig(String propertyFilePath) throws Exception { + // Format slc.home + String slcHome = System.getProperty("slc.home"); + if (slcHome != null) { + slcHome = new File(slcHome).getCanonicalPath(); + System.setProperty("slc.home", slcHome); + } + // Load config Properties config = new Properties(); InputStream in = null; - ; + try { in = Main.class .getResourceAsStream("/org/argeo/slc/detached/launcher/felix.properties"); config.load(in); } finally { - if (in != null) - in.close(); + IOUtils.closeQuietly(in); } try { - in = new FileInputStream(propertyFilePath); - config.load(in); + File file = new File(propertyFilePath); + if (file.exists()) { + in = new FileInputStream(propertyFilePath); + config.load(in); + } } finally { - if (in != null) - in.close(); + IOUtils.closeQuietly(in); } // System properties have priority. @@ -117,15 +126,24 @@ public class Main { } public static void startApp(Properties config) throws Exception { - String className = config.getProperty("argeo.scl.detached.appclass"); + String className = config.getProperty("slc.detached.appclass"); String[] uiArgs = readArgumentsFromLine(config.getProperty( - "argeo.slc.detached.appargs", "")); + "slc.detached.appargs", "")); + + if (className == null) + throw new Exception( + "A main class has to be defined with teh system property slc.detached.appclass"); // Launch main method using reflection Class clss = Class.forName(className); Class[] mainArgsClasses = new Class[] { uiArgs.getClass() }; Object[] mainArgs = { uiArgs }; Method mainMethod = clss.getMethod("main", mainArgsClasses); + String[] passedArgs = (String[])mainArgs[0]; + System.out.println("PASSED ARGS:"); + for(int i=0;i