From: Mathieu Baudier Date: Mon, 27 Apr 2009 15:47:19 +0000 (+0000) Subject: Improve detached launcher X-Git-Tag: argeo-slc-2.1.7~1934 X-Git-Url: http://git.argeo.org/?a=commitdiff_plain;ds=sidebyside;h=a5bc0826e17c1fae461129be871fd51d40e35b8b;p=gpl%2Fargeo-slc.git Improve detached launcher git-svn-id: https://svn.argeo.org/slc/trunk@2382 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- diff --git a/demo/pom.xml b/demo/pom.xml index e8ed6781e..e4f569132 100644 --- a/demo/pom.xml +++ b/demo/pom.xml @@ -67,7 +67,7 @@ org.springframework.osgi.web.extender, org.springframework.osgi.samples.simplewebapp, org.argeo.slc.server.activemq, - org.argeo.slc.server.mysql, + org.argeo.slc.server.hsqldb, org.argeo.slc.server.hibernate, org.argeo.slc.server.services, org.argeo.slc.server.jms, diff --git a/org.argeo.slc/pom.xml b/org.argeo.slc/pom.xml index efa7f3db8..8b3120366 100644 --- a/org.argeo.slc/pom.xml +++ b/org.argeo.slc/pom.xml @@ -577,7 +577,7 @@ limitations under the License. net.sourceforge.jtds - jtds + com.springsource.net.sourceforge.jtds 1.2.2 diff --git a/runtime/org.argeo.slc.detached.launcher/pom.xml b/runtime/org.argeo.slc.detached.launcher/pom.xml index b101f93dc..895fd155d 100644 --- a/runtime/org.argeo.slc.detached.launcher/pom.xml +++ b/runtime/org.argeo.slc.detached.launcher/pom.xml @@ -1,10 +1,11 @@ - + 4.0.0 - org.argeo.slc - argeo-slc + org.argeo.slc.runtime + argeo-slc-runtime 0.11.3-SNAPSHOT - ../org.argeo.slc + .. org.argeo.slc.detached.launcher Argeo SLC Detached Launcher @@ -48,93 +49,27 @@ - - org.apache.maven.plugins - maven-assembly-plugin - - - src/assembly/dist.xml - - - - - attach-assembly - package - - single - - - - + - org.eclipse.osgi org.eclipse.osgi - - - - - - - \ No newline at end of file diff --git a/runtime/org.argeo.slc.detached.launcher/src/main/java/org/argeo/slc/detached/launcher/Main.java b/runtime/org.argeo.slc.detached.launcher/src/main/java/org/argeo/slc/detached/launcher/Main.java index 807963e14..3fc42326f 100644 --- a/runtime/org.argeo.slc.detached.launcher/src/main/java/org/argeo/slc/detached/launcher/Main.java +++ b/runtime/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.Map; import java.util.Properties; import java.util.StringTokenizer; +import java.util.TreeMap; import java.util.Vector; import org.eclipse.core.runtime.adaptor.EclipseStarter; @@ -20,6 +21,7 @@ import org.osgi.framework.BundleException; public class Main { public final static String PROP_SLC_HOME = "slc.home"; + public final static String PROP_SLC_DETACHED_PROEPRTIES = "slc.detached.properties"; public final static String PROP_SLC_OSGI_START = "slc.osgi.start"; public final static String PROP_SLC_OSGI_SCAN_CLASSPATH = "slc.osgi.scanClasspath"; public final static String PROP_SLC_OSGI_EQUINOX_ARGS = "slc.osgi.equinox.args"; @@ -30,7 +32,8 @@ public class Main { info("Argeo SLC Detached launcher starting..."); try { // Load properties - String propertyPath = "slc-detached.properties"; + String propertyPath = System.getProperty("slc.detached.properties", + "slc-detached.properties"); Properties config = prepareConfig(propertyPath); // Start app (in main class loader) @@ -40,25 +43,17 @@ public class Main { try { startEquinox(config); } catch (Exception e) { - // TODO Auto-generated catch block e.printStackTrace(); } info("Argeo SLC Detached launcher started."); } catch (Exception e) { e.printStackTrace(); - System.exit(-1); + System.exit(1); } } protected static Properties prepareConfig(String propertyFilePath) throws Exception { - // Format slc.home - String slcHome = System.getProperty(PROP_SLC_HOME); - if (slcHome != null) { - slcHome = new File(slcHome).getCanonicalPath(); - System.setProperty(PROP_SLC_HOME, slcHome); - } - // Load config Properties config = new Properties(); InputStream in = null; @@ -73,8 +68,28 @@ public class Main { in.close(); } + // Format slc.home + String slcHome = System.getProperty(Main.PROP_SLC_HOME); + if (slcHome == null) { + slcHome = config.getProperty(Main.PROP_SLC_HOME); + } + if (slcHome != null) { + slcHome = new File(slcHome).getCanonicalPath(); + System.setProperty(Main.PROP_SLC_HOME, slcHome); + } + // System properties have priority. config.putAll(System.getProperties()); + + // SET ALL PROPERTIES AS SYSTEM PROPERTIES + TreeMap ordered = new TreeMap(config); + for (Iterator it = ordered.keySet().iterator(); it.hasNext();) { + String key = it.next().toString(); + String value = ordered.get(key).toString(); + System.out.println(key + "=" + value); + System.setProperty(key, value); + } + return config; } @@ -196,7 +211,7 @@ public class Main { private static void startBundle(BundleContext bundleContext, String symbolicName) throws BundleException { - //info("Starting bundle " + symbolicName + "..."); + // info("Starting bundle " + symbolicName + "..."); Bundle bundle = findBundleBySymbolicName(bundleContext, symbolicName); if (bundle != null) bundle.start(); @@ -296,6 +311,6 @@ public class Main { private static void bundleInstallWarn(Object obj) { System.err.println("[WARN] " + obj); - //Thread.dumpStack(); + // Thread.dumpStack(); } } diff --git a/runtime/org.argeo.slc.support.activemq/src/main/java/org/argeo/slc/jms/JmsAgent.java b/runtime/org.argeo.slc.support.activemq/src/main/java/org/argeo/slc/jms/JmsAgent.java index 7490f32d1..baddb1c60 100644 --- a/runtime/org.argeo.slc.support.activemq/src/main/java/org/argeo/slc/jms/JmsAgent.java +++ b/runtime/org.argeo.slc.support.activemq/src/main/java/org/argeo/slc/jms/JmsAgent.java @@ -81,19 +81,6 @@ public class JmsAgent extends AbstractAgent implements SlcAgent, this.agentUnregister = agentUnregister; } - /* - * public void onMessage(Message message) { // FIXME: we filter the messages - * on the client side, // because of a weird problem with selector since - * moving to OSGi try { if (message.getStringProperty("slc-agentId").equals( - * agentDescriptor.getUuid())) { runSlcExecution((SlcExecution) - * messageConverter .fromMessage(message)); } else { if - * (log.isDebugEnabled()) log.debug("Filtered out message " + message); } } - * catch (JMSException e) { throw new SlcException("Cannot convert message " - * + message, e); } - * - * } - */ - public String getMessageSelector() { String messageSelector = "slc_agentId='" + agentDescriptor.getUuid() + "'"; @@ -131,6 +118,7 @@ public class JmsAgent extends AbstractAgent implements SlcAgent, SlcExecution slcExecution = (SlcExecution) jmsTemplate .getMessageConverter().fromMessage(message); runSlcExecution(slcExecution); + return; } else { // try { // // FIXME: generalize diff --git a/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/AbstractSpringExecutionModule.java b/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/AbstractSpringExecutionModule.java index 51ca2f159..1cac123a8 100644 --- a/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/AbstractSpringExecutionModule.java +++ b/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/AbstractSpringExecutionModule.java @@ -72,6 +72,13 @@ public abstract class AbstractSpringExecutionModule implements ExecutionModule, + value.getClass().getName()); } values.put(key, refValue); + } else if (attribute instanceof ResourceSpecAttribute) { + PrimitiveValue primitiveValue = new PrimitiveValue(); + primitiveValue + .setType(((ResourceSpecAttribute) attribute) + .getType()); + primitiveValue.setValue(value); + values.put(key, primitiveValue); } else { throw new SlcException("Unkown spec attribute type " + attribute.getClass()); diff --git a/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/ResourceSpecAttribute.java b/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/ResourceSpecAttribute.java index 131c45a2a..572665dd5 100644 --- a/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/ResourceSpecAttribute.java +++ b/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/ResourceSpecAttribute.java @@ -41,4 +41,8 @@ public class ResourceSpecAttribute extends AbstractSpecAttribute { this.type = type; } + public String getType() { + return type; + } + } diff --git a/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/tasks/SystemCall.java b/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/tasks/SystemCall.java index 38b0f78b4..f5a9db5ca 100644 --- a/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/tasks/SystemCall.java +++ b/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/tasks/SystemCall.java @@ -99,7 +99,7 @@ public class SystemCall implements Executable { }; stdOutThread.start(); StreamReaderThread stdErrThread = new StreamReaderThread(process - .getInputStream()) { + .getErrorStream()) { protected void callback(String line) { stdErrCallback(line); } @@ -111,8 +111,10 @@ public class SystemCall implements Executable { // Wait for the end of the process if (synchronous) { Integer exitCode = process.waitFor(); - if (exitCode != 0) + if (exitCode != 0) { + Thread.sleep(5000);// leave the process a chance to log log.warn("Process return exit code " + exitCode); + } } else { // asynchronous: return } @@ -132,7 +134,7 @@ public class SystemCall implements Executable { else return dir.getPath(); } - + protected void stdOutCallback(String line) { log(stdOutLogLevel, line); } diff --git a/server/org.argeo.slc.siteserver/bundles/org.argeo.slc.server.mysql/META-INF/spring/mysql.xml b/server/org.argeo.slc.siteserver/bundles/org.argeo.slc.server.mysql/META-INF/spring/mysql.xml index 7f5d9a2b7..8286594a2 100644 --- a/server/org.argeo.slc.siteserver/bundles/org.argeo.slc.server.mysql/META-INF/spring/mysql.xml +++ b/server/org.argeo.slc.siteserver/bundles/org.argeo.slc.server.mysql/META-INF/spring/mysql.xml @@ -50,7 +50,7 @@ --> - + diff --git a/server/org.argeo.slc.siteserver/bundles/org.argeo.slc.server.mysql/mysql.properties b/server/org.argeo.slc.siteserver/bundles/org.argeo.slc.server.mysql/mysql.properties index dc979ad4d..11a0d5544 100644 --- a/server/org.argeo.slc.siteserver/bundles/org.argeo.slc.server.mysql/mysql.properties +++ b/server/org.argeo.slc.siteserver/bundles/org.argeo.slc.server.mysql/mysql.properties @@ -1,4 +1,3 @@ -jdbc.driverClassName=com.mysql.jdbc.Driver -jdbc.url=jdbc:mysql://localhost/sparta_prod +jdbc.url=jdbc:mysql://localhost/slc jdbc.username=root jdbc.password= diff --git a/server/org.argeo.slc.siteserver/pom.xml b/server/org.argeo.slc.siteserver/pom.xml index c2594095e..286b1daca 100644 --- a/server/org.argeo.slc.siteserver/pom.xml +++ b/server/org.argeo.slc.siteserver/pom.xml @@ -123,7 +123,7 @@ net.sourceforge.jtds - jtds + com.springsource.net.sourceforge.jtds com.mysql.jdbc