]> git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.support.osgi/src/main/java/org/argeo/slc/osgi/OsgiExecutionModule.java
Improve Javadocs
[gpl/argeo-slc.git] / runtime / org.argeo.slc.support.osgi / src / main / java / org / argeo / slc / osgi / OsgiExecutionModule.java
1 /*
2 * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package org.argeo.slc.osgi;
18
19 import org.apache.commons.logging.Log;
20 import org.apache.commons.logging.LogFactory;
21 import org.argeo.slc.core.execution.AbstractSpringExecutionModule;
22 import org.argeo.slc.execution.ExecutionContext;
23
24 @Deprecated
25 public class OsgiExecutionModule extends AbstractSpringExecutionModule {
26 private final static Log log = LogFactory.getLog(OsgiExecutionModule.class);
27
28 public OsgiExecutionModule() {
29 log.error("######## ERROR - DEPRECATED APPROACH USED ########");
30 log.error(OsgiExecutionModule.class.getName() + " is deprecated. ");
31 log
32 .error("It will be removed in the next release. Remove its bean definition.");
33 log
34 .error("And replace: <service interface=\"org.argeo.slc.execution.ExecutionModule\" ref=\"executionModule\" />");
35 log
36 .error("by: <beans:import resource=\"classpath:org/argeo/slc/osgi/execution/spring.xml\" /> ");
37 log.error("in osgi.xml.\n\n");
38 }
39
40 public void setExecutionContext(ExecutionContext executionContext) {
41 // do nothing, just for compatibility
42 }
43
44 /*
45 * private BundleContext bundleContext;
46 *
47 * @Override public void execute(ExecutionFlowDescriptor
48 * executionFlowDescriptor) { if (descriptorConverter != null)
49 * executionContext.addVariables(descriptorConverter
50 * .convertValues(executionFlowDescriptor));
51 *
52 * ExecutionFlow flow = findExecutionFlow(getName(), getVersion(),
53 * executionFlowDescriptor.getName()); flow.run(); }
54 *
55 * @Override protected Map<String, ExecutionFlow> listFlows() { String
56 * filter = "(org.argeo.slc.execution.module.name=" + getName() + ")";
57 * ServiceReference[] sfs; try { sfs =
58 * bundleContext.getServiceReferences(ExecutionFlow.class .getName(),
59 * filter); } catch (InvalidSyntaxException e) { throw new SlcException(
60 * "Cannot retrieve service reference for flow " + filter, e); }
61 *
62 * Map<String, ExecutionFlow> flows = new HashMap<String, ExecutionFlow>();
63 * for (ServiceReference sf : sfs) { ExecutionFlow flow = (ExecutionFlow)
64 * bundleContext.getService(sf); flows.put(flow.getName(), flow); } return
65 * flows; }
66 *
67 * public String getName() { return
68 * bundleContext.getBundle().getSymbolicName(); }
69 *
70 * public String getVersion() { return
71 * bundleContext.getBundle().getHeaders().get("Bundle-Version") .toString();
72 * }
73 *
74 * public void setBundleContext(BundleContext bundleContext) {
75 * this.bundleContext = bundleContext; }
76 *
77 * protected ExecutionFlow findExecutionFlow(String moduleName, String
78 * moduleVersion, String flowName) { String filter =
79 * "(&(org.argeo.slc.execution.module.name=" + moduleName +
80 * ")(org.argeo.slc.execution.flow.name=" + flowName + "))";
81 * log.debug("OSGi filter: " + filter);
82 *
83 * Assert.isTrue(OsgiFilterUtils.isValidFilter(filter), "valid filter");
84 * ServiceReference[] sfs; try { sfs =
85 * bundleContext.getServiceReferences(ExecutionFlow.class .getName(),
86 * filter); } catch (InvalidSyntaxException e) { throw new
87 * SlcException("Cannot retrieve service reference for " + filter, e); }
88 *
89 * if (sfs == null || sfs.length == 0) throw new
90 * SlcException("No execution flow found for " + filter); else if
91 * (sfs.length > 1) throw new
92 * SlcException("More than one execution flow found for " + filter); return
93 * (ExecutionFlow) bundleContext.getService(sfs[0]); }
94 */
95
96 }