From: Mathieu Baudier Date: Thu, 2 Oct 2008 07:46:39 +0000 (+0000) Subject: Integrate detached with standard SLC X-Git-Tag: argeo-slc-2.1.7~2514 X-Git-Url: http://git.argeo.org/?a=commitdiff_plain;h=5b44285758940176167cdfa401b1dda753b3a27b;p=gpl%2Fargeo-slc.git Integrate detached with standard SLC git-svn-id: https://svn.argeo.org/slc/trunk@1677 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- diff --git a/org.argeo.slc.detached.launcher/.classpath b/org.argeo.slc.detached.launcher/.classpath index 1aa73cdbf..4972669ed 100644 --- a/org.argeo.slc.detached.launcher/.classpath +++ b/org.argeo.slc.detached.launcher/.classpath @@ -4,5 +4,5 @@ - + diff --git a/org.argeo.slc.detached.launcher/pom.xml b/org.argeo.slc.detached.launcher/pom.xml index 1e6637d4f..50930710e 100644 --- a/org.argeo.slc.detached.launcher/pom.xml +++ b/org.argeo.slc.detached.launcher/pom.xml @@ -1,52 +1,82 @@ - 4.0.0 - - org.argeo.slc - argeo-slc - 0.11.1-SNAPSHOT - ../org.argeo.slc - - org.argeo.slc.detached.launcher - Argeo SLC Detached Launcher - jar - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.3 - 1.3 - - - - org.apache.maven.plugins - maven-source-plugin - - - - - - org.argeo.slc - org.argeo.slc.detached - ${project.version} - - - org.apache.felix - org.apache.felix.main - - - - org.springframework - spring-context - 2.0.8 - + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + 4.0.0 + + org.argeo.slc + argeo-slc + 0.11.1-SNAPSHOT + ../org.argeo.slc + + org.argeo.slc.detached.launcher + Argeo SLC Detached Launcher + jar + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.3 + 1.3 + + + + org.apache.maven.plugins + maven-source-plugin + + + org.apache.maven.plugins + maven-jar-plugin + + + + + org.argeo.slc.detached.launcher.Main + + + + + + + org.apache.maven.plugins + maven-assembly-plugin + + + src/assembly/dist.xml + + + + + attach-assembly + package + + single + + + + + + + + + org.apache.felix + org.apache.felix.main + + + + org.springframework + spring-context + 2.0.8 + - - xerces - xercesImpl - - + + xerces + xercesImpl + + + log4j + log4j + + \ No newline at end of file diff --git a/org.argeo.slc.detached.launcher/src/assembly/dist.xml b/org.argeo.slc.detached.launcher/src/assembly/dist.xml new file mode 100644 index 000000000..c3df20934 --- /dev/null +++ b/org.argeo.slc.detached.launcher/src/assembly/dist.xml @@ -0,0 +1,30 @@ + + dist + + tar.gz + + + + false + lib + + *:jar + + + + + \ No newline at end of file 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 5eff46c26..17c4ff4b0 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 @@ -1,6 +1,7 @@ package org.argeo.slc.detached.launcher; import java.io.File; +import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.lang.reflect.Method; @@ -20,12 +21,21 @@ public class Main { private final static Log log = LogFactory.getLog(Main.class); public static void main(String[] args) { + log.info("Argeo SLC Detached launcher starting..."); try { // Load properties - Properties config = prepareConfig(); + String propertyPath = "slc-detached.properties"; + Properties config = prepareConfig(propertyPath); + + // Create cache dir + if (!config.containsKey(BundleCache.CACHE_PROFILE_DIR_PROP)) { + final File cachedir = createTemporaryCacheDir(); + config.put(BundleCache.CACHE_PROFILE_DIR_PROP, cachedir + .getAbsolutePath()); + } - // Start UI (in main class loader) - startUi(config); + // Start app (in main class loader) + startApp(config); // Thread.sleep(10000); // Start OSGi system @@ -40,9 +50,8 @@ public class Main { } } - protected static Properties prepareConfig() throws Exception { - final File cachedir = createTemporaryCacheDir(); - + protected static Properties prepareConfig(String propertyFilePath) + throws Exception { // Load config Properties config = new Properties(); InputStream in = null; @@ -56,19 +65,26 @@ public class Main { in.close(); } + try { + in = new FileInputStream(propertyFilePath); + config.load(in); + } finally { + if (in != null) + in.close(); + } + + // System properties have priority. + config.putAll(System.getProperties()); + // Perform variable substitution for system properties. for (Enumeration e = config.propertyNames(); e.hasMoreElements();) { String name = (String) e.nextElement(); config.setProperty(name, org.apache.felix.main.Main.substVars( config.getProperty(name), name, null, config)); + if (log.isTraceEnabled()) + log.trace(name + "=" + config.getProperty(name)); } - config.put(BundleCache.CACHE_PROFILE_DIR_PROP, cachedir - .getAbsolutePath()); - - // System properties have priority. - config.putAll(System.getProperties()); - return config; } @@ -100,10 +116,10 @@ public class Main { return felix; } - public static void startUi(Properties config) throws Exception { - String className = config.getProperty("argeo.scl.autoui.uiclass"); + public static void startApp(Properties config) throws Exception { + String className = config.getProperty("argeo.scl.detached.appclass"); String[] uiArgs = readArgumentsFromLine(config.getProperty( - "argeo.slc.autoui.uiargs", "")); + "argeo.slc.detached.appargs", "")); // Launch main method using reflection Class clss = Class.forName(className); diff --git a/org.argeo.slc.detached.launcher/src/main/resources/log4j.properties b/org.argeo.slc.detached.launcher/src/main/resources/log4j.properties new file mode 100644 index 000000000..48539ac94 --- /dev/null +++ b/org.argeo.slc.detached.launcher/src/main/resources/log4j.properties @@ -0,0 +1,15 @@ +# Set root logger level to DEBUG and its only appender to A1. +log4j.rootLogger=WARN, console + +## Levels +# Slc +log4j.logger.org.argeo.slc=DEBUG + +## Appenders +# A1 is set to be a ConsoleAppender. +log4j.appender.console=org.apache.log4j.ConsoleAppender + +# A1 uses PatternLayout. +log4j.appender.console.layout=org.apache.log4j.PatternLayout +log4j.appender.console.layout.ConversionPattern= %-5p %d{ISO8601} %m - %c %n + diff --git a/org.argeo.slc.detached.launcher/src/main/resources/org/argeo/slc/detached/launcher/felix.properties b/org.argeo.slc.detached.launcher/src/main/resources/org/argeo/slc/detached/launcher/felix.properties index 7ac5502b9..268cd25bd 100644 --- a/org.argeo.slc.detached.launcher/src/main/resources/org/argeo/slc/detached/launcher/felix.properties +++ b/org.argeo.slc.detached.launcher/src/main/resources/org/argeo/slc/detached/launcher/felix.properties @@ -1,9 +1,9 @@ # Argeo Specific Context Properties -argeo.slc.mavenBase=file:${user.home}/.m2/repository/ +argeo.slc.mavenBase=file:${user.home}/.m2/repository -argeo.scl.autoui.uiclass=org.argeo.slc.testui.SwingTestUi -argeo.slc.autoui.uiargs=noExitOnClose +argeo.scl.detached.appclass=org.argeo.slc.testui.SwingTestUi +argeo.slc.detached.appargs=noExitOnClose # # Framework config properties. @@ -29,12 +29,12 @@ org.osgi.framework.system.packages=org.osgi.framework; version=1.4.0, \ # file:bundle/org.apache.felix.shell.tui-1.0.2.jar \ # file:bundle/org.apache.felix.bundlerepository-1.2.0.jar -felix.auto.start.1= \ - reference:file:${user.dir}/../sandbox/argeo.slc.jemmytest/bin/ \ - reference:file:${user.dir}/../org.argeo.slc.detached/bin/ \ - ${argeo.slc.mavenBase}org/apache/felix/org.apache.felix.shell/1.0.2/org.apache.felix.shell-1.0.2.jar \ - ${argeo.slc.mavenBase}org/apache/felix/org.apache.felix.shell.tui/1.0.2/org.apache.felix.shell.tui-1.0.2.jar \ - ${argeo.slc.mavenBase}org/argeo/dep/jemmy/org.argeo.dep.jemmy.nb61/0.2.2/org.argeo.dep.jemmy.nb61-0.2.2.jar +#felix.auto.start.1= \ +# reference:file:${user.dir}/../sandbox/argeo.slc.jemmytest/bin/ \ +# reference:file:${user.dir}/../org.argeo.slc.detached/bin/ \ +# ${argeo.slc.mavenBase}/org/apache/felix/org.apache.felix.shell/1.0.2/org.apache.felix.shell-1.0.2.jar \ +# ${argeo.slc.mavenBase}/org/apache/felix/org.apache.felix.shell.tui/1.0.2/org.apache.felix.shell.tui-1.0.2.jar \ +# ${argeo.slc.mavenBase}/org/argeo/dep/jemmy/org.argeo.dep.jemmy.nb61/0.2.2/org.argeo.dep.jemmy.nb61-0.2.2.jar # ${argeo.slc.mavenBase}org/argeo/slc/sandbox/org.argeo.slc.sandbox.jemmytest/0.1.2-SNAPSHOT/org.argeo.slc.sandbox.jemmytest-0.1.2-SNAPSHOT.jar"