Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2009-02-23 00:57:30 +0000
committerslewis2009-02-23 00:57:30 +0000
commitcb3aa7a02c72b9a3d0332cc020ab3d81c839cdc1 (patch)
tree369fe01451d0b414fb45733b16bb21cbdb823439 /providers
parent33ab434e7f2612b7efccc37a34dd4cd5c485c688 (diff)
downloadorg.eclipse.ecf-cb3aa7a02c72b9a3d0332cc020ab3d81c839cdc1.tar.gz
org.eclipse.ecf-cb3aa7a02c72b9a3d0332cc020ab3d81c839cdc1.tar.xz
org.eclipse.ecf-cb3aa7a02c72b9a3d0332cc020ab3d81c839cdc1.zip
Additions for RFC 119 support. See bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=249240#c11
Diffstat (limited to 'providers')
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.remoteservice/plugin.xml8
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RegistrySharedObject.java54
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RemoteServiceContainer.java13
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RemoteServiceNamespace.java44
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RemoteServiceReferenceImpl.java7
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RemoteServiceRegistrationImpl.java31
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RemoteServiceRegistryImpl.java5
7 files changed, 141 insertions, 21 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.remoteservice/plugin.xml b/providers/bundles/org.eclipse.ecf.provider.remoteservice/plugin.xml
index 5daf1858b..a28d6e121 100644
--- a/providers/bundles/org.eclipse.ecf.provider.remoteservice/plugin.xml
+++ b/providers/bundles/org.eclipse.ecf.provider.remoteservice/plugin.xml
@@ -17,5 +17,13 @@
<adapter type="org.eclipse.ecf.remoteservice.IRemoteServiceContainerAdapter"/>
</factory>
</extension>
+ <extension
+ point="org.eclipse.ecf.identity.namespace">
+ <namespace
+ class="org.eclipse.ecf.provider.remoteservice.generic.RemoteServiceNamespace"
+ description="Generic remote service namespace"
+ name="ecf.namespace.generic.remoteservice">
+ </namespace>
+ </extension>
</plugin>
diff --git a/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RegistrySharedObject.java b/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RegistrySharedObject.java
index 7821a6eaa..80a7d0b69 100644
--- a/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RegistrySharedObject.java
+++ b/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RegistrySharedObject.java
@@ -8,8 +8,6 @@
******************************************************************************/
package org.eclipse.ecf.provider.remoteservice.generic;
-import org.eclipse.ecf.core.jobs.JobsExecutor;
-
import java.io.IOException;
import java.io.Serializable;
import java.security.*;
@@ -18,8 +16,8 @@ import org.eclipse.core.runtime.*;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.ecf.core.events.IContainerConnectedEvent;
import org.eclipse.ecf.core.events.IContainerDisconnectedEvent;
-import org.eclipse.ecf.core.identity.ID;
-import org.eclipse.ecf.core.identity.Namespace;
+import org.eclipse.ecf.core.identity.*;
+import org.eclipse.ecf.core.jobs.JobsExecutor;
import org.eclipse.ecf.core.sharedobject.*;
import org.eclipse.ecf.core.sharedobject.events.ISharedObjectActivatedEvent;
import org.eclipse.ecf.core.util.*;
@@ -1016,7 +1014,7 @@ public class RegistrySharedObject extends BaseSharedObject implements IRemoteSer
* @since 3.0
*/
public Namespace getRemoteServiceNamespace() {
- return getSOContext().getConnectNamespace();
+ return IDFactory.getDefault().getNamespaceByName(RemoteServiceNamespace.NAME);
}
/**
@@ -1025,4 +1023,50 @@ public class RegistrySharedObject extends BaseSharedObject implements IRemoteSer
public IRemoteFilter createRemoteFilter(String filter) throws InvalidSyntaxException {
return new RemoteFilterImpl(filter);
}
+
+ /**
+ * @since 3.0
+ */
+ public IRemoteServiceReference getRemoteServiceReference(IRemoteServiceID serviceId) {
+ ID containerID = serviceId.getContainerID();
+ RemoteServiceRegistrationImpl registration = null;
+ if (this.localRegistry.containerID.equals(containerID)) {
+ synchronized (localRegistry) {
+ registration = localRegistry.findRegistrationForServiceId(serviceId.getContainerRelativeID());
+ if (registration != null)
+ return registration.getReference();
+ }
+ } else {
+ synchronized (remoteRegistrys) {
+ final ArrayList registrys = new ArrayList(remoteRegistrys.values());
+ for (final Iterator i = registrys.iterator(); i.hasNext();) {
+ final RemoteServiceRegistryImpl registry = (RemoteServiceRegistryImpl) i.next();
+ registration = registry.findRegistrationForServiceId(serviceId.getContainerRelativeID());
+ }
+ }
+ }
+ return (registration == null) ? null : registration.getReference();
+ }
+
+ public IRemoteServiceID getRemoteServiceID(ID containerId, long containerRelativeId) {
+ if (containerId == null)
+ return null;
+ synchronized (localRegistry) {
+ if (localRegistry.containerID.equals(containerId)) {
+ RemoteServiceRegistrationImpl reg = localRegistry.findRegistrationForServiceId(containerRelativeId);
+ if (reg != null)
+ return reg.getID();
+ }
+ }
+ synchronized (remoteRegistrys) {
+ final ArrayList registrys = new ArrayList(remoteRegistrys.values());
+ for (final Iterator i = registrys.iterator(); i.hasNext();) {
+ final RemoteServiceRegistryImpl registry = (RemoteServiceRegistryImpl) i.next();
+ RemoteServiceRegistrationImpl reg = registry.findRegistrationForServiceId(containerRelativeId);
+ if (reg != null)
+ return reg.getID();
+ }
+ }
+ return null;
+ }
}
diff --git a/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RemoteServiceContainer.java b/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RemoteServiceContainer.java
index 34003dc31..28a74717b 100644
--- a/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RemoteServiceContainer.java
+++ b/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RemoteServiceContainer.java
@@ -70,7 +70,7 @@ public class RemoteServiceContainer extends TCPClientSOContainer implements IRem
* @since 3.0
*/
public Namespace getRemoteServiceNamespace() {
- return getConnectNamespace();
+ return registry.getRemoteServiceNamespace();
}
/**
@@ -79,4 +79,15 @@ public class RemoteServiceContainer extends TCPClientSOContainer implements IRem
public IRemoteFilter createRemoteFilter(String filter) throws InvalidSyntaxException {
return registry.createRemoteFilter(filter);
}
+
+ /**
+ * @since 3.0
+ */
+ public IRemoteServiceReference getRemoteServiceReference(IRemoteServiceID serviceID) {
+ return registry.getRemoteServiceReference(serviceID);
+ }
+
+ public IRemoteServiceID getRemoteServiceID(ID containerID, long containerRelativeID) {
+ return registry.getRemoteServiceID(containerID, containerRelativeID);
+ }
}
diff --git a/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RemoteServiceNamespace.java b/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RemoteServiceNamespace.java
new file mode 100644
index 000000000..583c09ac4
--- /dev/null
+++ b/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RemoteServiceNamespace.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+* Copyright (c) 2009 EclipseSource and others. All rights reserved. This
+* program and the accompanying materials are made available under the terms of
+* the Eclipse Public License v1.0 which accompanies this distribution, and is
+* available at http://www.eclipse.org/legal/epl-v10.html
+*
+* Contributors:
+* EclipseSource - initial API and implementation
+******************************************************************************/
+package org.eclipse.ecf.provider.remoteservice.generic;
+
+import org.eclipse.ecf.core.identity.*;
+import org.eclipse.ecf.remoteservice.RemoteServiceID;
+
+public class RemoteServiceNamespace extends Namespace {
+
+ private static final long serialVersionUID = 1389616654436118037L;
+ private static final String REMOTE_SERVICE_SCHEME = "remoteservice"; //$NON-NLS-1$
+
+ public static final String NAME = "ecf.namespace.generic.remoteservice"; //$NON-NLS-1$
+
+ public RemoteServiceNamespace() {
+ // nothing
+ }
+
+ public RemoteServiceNamespace(String name, String desc) {
+ super(name, desc);
+ }
+
+ public ID createInstance(Object[] parameters) throws IDCreateException {
+ if (parameters == null || parameters.length != 2)
+ throw new IDCreateException("Parameters incorrect for remote ID creation"); //$NON-NLS-1$
+ try {
+ return new RemoteServiceID(this, (ID) parameters[0], ((Long) parameters[1]).longValue());
+ } catch (Exception e) {
+ throw new IDCreateException("Exception creating remoteID", e); //$NON-NLS-1$
+ }
+ }
+
+ public String getScheme() {
+ return REMOTE_SERVICE_SCHEME;
+ }
+
+}
diff --git a/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RemoteServiceReferenceImpl.java b/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RemoteServiceReferenceImpl.java
index 118433fad..38fc78625 100644
--- a/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RemoteServiceReferenceImpl.java
+++ b/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RemoteServiceReferenceImpl.java
@@ -9,6 +9,7 @@
package org.eclipse.ecf.provider.remoteservice.generic;
import org.eclipse.ecf.core.identity.ID;
+import org.eclipse.ecf.remoteservice.IRemoteServiceID;
import org.eclipse.ecf.remoteservice.IRemoteServiceReference;
public class RemoteServiceReferenceImpl implements IRemoteServiceReference {
@@ -53,11 +54,15 @@ public class RemoteServiceReferenceImpl implements IRemoteServiceReference {
protected String getRemoteClass() {
return clazz;
}
-
+
public String toString() {
StringBuffer buf = new StringBuffer("RemoteServiceReferenceImpl["); //$NON-NLS-1$
buf.append("class=").append(getRemoteClass()).append(";"); //$NON-NLS-1$ //$NON-NLS-2$
buf.append("registration=").append(getRegistration()).append("]"); //$NON-NLS-1$ //$NON-NLS-2$
return buf.toString();
}
+
+ public IRemoteServiceID getID() {
+ return registration.getID();
+ }
}
diff --git a/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RemoteServiceRegistrationImpl.java b/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RemoteServiceRegistrationImpl.java
index 2ef6e16f0..1b19d8b49 100644
--- a/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RemoteServiceRegistrationImpl.java
+++ b/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RemoteServiceRegistrationImpl.java
@@ -13,8 +13,7 @@ import java.lang.reflect.Array;
import java.util.*;
import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.internal.provider.remoteservice.Messages;
-import org.eclipse.ecf.remoteservice.IRemoteServiceReference;
-import org.eclipse.ecf.remoteservice.IRemoteServiceRegistration;
+import org.eclipse.ecf.remoteservice.*;
public class RemoteServiceRegistrationImpl implements IRemoteServiceRegistration, Serializable {
@@ -25,9 +24,6 @@ public class RemoteServiceRegistrationImpl implements IRemoteServiceRegistration
/** service classes for this registration. */
protected String[] clazzes;
- /** service id. */
- protected long serviceid;
-
/** properties for this registration. */
protected Properties properties;
@@ -40,8 +36,6 @@ public class RemoteServiceRegistrationImpl implements IRemoteServiceRegistration
/** The registration state */
protected int state = REGISTERED;
- protected ID containerID = null;
-
public static final int REGISTERED = 0x00;
public static final int UNREGISTERING = 0x01;
@@ -52,6 +46,8 @@ public class RemoteServiceRegistrationImpl implements IRemoteServiceRegistration
protected transient RegistrySharedObject sharedObject = null;
+ protected IRemoteServiceID remoteServiceID;
+
public RemoteServiceRegistrationImpl() {
//
@@ -61,10 +57,9 @@ public class RemoteServiceRegistrationImpl implements IRemoteServiceRegistration
this.sharedObject = sharedObject1;
this.service = svc;
this.clazzes = clzzes;
- this.containerID = registry.getContainerID();
this.reference = new RemoteServiceReferenceImpl(this);
synchronized (registry) {
- serviceid = registry.getNextServiceId();
+ this.remoteServiceID = registry.createRemoteServiceID(registry.getNextServiceId());
this.properties = createProperties(props);
registry.publishService(this);
}
@@ -75,7 +70,7 @@ public class RemoteServiceRegistrationImpl implements IRemoteServiceRegistration
}
public ID getContainerID() {
- return containerID;
+ return (remoteServiceID == null) ? null : remoteServiceID.getContainerID();
}
protected String[] getClasses() {
@@ -122,7 +117,7 @@ public class RemoteServiceRegistrationImpl implements IRemoteServiceRegistration
resultProps.setProperty(RemoteServiceRegistryImpl.REMOTEOBJECTCLASS, clazzes);
- resultProps.setProperty(RemoteServiceRegistryImpl.REMOTESERVICE_ID, new Long(serviceid));
+ resultProps.setProperty(RemoteServiceRegistryImpl.REMOTESERVICE_ID, new Long(getID().getContainerRelativeID()));
final Object ranking = resultProps.getProperty(RemoteServiceRegistryImpl.REMOTESERVICE_RANKING);
@@ -315,7 +310,10 @@ public class RemoteServiceRegistrationImpl implements IRemoteServiceRegistration
}
public long getServiceId() {
- return serviceid;
+ IRemoteServiceID rsID = getID();
+ if (rsID == null)
+ return 0L;
+ return rsID.getContainerRelativeID();
}
public Object callService(RemoteCallImpl call) throws Exception {
@@ -324,8 +322,9 @@ public class RemoteServiceRegistrationImpl implements IRemoteServiceRegistration
public String toString() {
StringBuffer buf = new StringBuffer("RemoteServiceRegistrationImpl["); //$NON-NLS-1$
- buf.append("containerID=").append(containerID).append(";"); //$NON-NLS-1$ //$NON-NLS-2$
- buf.append("serviceid=").append(serviceid).append(";"); //$NON-NLS-1$ //$NON-NLS-2$
+ buf.append("remoteServiceID=").append(getID()).append(";"); //$NON-NLS-1$ //$NON-NLS-2$
+ buf.append("containerID=").append(getContainerID()).append(";"); //$NON-NLS-1$ //$NON-NLS-2$
+ buf.append("serviceid=").append(getID().getContainerRelativeID()).append(";"); //$NON-NLS-1$ //$NON-NLS-2$
buf.append("serviceranking=").append(serviceranking).append(";"); //$NON-NLS-1$ //$NON-NLS-2$
buf.append("classes=").append(Arrays.asList(clazzes)).append(";"); //$NON-NLS-1$ //$NON-NLS-2$
buf.append("state=").append(state).append(";"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -333,4 +332,8 @@ public class RemoteServiceRegistrationImpl implements IRemoteServiceRegistration
return buf.toString();
}
+ public IRemoteServiceID getID() {
+ return this.remoteServiceID;
+ }
+
}
diff --git a/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RemoteServiceRegistryImpl.java b/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RemoteServiceRegistryImpl.java
index 157bb0ec2..98fbaa7d8 100644
--- a/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RemoteServiceRegistryImpl.java
+++ b/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RemoteServiceRegistryImpl.java
@@ -11,6 +11,7 @@ package org.eclipse.ecf.provider.remoteservice.generic;
import java.io.Serializable;
import java.util.*;
import org.eclipse.ecf.core.identity.ID;
+import org.eclipse.ecf.core.identity.IDFactory;
import org.eclipse.ecf.remoteservice.*;
public class RemoteServiceRegistryImpl implements Serializable {
@@ -187,4 +188,8 @@ public class RemoteServiceRegistryImpl implements Serializable {
return buf.toString();
}
+ public IRemoteServiceID createRemoteServiceID(long serviceid) {
+ return (IRemoteServiceID) IDFactory.getDefault().createID(IDFactory.getDefault().getNamespaceByName(RemoteServiceNamespace.NAME), new Object[] {containerID, new Long(serviceid)});
+ }
+
}

Back to the top