Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis@composent.com2010-12-09 00:53:02 +0000
committerslewis@composent.com2010-12-09 00:53:02 +0000
commit381ae3c9737897aff0d71edd949b5eb02e02ee37 (patch)
tree186b639d88116592fd3aa7b2ec231c5c32446144 /incubation
parent8c592e4f5648c85ccdb14566f8675719b8266270 (diff)
downloadorg.eclipse.ecf-381ae3c9737897aff0d71edd949b5eb02e02ee37.tar.gz
org.eclipse.ecf-381ae3c9737897aff0d71edd949b5eb02e02ee37.tar.xz
org.eclipse.ecf-381ae3c9737897aff0d71edd949b5eb02e02ee37.zip
rsa unexport implementation added
Diffstat (limited to 'incubation')
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractTopologyManager.java33
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteServiceAdmin.java51
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/TopologyManager.java11
3 files changed, 63 insertions, 32 deletions
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 fbefb8ded..f2d574b55 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
@@ -196,30 +196,35 @@ public abstract class AbstractTopologyManager {
this.getClass(), message);
}
- protected void publishExportedRegistrations(
- Collection<org.osgi.service.remoteserviceadmin.ExportRegistration> registrations) {
- for (org.osgi.service.remoteserviceadmin.ExportRegistration reg : registrations) {
- if (reg instanceof ExportRegistration) {
- publishExportedRegistration((ExportRegistration) reg);
- }
+ protected void advertiseEndpointDescription(EndpointDescription endpointDescription) {
+ IEndpointDescriptionAdvertiser advertiser = getEndpointDescriptionAdvertiser();
+ if (advertiser == null) {
+ logError("advertiseExportedRegistration",
+ "No endpoint description advertiser available to advertise endpointDescription="
+ + endpointDescription);
+ return;
}
+ // Now advertise endpoint description using endpoint description advertiser
+ IStatus result = advertiser.advertise(endpointDescription);
+ if (!result.isOK())
+ logError("advertiseExportedRegistration",
+ "Advertise of endpointDescription=" + endpointDescription + " FAILED",
+ result);
}
- private void publishExportedRegistration(ExportRegistration reg) {
+ protected void unadvertiseEndpointDescription(EndpointDescription endpointDescription) {
IEndpointDescriptionAdvertiser advertiser = getEndpointDescriptionAdvertiser();
if (advertiser == null) {
logError("advertiseExportedRegistration",
- "No endpoint description advertiser available to advertise ExportRegistration="
- + reg);
+ "No endpoint description advertiser available to unadvertise endpointDescription="
+ + endpointDescription);
return;
}
- // Now advertise endpoint description using endpoint description
- // advertiser
- IStatus result = advertiser.advertise((EndpointDescription) reg
- .getExportReference().getExportedEndpoint());
+ // Now unadvertise endpoint description using endpoint description advertiser
+ IStatus result = advertiser.unadvertise(endpointDescription);
if (!result.isOK())
logError("advertiseExportedRegistration",
- "Advertise of ExportRegistration=" + reg + " FAILED",
+ "Unadvertise of endpointDescription=" + endpointDescription + " FAILED",
result);
}
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 1fa80a006..e9fdf858e 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
@@ -77,9 +77,14 @@ public class RemoteServiceAdmin extends AbstractRemoteServiceAdmin implements
ExportRegistration rsRegistration = null;
try {
rsRegistration = doExportService(serviceReference,
- properties, exportedInterfaces, serviceIntents, rsContainers[i]);
+ properties, exportedInterfaces, serviceIntents,
+ rsContainers[i]);
} catch (Exception e) {
- logError("exportService", "Exception exporting serviceReference="+serviceReference+" with properties="+properties+" rsContainerID="+rsContainers[i].getContainer().getID(),e);
+ logError("exportService",
+ "Exception exporting serviceReference="
+ + serviceReference + " with properties="
+ + properties + " rsContainerID="
+ + rsContainers[i].getContainer().getID(), e);
rsRegistration = new ExportRegistration(e);
}
results.add(rsRegistration);
@@ -91,10 +96,8 @@ public class RemoteServiceAdmin extends AbstractRemoteServiceAdmin implements
private ExportRegistration doExportService(
ServiceReference serviceReference, Map<String, Object> properties,
- String [] exportedInterfaces,
- String [] serviceIntents,
- IRemoteServiceContainer rsContainer)
- throws Exception {
+ String[] exportedInterfaces, String[] serviceIntents,
+ IRemoteServiceContainer rsContainer) throws Exception {
IRemoteServiceRegistration remoteRegistration = null;
try {
// Create remote service properties for remote service export
@@ -103,21 +106,23 @@ public class RemoteServiceAdmin extends AbstractRemoteServiceAdmin implements
// Get container adapter
IRemoteServiceContainerAdapter containerAdapter = rsContainer
.getContainerAdapter();
- // If it's an IOSGiRemoteServiceContainerAdapter then call it one way
+ // If it's an IOSGiRemoteServiceContainerAdapter then call it one
+ // way
if (containerAdapter instanceof IOSGiRemoteServiceContainerAdapter) {
IOSGiRemoteServiceContainerAdapter osgiContainerAdapter = (IOSGiRemoteServiceContainerAdapter) containerAdapter;
remoteRegistration = osgiContainerAdapter
.registerRemoteService(exportedInterfaces,
serviceReference, remoteServiceProperties);
} else {
- // call it the normal way
+ // call it the normal way
remoteRegistration = containerAdapter.registerRemoteService(
exportedInterfaces, getService(serviceReference),
remoteServiceProperties);
}
// Create EndpointDescription from remoteRegistration
EndpointDescription endpointDescription = createExportEndpointDescription(
- serviceReference, properties, exportedInterfaces, serviceIntents, remoteRegistration, rsContainer);
+ serviceReference, properties, exportedInterfaces,
+ serviceIntents, remoteRegistration, rsContainer);
// Create ExportRegistration
return createExportRegistration(remoteRegistration,
serviceReference, endpointDescription);
@@ -329,23 +334,37 @@ public class RemoteServiceAdmin extends AbstractRemoteServiceAdmin implements
super.close();
}
- private ExportRegistration[] findExportRegistrations(ServiceReference serviceReference) {
+ private ExportRegistration[] findExportRegistrations(
+ ServiceReference serviceReference) {
List<ExportRegistration> results = new ArrayList<ExportRegistration>();
- for(ExportRegistration exportReg: exportedRegistrations) {
- if (exportReg.matchesServiceReference(serviceReference)) results.add(exportReg);
- }
+ for (ExportRegistration exportReg : exportedRegistrations)
+ if (exportReg.matchesServiceReference(serviceReference))
+ results.add(exportReg);
return results.toArray(new ExportRegistration[results.size()]);
}
-
- public void unexportService(ServiceReference serviceReference) {
+
+ public EndpointDescription[] unexportService(ServiceReference serviceReference) {
+ List<EndpointDescription> endpointDescriptions = new ArrayList<EndpointDescription>();
synchronized (exportedRegistrations) {
ExportRegistration[] exportRegs = findExportRegistrations(serviceReference);
if (exportRegs != null) {
- for(int i=0; i < exportRegs.length; i++) {
+ for (int i = 0; i < exportRegs.length; i++) {
+ org.osgi.service.remoteserviceadmin.ExportReference exportRef = exportRegs[i]
+ .getExportReference();
+ if (exportRef != null) {
+ org.osgi.service.remoteserviceadmin.EndpointDescription endpointDescription = exportRef
+ .getExportedEndpoint();
+ if (endpointDescription != null
+ && endpointDescription instanceof EndpointDescription) {
+ endpointDescriptions
+ .add((EndpointDescription) endpointDescription);
+ }
+ }
exportRegs[i].close();
exportedRegistrations.remove(exportRegs[i]);
}
}
}
+ return endpointDescriptions.toArray(new EndpointDescription[endpointDescriptions.size()]);
}
}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/TopologyManager.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/TopologyManager.java
index 367a0e5d8..c052539e9 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/TopologyManager.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/TopologyManager.java
@@ -192,7 +192,9 @@ public class TopologyManager extends AbstractTopologyManager implements
}
// publish exported registrations
- publishExportedRegistrations(registrations);
+ for (org.osgi.service.remoteserviceadmin.ExportRegistration reg : registrations) {
+ advertiseEndpointDescription((EndpointDescription) reg.getExportReference().getExportedEndpoint());
+ }
}
@@ -210,7 +212,12 @@ public class TopologyManager extends AbstractTopologyManager implements
+ ". Remote service NOT UNEXPORTED");
return;
}
- rsa.unexportService(serviceReference);
+ EndpointDescription[] endpointDescriptions = rsa.unexportService(serviceReference);
+ if (endpointDescriptions != null) {
+ for(int i=0; i < endpointDescriptions.length; i++) {
+ unadvertiseEndpointDescription(endpointDescriptions[i]);
+ }
+ }
}
}

Back to the top