summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/extensibility-equinox/src
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-05-27 01:23:40 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-05-27 01:23:40 +0000
commit3635a0ee6f59980439ec043f2251d950e4ffb8a4 (patch)
treedf7870b015abf1b4e6559d8045fb81293e7e7b31 /java/sca/modules/extensibility-equinox/src
parentd8da679db3c406c9c56cc14d047645d0cebb7afd (diff)
Add optional life cycle control for extension points (for example, RMI extension point needs to unexport the registry)
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@778955 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/extensibility-equinox/src')
-rw-r--r--java/sca/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/OSGiExtensionPointRegistry.java23
1 files changed, 23 insertions, 0 deletions
diff --git a/java/sca/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/OSGiExtensionPointRegistry.java b/java/sca/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/OSGiExtensionPointRegistry.java
index a84268cc69..8c8ace95ad 100644
--- a/java/sca/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/OSGiExtensionPointRegistry.java
+++ b/java/sca/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/OSGiExtensionPointRegistry.java
@@ -21,10 +21,12 @@ package org.apache.tuscany.sca.extensibility.equinox;
import java.util.Dictionary;
import java.util.Hashtable;
+import java.util.IdentityHashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ModuleActivator;
import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -99,4 +101,25 @@ public class OSGiExtensionPointRegistry extends DefaultExtensionPointRegistry {
services.remove(i);
}
+ @Override
+ public void destroy() {
+ // Get a unique map as an extension point may exist in the map by different keys
+ Map<ModuleActivator, ModuleActivator> map = new IdentityHashMap<ModuleActivator, ModuleActivator>();
+ for (ServiceRegistration reg : services.values()) {
+ ServiceReference ref = reg.getReference();
+ if (ref != null) {
+ Object service = bundleContext.getService(ref);
+ if (service instanceof ModuleActivator) {
+ ModuleActivator activator = (ModuleActivator)service;
+ map.put(activator, activator);
+ }
+ reg.unregister();
+ }
+ }
+ for (ModuleActivator activator : map.values()) {
+ activator.stop(this);
+ }
+ services.clear();
+ }
+
}