X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;ds=inline;f=runtime%2Forg.argeo.slc.support.equinox%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fosgi%2FOsgiExecutionModule.java;h=ca3f5faa7fe3df1938f9397c41757042a24de0e8;hb=9c82ed02a7ee7b4a757853d8160587b27e493f1a;hp=1708240e9668b550f435d264a315aa671d3b3db0;hpb=e5249c75ef672c95d9cf5405b05cabf6083d18a6;p=gpl%2Fargeo-slc.git
diff --git a/runtime/org.argeo.slc.support.equinox/src/main/java/org/argeo/slc/osgi/OsgiExecutionModule.java b/runtime/org.argeo.slc.support.equinox/src/main/java/org/argeo/slc/osgi/OsgiExecutionModule.java
index 1708240e9..ca3f5faa7 100644
--- a/runtime/org.argeo.slc.support.equinox/src/main/java/org/argeo/slc/osgi/OsgiExecutionModule.java
+++ b/runtime/org.argeo.slc.support.equinox/src/main/java/org/argeo/slc/osgi/OsgiExecutionModule.java
@@ -1,24 +1,80 @@
package org.argeo.slc.osgi;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.argeo.slc.core.execution.AbstractSpringExecutionModule;
-import org.osgi.framework.BundleContext;
-import org.springframework.osgi.context.BundleContextAware;
+import org.argeo.slc.execution.ExecutionContext;
-public class OsgiExecutionModule extends AbstractSpringExecutionModule implements
- BundleContextAware {
- private BundleContext bundleContext;
+@Deprecated
+public class OsgiExecutionModule extends AbstractSpringExecutionModule {
+ private final static Log log = LogFactory.getLog(OsgiExecutionModule.class);
- public String getName() {
- return bundleContext.getBundle().getSymbolicName();
+ public OsgiExecutionModule() {
+ log.error("######## ERROR - DEPRECATED APPROACH USED ########");
+ log.error(OsgiExecutionModule.class.getName() + " is deprecated. ");
+ log
+ .error("It will be removed in the next release. Remove its bean definition.");
+ log
+ .error("And replace: ");
+ log
+ .error("by: ");
+ log.error("in osgi.xml.\n\n");
}
- public String getVersion() {
- return bundleContext.getBundle().getHeaders().get("Bundle-Version")
- .toString();
+ public void setExecutionContext(ExecutionContext executionContext) {
+ // do nothing, just for compatibility
}
- public void setBundleContext(BundleContext bundleContext) {
- this.bundleContext = bundleContext;
- }
+ /*
+ * private BundleContext bundleContext;
+ *
+ * @Override public void execute(ExecutionFlowDescriptor
+ * executionFlowDescriptor) { if (descriptorConverter != null)
+ * executionContext.addVariables(descriptorConverter
+ * .convertValues(executionFlowDescriptor));
+ *
+ * ExecutionFlow flow = findExecutionFlow(getName(), getVersion(),
+ * executionFlowDescriptor.getName()); flow.run(); }
+ *
+ * @Override protected Map listFlows() { String
+ * filter = "(org.argeo.slc.execution.module.name=" + getName() + ")";
+ * ServiceReference[] sfs; try { sfs =
+ * bundleContext.getServiceReferences(ExecutionFlow.class .getName(),
+ * filter); } catch (InvalidSyntaxException e) { throw new SlcException(
+ * "Cannot retrieve service reference for flow " + filter, e); }
+ *
+ * Map flows = new HashMap();
+ * for (ServiceReference sf : sfs) { ExecutionFlow flow = (ExecutionFlow)
+ * bundleContext.getService(sf); flows.put(flow.getName(), flow); } return
+ * flows; }
+ *
+ * public String getName() { return
+ * bundleContext.getBundle().getSymbolicName(); }
+ *
+ * public String getVersion() { return
+ * bundleContext.getBundle().getHeaders().get("Bundle-Version") .toString();
+ * }
+ *
+ * public void setBundleContext(BundleContext bundleContext) {
+ * this.bundleContext = bundleContext; }
+ *
+ * protected ExecutionFlow findExecutionFlow(String moduleName, String
+ * moduleVersion, String flowName) { String filter =
+ * "(&(org.argeo.slc.execution.module.name=" + moduleName +
+ * ")(org.argeo.slc.execution.flow.name=" + flowName + "))";
+ * log.debug("OSGi filter: " + filter);
+ *
+ * Assert.isTrue(OsgiFilterUtils.isValidFilter(filter), "valid filter");
+ * ServiceReference[] sfs; try { sfs =
+ * bundleContext.getServiceReferences(ExecutionFlow.class .getName(),
+ * filter); } catch (InvalidSyntaxException e) { throw new
+ * SlcException("Cannot retrieve service reference for " + filter, e); }
+ *
+ * if (sfs == null || sfs.length == 0) throw new
+ * SlcException("No execution flow found for " + filter); else if
+ * (sfs.length > 1) throw new
+ * SlcException("More than one execution flow found for " + filter); return
+ * (ExecutionFlow) bundleContext.getService(sfs[0]); }
+ */
}