From: Mathieu Baudier Date: Fri, 9 Dec 2011 23:56:00 +0000 (+0000) Subject: Unique launch X-Git-Tag: argeo-slc-2.1.7~838 X-Git-Url: http://git.argeo.org/?a=commitdiff_plain;h=aee87eeef820af87f18c2cf2e9b86b612393f7db;p=gpl%2Fargeo-slc.git Unique launch git-svn-id: https://svn.argeo.org/slc/trunk@4936 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- diff --git a/demo/site/org.argeo.slc.demo.minimal/META-INF/spring/helloworld.xml b/demo/site/org.argeo.slc.demo.minimal/META-INF/spring/helloworld.xml index 7c2daa5a5..3af2dcd01 100644 --- a/demo/site/org.argeo.slc.demo.minimal/META-INF/spring/helloworld.xml +++ b/demo/site/org.argeo.slc.demo.minimal/META-INF/spring/helloworld.xml @@ -6,7 +6,7 @@ http://www.argeo.org/schema/slc-flow http://www.argeo.org/schema/slc-flow-0.12.xsd"> - + Print Hello World! diff --git a/dep/org.argeo.slc.dep.rcp/org.argeo.slc.dep.rcp-maven.target b/dep/org.argeo.slc.dep.rcp/org.argeo.slc.dep.rcp-maven.target index e4d016d48..6ea422e94 100644 --- a/dep/org.argeo.slc.dep.rcp/org.argeo.slc.dep.rcp-maven.target +++ b/dep/org.argeo.slc.dep.rcp/org.argeo.slc.dep.rcp-maven.target @@ -6,9 +6,11 @@ + + @@ -34,7 +36,9 @@ + + @@ -42,6 +46,7 @@ + @@ -53,6 +58,7 @@ + @@ -79,7 +85,9 @@ + + @@ -315,8 +323,11 @@ + + + @@ -332,6 +343,7 @@ + @@ -384,9 +396,11 @@ + + @@ -412,7 +426,9 @@ + + @@ -420,6 +436,7 @@ + @@ -431,6 +448,7 @@ + @@ -457,7 +475,9 @@ + + @@ -693,8 +713,11 @@ + + + @@ -710,6 +733,7 @@ + diff --git a/dist/slc/src/main/rpm/etc/slc-cl/log4j.properties b/dist/slc/src/main/rpm/etc/slc-cl/log4j.properties index 7edc3f2d4..a9d97ce91 100644 --- a/dist/slc/src/main/rpm/etc/slc-cl/log4j.properties +++ b/dist/slc/src/main/rpm/etc/slc-cl/log4j.properties @@ -1,5 +1,5 @@ -log4j.rootLogger=WARN, file -#log4j.rootLogger=WARN, console +#log4j.rootLogger=WARN, file +log4j.rootLogger=WARN, console ## Levels log4j.logger.org.argeo=INFO diff --git a/dist/slc/src/main/rpm/usr/bin/slc b/dist/slc/src/main/rpm/usr/bin/slc index edf98110d..3efd3bc67 100644 --- a/dist/slc/src/main/rpm/usr/bin/slc +++ b/dist/slc/src/main/rpm/usr/bin/slc @@ -20,5 +20,6 @@ java -jar $OSGI_FRAMEWORK \ -configuration $CONF_DIR \ -data $DATA_DIR \ -Dslc.launch.module=$MODULE \ - -Dslc.launch.execution=$FLOW \ + -Dslc.launch.flow=$FLOW \ + -console \ -clean diff --git a/modules/agent/org.argeo.slc.agent/META-INF/spring/agent.xml b/modules/agent/org.argeo.slc.agent/META-INF/spring/agent.xml index c91f98b20..2cb735787 100644 --- a/modules/agent/org.argeo.slc.agent/META-INF/spring/agent.xml +++ b/modules/agent/org.argeo.slc.agent/META-INF/spring/agent.xml @@ -5,7 +5,8 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> - + diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/DefaultExecutionFlowDescriptorConverter.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/DefaultExecutionFlowDescriptorConverter.java index 2fb897d3a..9b3764b8a 100644 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/DefaultExecutionFlowDescriptorConverter.java +++ b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/DefaultExecutionFlowDescriptorConverter.java @@ -35,6 +35,7 @@ import org.argeo.slc.execution.ExecutionSpec; import org.argeo.slc.execution.ExecutionSpecAttribute; import org.springframework.aop.scope.ScopedObject; import org.springframework.beans.BeansException; +import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.context.ApplicationContext; @@ -217,8 +218,11 @@ public class DefaultExecutionFlowDescriptorConverter implements efd.setPath(""); // Takes description from spring - BeanDefinition bd = getBeanFactory().getBeanDefinition(name); - efd.setDescription(bd.getDescription()); + BeanFactory bf = getBeanFactory(); + if (bf != null) { + BeanDefinition bd = getBeanFactory().getBeanDefinition(name); + efd.setDescription(bd.getDescription()); + } return efd; } @@ -292,7 +296,10 @@ public class DefaultExecutionFlowDescriptorConverter implements } } + /** @return can be null */ private ConfigurableListableBeanFactory getBeanFactory() { + if (applicationContext == null) + return null; return ((ConfigurableApplicationContext) applicationContext) .getBeanFactory(); } diff --git a/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/execution/ExecutionModuleDescriptor.java b/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/execution/ExecutionModuleDescriptor.java index 04f8f2d26..ff841a138 100644 --- a/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/execution/ExecutionModuleDescriptor.java +++ b/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/execution/ExecutionModuleDescriptor.java @@ -21,6 +21,7 @@ import java.util.List; import org.argeo.slc.deploy.ModuleDescriptor; +/** Describes the information required to launch a flow */ public class ExecutionModuleDescriptor extends ModuleDescriptor { private static final long serialVersionUID = -2394473464513029512L; private List executionSpecs = new ArrayList(); diff --git a/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/execution/ExecutionModulesManager.java b/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/execution/ExecutionModulesManager.java index 3f927a345..616dc502c 100644 --- a/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/execution/ExecutionModulesManager.java +++ b/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/execution/ExecutionModulesManager.java @@ -27,6 +27,12 @@ public interface ExecutionModulesManager extends ModulesManager { /** Used to filter event notified to an execution notifier. */ public static String SLC_PROCESS_ID = "slc.process.id"; + /** Unique launch module */ + public static String UNIQUE_LAUNCH_MODULE_PROPERTY = "slc.launch.module"; + + /** Unique launch flow */ + public static String UNIQUE_LAUNCH_FLOW_PROPERTY = "slc.launch.flow"; + /** @return a full fledged module descriptor. */ public ExecutionModuleDescriptor getExecutionModuleDescriptor( String moduleName, String version); diff --git a/runtime/org.argeo.slc.support.equinox/.classpath b/runtime/org.argeo.slc.support.equinox/.classpath index 762e65304..c9f26bd8e 100644 --- a/runtime/org.argeo.slc.support.equinox/.classpath +++ b/runtime/org.argeo.slc.support.equinox/.classpath @@ -1,7 +1,6 @@ - diff --git a/runtime/org.argeo.slc.support.equinox/META-INF/spring/manager.xml b/runtime/org.argeo.slc.support.equinox/META-INF/spring/manager.xml new file mode 100644 index 000000000..e5779ac10 --- /dev/null +++ b/runtime/org.argeo.slc.support.equinox/META-INF/spring/manager.xml @@ -0,0 +1,42 @@ + + + + + + + + + + osgibundle:equinox.properties + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/runtime/org.argeo.slc.support.equinox/META-INF/spring/osgi.xml b/runtime/org.argeo.slc.support.equinox/META-INF/spring/osgi.xml new file mode 100644 index 000000000..79a47bc15 --- /dev/null +++ b/runtime/org.argeo.slc.support.equinox/META-INF/spring/osgi.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/runtime/org.argeo.slc.support.equinox/equinox.properties b/runtime/org.argeo.slc.support.equinox/equinox.properties new file mode 100644 index 000000000..dae8b2e67 --- /dev/null +++ b/runtime/org.argeo.slc.support.equinox/equinox.properties @@ -0,0 +1,4 @@ +# Timeout for the SLC command in the OSGi console (in ms) +slc.equinox.commandTimeout=10000 +# Polling period for synchronous OSGi commands (in ms) +slc.equinox.commandPollingPeriod=100 \ No newline at end of file diff --git a/runtime/org.argeo.slc.support.equinox/src/main/java/org/argeo/slc/equinox/ExecutionCommandProvider.java b/runtime/org.argeo.slc.support.equinox/src/main/java/org/argeo/slc/equinox/ExecutionCommandProvider.java index 2a265bb91..5d7f7796a 100644 --- a/runtime/org.argeo.slc.support.equinox/src/main/java/org/argeo/slc/equinox/ExecutionCommandProvider.java +++ b/runtime/org.argeo.slc.support.equinox/src/main/java/org/argeo/slc/equinox/ExecutionCommandProvider.java @@ -21,7 +21,6 @@ import org.apache.commons.logging.LogFactory; import org.argeo.slc.SlcException; import org.argeo.slc.osgi.OsgiExecutionModulesManager; import org.argeo.slc.process.RealizedFlow; -import org.eclipse.core.runtime.adaptor.EclipseStarter; import org.eclipse.osgi.framework.console.CommandInterpreter; import org.eclipse.osgi.framework.console.CommandProvider; @@ -100,31 +99,4 @@ public class ExecutionCommandProvider implements CommandProvider { this.modulesManager = osgiModulesManager; } - public void init() throws Exception { - final String module = System.getProperty("slc.launch.module"); - final String executionName = System.getProperty("slc.launch.execution"); - if (module != null) { - new Thread() { - - @Override - public void run() { - try { - launch(SLC_NO_REFRESH, module, executionName); - // in case of failure OSGi runtime stays up and last - // launch can be used to debug by calling 'slc' - } catch (Exception e) { - throw new SlcException("Error when executing " - + executionName + " on " + module, e); - } - try { - EclipseStarter.shutdown(); - } catch (Exception e) { - throw new SlcException("Cannot shutdown equinox.", e); - } - } - - }.start(); - } - - } } diff --git a/runtime/org.argeo.slc.support.equinox/src/main/resources/META-INF/spring/manager.xml b/runtime/org.argeo.slc.support.equinox/src/main/resources/META-INF/spring/manager.xml deleted file mode 100644 index aafe92935..000000000 --- a/runtime/org.argeo.slc.support.equinox/src/main/resources/META-INF/spring/manager.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - osgibundle:equinox.properties - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/runtime/org.argeo.slc.support.equinox/src/main/resources/META-INF/spring/osgi.xml b/runtime/org.argeo.slc.support.equinox/src/main/resources/META-INF/spring/osgi.xml deleted file mode 100644 index 79a47bc15..000000000 --- a/runtime/org.argeo.slc.support.equinox/src/main/resources/META-INF/spring/osgi.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/runtime/org.argeo.slc.support.equinox/src/main/resources/equinox.properties b/runtime/org.argeo.slc.support.equinox/src/main/resources/equinox.properties deleted file mode 100644 index dae8b2e67..000000000 --- a/runtime/org.argeo.slc.support.equinox/src/main/resources/equinox.properties +++ /dev/null @@ -1,4 +0,0 @@ -# Timeout for the SLC command in the OSGi console (in ms) -slc.equinox.commandTimeout=10000 -# Polling period for synchronous OSGi commands (in ms) -slc.equinox.commandPollingPeriod=100 \ No newline at end of file diff --git a/runtime/org.argeo.slc.support.osgi/src/main/java/org/argeo/slc/osgi/BundlesManager.java b/runtime/org.argeo.slc.support.osgi/src/main/java/org/argeo/slc/osgi/BundlesManager.java index b56ebc2a6..3d6510d14 100644 --- a/runtime/org.argeo.slc.support.osgi/src/main/java/org/argeo/slc/osgi/BundlesManager.java +++ b/runtime/org.argeo.slc.support.osgi/src/main/java/org/argeo/slc/osgi/BundlesManager.java @@ -281,11 +281,16 @@ public class BundlesManager implements BundleContextAware, FrameworkListener, } @SuppressWarnings(value = { "unchecked" }) - public T getSingleService(Class clss, String filter) { + public T getSingleService(Class clss, String filter, + Boolean synchronous) { Assert.isTrue(OsgiFilterUtils.isValidFilter(filter), "valid filter"); ServiceReference[] sfs; try { - sfs = bundleContext.getServiceReferences(clss.getName(), filter); + if (synchronous) + sfs = getServiceRefSynchronous(clss.getName(), filter); + else + sfs = bundleContext + .getServiceReferences(clss.getName(), filter); } catch (InvalidSyntaxException e) { throw new SlcException("Cannot retrieve service reference for " + filter, e); @@ -300,7 +305,7 @@ public class BundlesManager implements BundleContextAware, FrameworkListener, } public T getSingleServiceStrict(Class clss, String filter) { - T service = getSingleService(clss, filter); + T service = getSingleService(clss, filter, true); if (service == null) throw new SlcException("No execution flow found for " + filter); else diff --git a/runtime/org.argeo.slc.support.osgi/src/main/java/org/argeo/slc/osgi/OsgiExecutionModulesManager.java b/runtime/org.argeo.slc.support.osgi/src/main/java/org/argeo/slc/osgi/OsgiExecutionModulesManager.java index 6625ebd3b..c5d23589e 100644 --- a/runtime/org.argeo.slc.support.osgi/src/main/java/org/argeo/slc/osgi/OsgiExecutionModulesManager.java +++ b/runtime/org.argeo.slc.support.osgi/src/main/java/org/argeo/slc/osgi/OsgiExecutionModulesManager.java @@ -67,6 +67,47 @@ public class OsgiExecutionModulesManager extends private Boolean registerFlowsToJmx = true; + public void init() throws Exception { + final String module = System.getProperty(UNIQUE_LAUNCH_MODULE_PROPERTY); + final String flow = System.getProperty(UNIQUE_LAUNCH_FLOW_PROPERTY); + if (module != null) { + // launch a flow and stops + new Thread("Unique Flow") { + @Override + public void run() { + try { + bundlesManager.startSynchronous(bundlesManager + .findRelatedBundle(bundlesManager + .findFromPattern(module))); + RealizedFlow lastLaunch = findRealizedFlow(module, flow); + if (lastLaunch == null) + throw new SlcException("Cannot find launch for " + + module + " " + flow); + execute(lastLaunch); + } catch (Exception e) { + throw new SlcException( + "Error when executing unique flow " + flow + + " on " + module, e); + } finally { + try { + bundlesManager.getBundleContext().getBundle(0) + .stop(); + System.exit(0); + } catch (Exception e) { + log.error("Cannot shutdown equinox.", e); + System.exit(1); + } + } + } + }.start(); + } + + } + + public void destroy() { + + } + public synchronized ExecutionModuleDescriptor getExecutionModuleDescriptor( String moduleName, String version) { ExecutionModuleDescriptor md = new ExecutionModuleDescriptor(); @@ -142,11 +183,10 @@ public class OsgiExecutionModulesManager extends protected ExecutionFlowDescriptorConverter findExecutionFlowDescriptorConverter( String moduleName, String moduleVersion) { - String filter = "(&(Bundle-SymbolicName=" + moduleName + ")(Bundle-Version=" + moduleVersion + "))"; return bundlesManager.getSingleService( - ExecutionFlowDescriptorConverter.class, filter); + ExecutionFlowDescriptorConverter.class, filter, false); } /**