Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2016-08-23 16:55:55 -0400
committerslewis2016-08-23 16:55:55 -0400
commit89ac3f3ad51b35bfe78e602ea273b740a821072e (patch)
tree0b6f54bc1596ce67d5084d8b37687581aa15ee63
parentfe6d21aef6910d83317b2235adcc047e98fc3c17 (diff)
downloadorg.eclipse.ecf-89ac3f3ad51b35bfe78e602ea273b740a821072e.tar.gz
org.eclipse.ecf-89ac3f3ad51b35bfe78e602ea273b740a821072e.tar.xz
org.eclipse.ecf-89ac3f3ad51b35bfe78e602ea273b740a821072e.zip
Fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=499946R-Release_HEAD-sdk_feature-276_276
-rw-r--r--protocols/bundles/ch.ethz.iks.r_osgi.remote/src/main/java/ch/ethz/iks/r_osgi/impl/ChannelEndpointImpl.java2
-rw-r--r--protocols/bundles/ch.ethz.iks.r_osgi.remote/src/main/java/ch/ethz/iks/r_osgi/impl/RemoteOSGiServiceImpl.java39
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.r_osgi/src/org/eclipse/ecf/internal/provider/r_osgi/R_OSGiRemoteServiceContainer.java11
3 files changed, 37 insertions, 15 deletions
diff --git a/protocols/bundles/ch.ethz.iks.r_osgi.remote/src/main/java/ch/ethz/iks/r_osgi/impl/ChannelEndpointImpl.java b/protocols/bundles/ch.ethz.iks.r_osgi.remote/src/main/java/ch/ethz/iks/r_osgi/impl/ChannelEndpointImpl.java
index 33d50aff7..e5e910456 100644
--- a/protocols/bundles/ch.ethz.iks.r_osgi.remote/src/main/java/ch/ethz/iks/r_osgi/impl/ChannelEndpointImpl.java
+++ b/protocols/bundles/ch.ethz.iks.r_osgi.remote/src/main/java/ch/ethz/iks/r_osgi/impl/ChannelEndpointImpl.java
@@ -1126,7 +1126,7 @@ public final class ChannelEndpointImpl implements ChannelEndpoint {
final LeaseMessage lease = (LeaseMessage) msg;
processLease(lease);
- populateLease(lease, RemoteOSGiServiceImpl.getServices(),
+ populateLease(lease, RemoteOSGiServiceImpl.getServices(networkChannel.getProtocol()),
RemoteOSGiServiceImpl.getTopics());
return lease;
}
diff --git a/protocols/bundles/ch.ethz.iks.r_osgi.remote/src/main/java/ch/ethz/iks/r_osgi/impl/RemoteOSGiServiceImpl.java b/protocols/bundles/ch.ethz.iks.r_osgi.remote/src/main/java/ch/ethz/iks/r_osgi/impl/RemoteOSGiServiceImpl.java
index 0fc077dd4..742576439 100644
--- a/protocols/bundles/ch.ethz.iks.r_osgi.remote/src/main/java/ch/ethz/iks/r_osgi/impl/RemoteOSGiServiceImpl.java
+++ b/protocols/bundles/ch.ethz.iks.r_osgi.remote/src/main/java/ch/ethz/iks/r_osgi/impl/RemoteOSGiServiceImpl.java
@@ -44,6 +44,7 @@ import java.util.Dictionary;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -488,11 +489,12 @@ final class RemoteOSGiServiceImpl implements RemoteOSGiService, Remoting {
final ServiceDiscoveryHandler handler = (ServiceDiscoveryHandler) context
.getService(reference);
- final RemoteServiceRegistration[] regs = (RemoteServiceRegistration[]) serviceRegistrations
- .values()
- .toArray(
- new RemoteServiceRegistration[serviceRegistrations
- .size()]);
+ RemoteServiceRegistration[] regs = null;
+
+ synchronized (serviceRegistrations) {
+ regs = (RemoteServiceRegistration[]) serviceRegistrations.values()
+ .toArray(new RemoteServiceRegistration[serviceRegistrations.size()]);
+ }
for (int i = 0; i < regs.length; i++) {
handler
@@ -556,7 +558,9 @@ final class RemoteOSGiServiceImpl implements RemoteOSGiService, Remoting {
+ " AS PROXIED SERVICES"); //$NON-NLS-1$
}
- serviceRegistrations.put(service, reg);
+ synchronized (serviceRegistrations) {
+ serviceRegistrations.put(service, reg);
+ }
registerWithServiceDiscovery(reg);
@@ -722,7 +726,7 @@ final class RemoteOSGiServiceImpl implements RemoteOSGiService, Remoting {
final NetworkChannelFactory factory = getNetworkChannelFactory(protocol);
channel = new ChannelEndpointImpl(factory, endpoint);
- return channel.sendLease(getServices(), getTopics());
+ return channel.sendLease(getServices(endpoint.getScheme()), getTopics());
}
/**
@@ -996,11 +1000,17 @@ final class RemoteOSGiServiceImpl implements RemoteOSGiService, Remoting {
*
* @return return the services.
*/
- static RemoteServiceRegistration[] getServices() {
- return (RemoteServiceRegistration[]) serviceRegistrations.values()
- .toArray(
- new RemoteServiceRegistration[serviceRegistrations
- .size()]);
+ static RemoteServiceRegistration[] getServices(String transport) {
+ List results = new ArrayList();
+ synchronized (serviceRegistrations) {
+ for (Iterator i = serviceRegistrations.keySet().iterator(); i.hasNext();) {
+ ServiceReference ref = (ServiceReference) i.next();
+ Object propVal = ref.getProperty(RemoteOSGiService.R_OSGi_REGISTRATION);
+ if (transport == null || propVal == null || propVal.equals(transport))
+ results.add(serviceRegistrations.get(ref));
+ }
+ }
+ return (RemoteServiceRegistration[]) results.toArray(new RemoteServiceRegistration[results.size()]);
}
/**
@@ -1023,8 +1033,9 @@ final class RemoteOSGiServiceImpl implements RemoteOSGiService, Remoting {
}
return null;
}
- return (RemoteServiceRegistration) serviceRegistrations
- .get(refs[0]);
+ synchronized (serviceRegistrations) {
+ return (RemoteServiceRegistration) serviceRegistrations.get(refs[0]);
+ }
} catch (final InvalidSyntaxException e) {
e.printStackTrace();
return null;
diff --git a/providers/bundles/org.eclipse.ecf.provider.r_osgi/src/org/eclipse/ecf/internal/provider/r_osgi/R_OSGiRemoteServiceContainer.java b/providers/bundles/org.eclipse.ecf.provider.r_osgi/src/org/eclipse/ecf/internal/provider/r_osgi/R_OSGiRemoteServiceContainer.java
index 4ff69d358..39e818f94 100644
--- a/providers/bundles/org.eclipse.ecf.provider.r_osgi/src/org/eclipse/ecf/internal/provider/r_osgi/R_OSGiRemoteServiceContainer.java
+++ b/providers/bundles/org.eclipse.ecf.provider.r_osgi/src/org/eclipse/ecf/internal/provider/r_osgi/R_OSGiRemoteServiceContainer.java
@@ -71,6 +71,9 @@ class R_OSGiRemoteServiceContainer implements IOSGiRemoteServiceContainerAdapter
// Connect context to use for connect calls
private IConnectContext connectContext;
+ // New system property to allow the per-transport exposure of remote services to be defeated.
+ private boolean exposeRemoteServicesOnAllTransports = Boolean.parseBoolean(System.getProperty("org.eclipse.ecf.internal.provider.r_osgi.exposeRemoteServicesOnAllTransports", "false")); //$NON-NLS-1$ //$NON-NLS-2$
+
public R_OSGiRemoteServiceContainer(RemoteOSGiService service, final ID containerID) throws IDCreateException {
Assert.isNotNull(service);
Assert.isNotNull(containerID);
@@ -444,6 +447,14 @@ class R_OSGiRemoteServiceContainer implements IOSGiRemoteServiceContainerAdapter
final Dictionary props = properties == null ? new Hashtable() : clone(properties);
+ R_OSGiNamespace ns = (R_OSGiNamespace) containerID.getNamespace();
+ // add the hint property for R-OSGi that this service is intended to be
+ // accessed remotely.
+ Object rosgiRegistrationValue = Boolean.TRUE;
+ if (!exposeRemoteServicesOnAllTransports)
+ rosgiRegistrationValue = (ns instanceof R_OSGiWSSNamespace) ? "https" : (ns instanceof R_OSGiWSNamespace) ? "http" : "r-osgi"; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
+
+ props.put(RemoteOSGiService.R_OSGi_REGISTRATION, rosgiRegistrationValue);
// add the hint property for R-OSGi that this service is intended to be
// accessed remotely.
props.put(RemoteOSGiService.R_OSGi_REGISTRATION, Boolean.TRUE);

Back to the top