]> git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.support.osgi/src/main/java/org/argeo/slc/osgi/OsgiExecutionModule.java
Reduce debug verbosity
[gpl/argeo-slc.git] / runtime / org.argeo.slc.support.osgi / src / main / java / org / argeo / slc / osgi / OsgiExecutionModule.java
1 package org.argeo.slc.osgi;
2
3 import org.apache.commons.logging.Log;
4 import org.apache.commons.logging.LogFactory;
5 import org.argeo.slc.core.execution.AbstractSpringExecutionModule;
6 import org.argeo.slc.execution.ExecutionContext;
7
8 @Deprecated
9 public class OsgiExecutionModule extends AbstractSpringExecutionModule {
10 private final static Log log = LogFactory.getLog(OsgiExecutionModule.class);
11
12 public OsgiExecutionModule() {
13 log.error("######## ERROR - DEPRECATED APPROACH USED ########");
14 log.error(OsgiExecutionModule.class.getName() + " is deprecated. ");
15 log
16 .error("It will be removed in the next release. Remove its bean definition.");
17 log
18 .error("And replace: <service interface=\"org.argeo.slc.execution.ExecutionModule\" ref=\"executionModule\" />");
19 log
20 .error("by: <beans:import resource=\"classpath:org/argeo/slc/osgi/execution/spring.xml\" /> ");
21 log.error("in osgi.xml.\n\n");
22 }
23
24 public void setExecutionContext(ExecutionContext executionContext) {
25 // do nothing, just for compatibility
26 }
27
28 /*
29 * private BundleContext bundleContext;
30 *
31 * @Override public void execute(ExecutionFlowDescriptor
32 * executionFlowDescriptor) { if (descriptorConverter != null)
33 * executionContext.addVariables(descriptorConverter
34 * .convertValues(executionFlowDescriptor));
35 *
36 * ExecutionFlow flow = findExecutionFlow(getName(), getVersion(),
37 * executionFlowDescriptor.getName()); flow.run(); }
38 *
39 * @Override protected Map<String, ExecutionFlow> listFlows() { String
40 * filter = "(org.argeo.slc.execution.module.name=" + getName() + ")";
41 * ServiceReference[] sfs; try { sfs =
42 * bundleContext.getServiceReferences(ExecutionFlow.class .getName(),
43 * filter); } catch (InvalidSyntaxException e) { throw new SlcException(
44 * "Cannot retrieve service reference for flow " + filter, e); }
45 *
46 * Map<String, ExecutionFlow> flows = new HashMap<String, ExecutionFlow>();
47 * for (ServiceReference sf : sfs) { ExecutionFlow flow = (ExecutionFlow)
48 * bundleContext.getService(sf); flows.put(flow.getName(), flow); } return
49 * flows; }
50 *
51 * public String getName() { return
52 * bundleContext.getBundle().getSymbolicName(); }
53 *
54 * public String getVersion() { return
55 * bundleContext.getBundle().getHeaders().get("Bundle-Version") .toString();
56 * }
57 *
58 * public void setBundleContext(BundleContext bundleContext) {
59 * this.bundleContext = bundleContext; }
60 *
61 * protected ExecutionFlow findExecutionFlow(String moduleName, String
62 * moduleVersion, String flowName) { String filter =
63 * "(&(org.argeo.slc.execution.module.name=" + moduleName +
64 * ")(org.argeo.slc.execution.flow.name=" + flowName + "))";
65 * log.debug("OSGi filter: " + filter);
66 *
67 * Assert.isTrue(OsgiFilterUtils.isValidFilter(filter), "valid filter");
68 * ServiceReference[] sfs; try { sfs =
69 * bundleContext.getServiceReferences(ExecutionFlow.class .getName(),
70 * filter); } catch (InvalidSyntaxException e) { throw new
71 * SlcException("Cannot retrieve service reference for " + filter, e); }
72 *
73 * if (sfs == null || sfs.length == 0) throw new
74 * SlcException("No execution flow found for " + filter); else if
75 * (sfs.length > 1) throw new
76 * SlcException("More than one execution flow found for " + filter); return
77 * (ExecutionFlow) bundleContext.getService(sfs[0]); }
78 */
79
80 }