+ @SuppressWarnings("rawtypes")
+ public synchronized void unbind(Object service, Map properties)
+ throws Exception {
+ if (service instanceof ExecutionContext) {
+ OsgiBundle osgiBundle = asOsgiBundle(properties);
+ if (executionContexts.containsKey(osgiBundle)) {
+ ExecutionContext executionContext = executionContexts
+ .remove(osgiBundle);
+ if (log.isTraceEnabled())
+ log.debug("Removed execution context from " + osgiBundle);
+ // Notify
+ for (ExecutionModulesListener listener : getExecutionModulesListeners())
+ listener.executionModuleRemoved(osgiBundle,
+ executionContext);
+ }
+ } else if (service instanceof ExecutionFlow) {
+ ExecutionFlow executionFlow = (ExecutionFlow) service;
+ OsgiBundle osgiBundle = asOsgiBundle(properties);
+ if (executionFlows.containsKey(osgiBundle)) {
+ Set flows = executionFlows.get(osgiBundle);
+ flows.remove(executionFlow);
+ if (log.isTraceEnabled())
+ log.debug("Removed " + executionFlow + " from "
+ + osgiBundle);
+ if (flows.size() == 0) {
+ executionFlows.remove(osgiBundle);
+ if (log.isTraceEnabled())
+ log.debug("Removed flows set from " + osgiBundle);
+ }
+ for (ExecutionModulesListener listener : getExecutionModulesListeners())
+ listener.executionFlowRemoved(osgiBundle, executionFlow);
+ }
+ } else if (service instanceof ExecutionFlowDescriptorConverter) {
+ OsgiBundle osgiBundle = asOsgiBundle(properties);
+ if (executionFlowDescriptorConverters.containsKey(osgiBundle)) {
+ executionFlowDescriptorConverters.remove(osgiBundle);
+ if (log.isTraceEnabled())
+ log.debug("Removed execution flow descriptor converter from "
+ + osgiBundle);
+ }
+ } else {
+ // ignore
+ }
+ }
+
+ @SuppressWarnings("rawtypes")
+ private OsgiBundle asOsgiBundle(Map properties) {
+ String bundleSymbolicName = checkAndGet(Constants.BUNDLE_SYMBOLICNAME,
+ properties);
+ String bundleVersion = checkAndGet(Constants.BUNDLE_VERSION, properties);
+ return new OsgiBundle(bundleSymbolicName, bundleVersion);
+ }
+
+ @SuppressWarnings("rawtypes")
+ private String checkAndGet(Object key, Map properties) {
+ if (!properties.containsKey(key) || properties.get(key) == null)
+ throw new SlcException(key + " not set in " + properties);
+ else
+ return properties.get(key).toString();
+ }
+
+ public void setDefaultDescriptorConverter(
+ ExecutionFlowDescriptorConverter defaultDescriptorConverter) {
+ this.defaultDescriptorConverter = defaultDescriptorConverter;
+ }