X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;ds=sidebyside;f=org.argeo.slc.detached.launcher%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fdetached%2Flauncher%2FMain.java;h=fe69e30c56af83cd95c2b7dceb7ff0e62b99fd1b;hb=bd289ae8e8a75c6ca1ecbe4fc86960607b6846de;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..fe69e30c5 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,9 +126,13 @@ 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);