Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2011-01-04 13:11:41 -0500
committerslewis2011-01-04 13:11:41 -0500
commit38ca20ed022460e01053e174f1461e49aacf4c5c (patch)
tree727f8782a05be9efeb20ed9625134e7de0a6a4c6 /incubation
parente551051957cfc14b058136a4d276d229998a88fc (diff)
downloadorg.eclipse.ecf-38ca20ed022460e01053e174f1461e49aacf4c5c.tar.gz
org.eclipse.ecf-38ca20ed022460e01053e174f1461e49aacf4c5c.tar.xz
org.eclipse.ecf-38ca20ed022460e01053e174f1461e49aacf4c5c.zip
rsa close fixes
Diffstat (limited to 'incubation')
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/Activator.java28
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractTopologyManager.java18
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteServiceAdmin.java41
3 files changed, 45 insertions, 42 deletions
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/Activator.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/Activator.java
index bb47a2043..e063a9081 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/Activator.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/Activator.java
@@ -10,10 +10,7 @@
package org.eclipse.ecf.internal.osgi.services.remoteserviceadmin;
import java.util.Dictionary;
-import java.util.Iterator;
-import java.util.Map;
import java.util.Properties;
-import java.util.TreeMap;
import java.util.UUID;
import javax.xml.parsers.SAXParserFactory;
@@ -52,7 +49,6 @@ public class Activator implements BundleActivator {
return instance;
}
- private Map<Bundle, RemoteServiceAdmin> remoteServiceAdmins = new TreeMap<Bundle, RemoteServiceAdmin>();
private ServiceRegistration remoteServiceAdminRegistration;
private EndpointDescriptionLocator endpointDescriptionLocator;
@@ -116,22 +112,12 @@ public class Activator implements BundleActivator {
.getName(), new ServiceFactory() {
public Object getService(Bundle bundle,
ServiceRegistration registration) {
- RemoteServiceAdmin rsa = new RemoteServiceAdmin(bundle);
- synchronized (remoteServiceAdmins) {
- remoteServiceAdmins.put(bundle, rsa);
- }
- return rsa;
+ return new RemoteServiceAdmin(bundle);
}
public void ungetService(Bundle bundle,
ServiceRegistration registration, Object service) {
-
- RemoteServiceAdmin rsa = null;
- synchronized (remoteServiceAdmins) {
- rsa = remoteServiceAdmins.get(bundle);
- }
- if (rsa != null)
- rsa.close();
+ if (service != null) ((RemoteServiceAdmin) service).close();
}
}, rsaProps);
}
@@ -141,16 +127,6 @@ public class Activator implements BundleActivator {
remoteServiceAdminRegistration.unregister();
remoteServiceAdminRegistration = null;
}
- synchronized (remoteServiceAdmins) {
- for (Iterator<Bundle> i = remoteServiceAdmins.keySet().iterator(); i
- .hasNext();) {
- RemoteServiceAdmin rsa = remoteServiceAdmins.get(i.next());
- if (rsa != null) {
- rsa.close();
- i.remove();
- }
- }
- }
}
private void startEndpointDescriptionAdvertiser() {
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractTopologyManager.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractTopologyManager.java
index ba7443449..7e2721824 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractTopologyManager.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractTopologyManager.java
@@ -79,6 +79,12 @@ public abstract class AbstractTopologyManager {
remoteServiceAdminTracker = null;
}
}
+ synchronized (exportedRegistrations) {
+ exportedRegistrations.clear();
+ }
+ synchronized (importedRegistrations) {
+ importedRegistrations.clear();
+ }
context = null;
}
@@ -109,7 +115,7 @@ public abstract class AbstractTopologyManager {
if (remoteServiceAdminTracker == null) {
remoteServiceAdminTracker = new ServiceTracker(getContext(),
createRSAFilter(), null);
- remoteServiceAdminTracker.open(true);
+ remoteServiceAdminTracker.open();
}
}
return (org.osgi.service.remoteserviceadmin.RemoteServiceAdmin) remoteServiceAdminTracker
@@ -376,10 +382,12 @@ public abstract class AbstractTopologyManager {
}
}
// Now close all of them
- for (org.osgi.service.remoteserviceadmin.ImportRegistration removedReg : removedRegistrations) {
- trace("unimportService", "closing importRegistration=" + removedReg);
- removedReg.close();
- }
+ if (removedRegistrations != null)
+ for (org.osgi.service.remoteserviceadmin.ImportRegistration removedReg : removedRegistrations) {
+ trace("unimportService", "closing importRegistration="
+ + removedReg);
+ removedReg.close();
+ }
}
}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteServiceAdmin.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteServiceAdmin.java
index b0aefbf60..8dab194e9 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteServiceAdmin.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteServiceAdmin.java
@@ -710,7 +710,7 @@ public class RemoteServiceAdmin implements
}
- class ImportReference implements
+ public class ImportReference implements
org.osgi.service.remoteserviceadmin.ImportReference {
private ServiceReference importedServiceReference;
@@ -916,8 +916,10 @@ public class RemoteServiceAdmin implements
public Collection<org.osgi.service.remoteserviceadmin.ExportReference> getExportedServices() {
Collection<org.osgi.service.remoteserviceadmin.ExportReference> results = new ArrayList<org.osgi.service.remoteserviceadmin.ExportReference>();
synchronized (exportedRegistrations) {
- for (ExportRegistration reg : exportedRegistrations)
- results.add(reg.getExportReference());
+ for (ExportRegistration reg : exportedRegistrations) {
+ org.osgi.service.remoteserviceadmin.ExportReference eRef = reg.getExportReference();
+ if (eRef != null) results.add(eRef);
+ }
}
return results;
}
@@ -925,8 +927,10 @@ public class RemoteServiceAdmin implements
public Collection<org.osgi.service.remoteserviceadmin.ImportReference> getImportedEndpoints() {
Collection<org.osgi.service.remoteserviceadmin.ImportReference> results = new ArrayList<org.osgi.service.remoteserviceadmin.ImportReference>();
synchronized (importedRegistrations) {
- for (ImportRegistration reg : importedRegistrations)
- results.add(reg.getImportReference());
+ for (ImportRegistration reg : importedRegistrations) {
+ org.osgi.service.remoteserviceadmin.ImportReference iRef = reg.getImportReference();
+ if (iRef != null) results.add(iRef);
+ }
}
return results;
}
@@ -1784,7 +1788,26 @@ public class RemoteServiceAdmin implements
intf, rsFilter);
}
+ private void closeExportRegistrations() {
+ List<ExportRegistration> toClose = null;
+ synchronized (exportedRegistrations) {
+ toClose = new ArrayList<ExportRegistration>(exportedRegistrations);
+ exportedRegistrations.clear();
+ }
+ for(ExportRegistration reg: toClose) reg.close();
+ }
+
+ private void closeImportRegistrations() {
+ List<ImportRegistration> toClose = null;
+ synchronized (importedRegistrations) {
+ toClose = new ArrayList<ImportRegistration>(importedRegistrations);
+ importedRegistrations.clear();
+ }
+ for(ImportRegistration reg: toClose) reg.close();
+ }
+
public void close() {
+ trace("close","closing importedRegistrations="+importedRegistrations+" exportedRegistrations="+exportedRegistrations);
closeRemoteServiceAdminListenerTracker();
closeEventAdminTracker();
closePackageAdminTracker();
@@ -1792,12 +1815,8 @@ public class RemoteServiceAdmin implements
closeConsumerContainerSelectorTracker();
closeHostContainerSelectorTracker();
closeDefaultContainerSelectors();
- synchronized (exportedRegistrations) {
- exportedRegistrations.clear();
- }
- synchronized (importedRegistrations) {
- importedRegistrations.clear();
- }
+ closeImportRegistrations();
+ closeExportRegistrations();
this.bundle = null;
}

Back to the top