Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/osgi
diff options
context:
space:
mode:
authorslewis2018-02-27 22:11:49 -0500
committerslewis2018-02-27 22:11:49 -0500
commitcdec999cfe3c26e21186d523106a887d35fdaeb8 (patch)
tree9d52faf4285a160f16e47cee792e559f83dd6791 /osgi
parent7421d1219725f3f87e443ed88024f8fb94c1eee4 (diff)
downloadorg.eclipse.ecf-cdec999cfe3c26e21186d523106a887d35fdaeb8.tar.gz
org.eclipse.ecf-cdec999cfe3c26e21186d523106a887d35fdaeb8.tar.xz
org.eclipse.ecf-cdec999cfe3c26e21186d523106a887d35fdaeb8.zip
Simplification of BasicTopologyManager
Diffstat (limited to 'osgi')
-rw-r--r--osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/ITopologyManager.java5
-rw-r--r--osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/TopologyManager.java5
-rw-r--r--osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/TopologyManagerImpl.java37
3 files changed, 47 insertions, 0 deletions
diff --git a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/ITopologyManager.java b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/ITopologyManager.java
index fbf8e612d..38068b0ee 100644
--- a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/ITopologyManager.java
+++ b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/ITopologyManager.java
@@ -32,6 +32,11 @@ public interface ITopologyManager {
public static final String ONLY_ECF_SCOPE = "(" + RemoteConstants.ENDPOINT_CONTAINER_ID_NAMESPACE + "=*)"; //$NON-NLS-1$ //$NON-NLS-2$
+ public static final String EXPORT_REGISTERED_SERVICES_FILTER_PROP = "exportRegisteredServicesFilter"; //$NON-NLS-1$
+ public static final String EXPORT_REGISTERED_SERVICES_FILTER = System.getProperty(
+ ITopologyManager.class.getName() + "." + EXPORT_REGISTERED_SERVICES_FILTER_PROP, //$NON-NLS-1$
+ "(service.exported.interfaces=*)"); //$NON-NLS-1$
+
public String[] getEndpointFilters();
public String[] setEndpointFilters(String[] newFilters);
diff --git a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/TopologyManager.java b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/TopologyManager.java
index fb2d1517a..08de73a3e 100644
--- a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/TopologyManager.java
+++ b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/TopologyManager.java
@@ -203,6 +203,11 @@ public class TopologyManager
}
}
}, (Dictionary<String, Object>) props);
+ String exportRegisteredSvcsFilter = (String) properties.get(EXPORT_REGISTERED_SERVICES_FILTER_PROP);
+ if (exportRegisteredSvcsFilter == null)
+ exportRegisteredSvcsFilter = EXPORT_REGISTERED_SERVICES_FILTER;
+
+ this.topologyManagerImpl.exportRegisteredServices(exportRegisteredSvcsFilter);
}
protected Dictionary<String, Object> createEndpointListenerProps(List<String> filters) {
diff --git a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/TopologyManagerImpl.java b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/TopologyManagerImpl.java
index cfd7b1212..7aaac8519 100644
--- a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/TopologyManagerImpl.java
+++ b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/TopologyManagerImpl.java
@@ -15,7 +15,9 @@ import org.eclipse.ecf.osgi.services.remoteserviceadmin.AbstractTopologyManager;
import org.eclipse.ecf.osgi.services.remoteserviceadmin.EndpointDescription;
import org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceReference;
import org.osgi.service.remoteserviceadmin.EndpointEvent;
import org.osgi.service.remoteserviceadmin.EndpointEventListener;
import org.osgi.service.remoteserviceadmin.RemoteServiceAdminEvent;
@@ -118,4 +120,39 @@ public class TopologyManagerImpl extends AbstractTopologyManager implements Endp
String matchedFilter) {
handleECFEndpointModified((EndpointDescription) endpoint);
}
+
+ protected void exportRegisteredServices(String exportRegisteredSvcsFilter) {
+ try {
+ final ServiceReference[] existingServiceRefs = getContext()
+ .getAllServiceReferences(null, exportRegisteredSvcsFilter);
+ // Now export as if the service was registering right now...i.e.
+ // perform
+ // export
+ if (existingServiceRefs != null && existingServiceRefs.length > 0) {
+ // After having collected all pre-registered services (with
+ // marker prop) we are going to asynchronously remote them.
+ // Registering potentially is a long-running operation (due to
+ // discovery I/O...) and thus should no be carried out in the
+ // OSGi FW thread. (https://bugs.eclipse.org/405027)
+ new Thread(new Runnable() {
+ public void run() {
+ for (int i = 0; i < existingServiceRefs.length; i++) {
+ // This method will check the service properties for
+ // remote service props. If previously registered as
+ // a
+ // remote service, it will export the remote
+ // service if not it will simply return/skip
+ handleServiceRegistering(existingServiceRefs[i]);
+ }
+ }
+ }, "BasicTopologyManagerPreRegSrvExporter").start(); //$NON-NLS-1$
+ }
+ } catch (InvalidSyntaxException e) {
+ logError("exportRegisteredServices", //$NON-NLS-1$
+ "Could not retrieve existing service references for exportRegisteredSvcsFilter=" //$NON-NLS-1$
+ + exportRegisteredSvcsFilter,
+ e);
+ }
+ }
+
}

Back to the top