import org.argeo.slc.execution.ExecutionModulesListener;
import org.argeo.slc.process.RealizedFlow;
import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;
import org.springframework.osgi.service.importer.OsgiServiceLifecycleListener;
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();
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);
}
/**
return lst;
}
+ public void start(NameVersion nameVersion) {
+ try {
+ Bundle bundle = bundlesManager.findRelatedBundle(new OsgiBundle(
+ nameVersion));
+ bundlesManager.startSynchronous(bundle);
+ } catch (BundleException e) {
+ throw new SlcException("Cannot start " + nameVersion, e);
+ }
+ }
+
+ public void stop(NameVersion nameVersion) {
+ try {
+ Bundle bundle = bundlesManager.findRelatedBundle(new OsgiBundle(
+ nameVersion));
+ bundlesManager.stopSynchronous(bundle);
+ } catch (BundleException e) {
+ throw new SlcException("Cannot stop " + nameVersion, e);
+ }
+ }
+
protected void setMetadataFromBundle(ModuleDescriptor md, Bundle bundle) {
Bundle bdl = bundle;
if (bdl == null) {