Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkuppe2009-03-10 16:04:45 +0000
committermkuppe2009-03-10 16:04:45 +0000
commit87e00c9bde19d093f59773d98e8d303d18b57075 (patch)
tree539de2422361643f1400aa6548a6cca833007390 /providers
parentbc9f3b6ef918d6b22de79bca1f7145d22abd6270 (diff)
downloadorg.eclipse.ecf-87e00c9bde19d093f59773d98e8d303d18b57075.tar.gz
org.eclipse.ecf-87e00c9bde19d093f59773d98e8d303d18b57075.tar.xz
org.eclipse.ecf-87e00c9bde19d093f59773d98e8d303d18b57075.zip
NEW - bug 266723: [Discovery] specify how clients can determine service uniqueness
https://bugs.eclipse.org/bugs/show_bug.cgi?id=266723
Diffstat (limited to 'providers')
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.jslp/META-INF/MANIFEST.MF2
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/JSLPDiscoveryJob.java3
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/ServiceURLAdapter.java18
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/container/ContainerInstantiator.java2
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/container/JSLPDiscoveryContainer.java13
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/container/JSLPServiceInfo.java36
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/identity/JSLPNamespace.java44
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/identity/JSLPServiceID.java6
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/identity/JSLPServiceTypeID.java2
9 files changed, 68 insertions, 58 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.jslp/META-INF/MANIFEST.MF b/providers/bundles/org.eclipse.ecf.provider.jslp/META-INF/MANIFEST.MF
index 32160b303..4c6d9a7fb 100644
--- a/providers/bundles/org.eclipse.ecf.provider.jslp/META-INF/MANIFEST.MF
+++ b/providers/bundles/org.eclipse.ecf.provider.jslp/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.ecf.provider.jslp;singleton:=true
-Bundle-Version: 2.2.0.qualifier
+Bundle-Version: 3.0.0.qualifier
Bundle-Activator: org.eclipse.ecf.internal.provider.jslp.Activator
Bundle-Vendor: %providerName
Bundle-Localization: plugin
diff --git a/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/JSLPDiscoveryJob.java b/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/JSLPDiscoveryJob.java
index 36db0f98e..fde7948fc 100644
--- a/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/JSLPDiscoveryJob.java
+++ b/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/JSLPDiscoveryJob.java
@@ -50,7 +50,8 @@ public final class JSLPDiscoveryJob extends Job {
removedServices.remove(url);
} else { // we don't know the service, so we need to create the
final ServicePropertiesAdapter spa = new ServicePropertiesAdapter((List) entry.getValue());
- final IServiceInfo serviceInfo = new JSLPServiceInfo(new ServiceURLAdapter(url, spa.getServiceName()), spa.getPriority(), spa.getWeight(), spa);
+ final String serviceName = spa.getServiceName() == null ? url.toString() : spa.getServiceName();
+ final IServiceInfo serviceInfo = new JSLPServiceInfo(serviceName, new ServiceURLAdapter(url), spa.getPriority(), spa.getWeight(), spa);
services.put(url, serviceInfo);
discoveryContainer.fireServiceTypeDiscovered(serviceInfo.getServiceID().getServiceTypeID());
discoveryContainer.fireServiceDiscovered(serviceInfo);
diff --git a/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/ServiceURLAdapter.java b/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/ServiceURLAdapter.java
index a773393c8..ecc31578c 100644
--- a/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/ServiceURLAdapter.java
+++ b/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/ServiceURLAdapter.java
@@ -15,7 +15,7 @@ import java.net.URI;
import org.eclipse.core.runtime.Assert;
import org.eclipse.ecf.core.identity.IDFactory;
import org.eclipse.ecf.core.identity.Namespace;
-import org.eclipse.ecf.discovery.identity.IServiceID;
+import org.eclipse.ecf.discovery.identity.IServiceTypeID;
import org.eclipse.ecf.provider.jslp.identity.JSLPNamespace;
/**
@@ -24,16 +24,16 @@ import org.eclipse.ecf.provider.jslp.identity.JSLPNamespace;
public class ServiceURLAdapter {
private URI uri;
- private IServiceID serviceID;
+ private IServiceTypeID serviceID;
- public ServiceURLAdapter(final ServiceURL aServiceURL, final String aServiceName) {
- this(aServiceURL, aServiceName, new String[0]);
+ public ServiceURLAdapter(final ServiceURL aServiceURL) {
+ this(aServiceURL, new String[0]);
}
- public ServiceURLAdapter(final ServiceURL aServiceURL, final String aServiceName, final String[] scopes) {
+ public ServiceURLAdapter(final ServiceURL aServiceURL, final String[] scopes) {
Assert.isNotNull(aServiceURL);
Assert.isNotNull(scopes);
- setIServiceID(aServiceURL, aServiceName, scopes);
+ setIServiceTypeID(aServiceURL, scopes);
setURI(aServiceURL);
}
@@ -57,9 +57,9 @@ public class ServiceURLAdapter {
uri = URI.create(buf.toString());
}
- private void setIServiceID(final ServiceURL aServiceURL, final String aServiceName, final String[] scopes) {
+ private void setIServiceTypeID(final ServiceURL aServiceURL, final String[] scopes) {
final Namespace namespace = IDFactory.getDefault().getNamespaceByName(JSLPNamespace.NAME);
- serviceID = (IServiceID) namespace.createInstance(new Object[] {aServiceURL, aServiceName, scopes});
+ serviceID = (IServiceTypeID) namespace.createInstance(new Object[] {aServiceURL, scopes});
}
/**
@@ -72,7 +72,7 @@ public class ServiceURLAdapter {
/**
* @return IServiceID
*/
- public IServiceID getIServiceID() {
+ public IServiceTypeID getIServiceTypeID() {
return serviceID;
}
}
diff --git a/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/container/ContainerInstantiator.java b/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/container/ContainerInstantiator.java
index 7ee5da77a..811f6bfda 100644
--- a/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/container/ContainerInstantiator.java
+++ b/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/container/ContainerInstantiator.java
@@ -54,7 +54,7 @@ public class ContainerInstantiator implements IContainerInstantiator {
}
/**
- * @since 2.2
+ * @since 3.0
* @see org.eclipse.ecf.core.provider.IContainerInstantiator#getSupportedIntents(org.eclipse.ecf.core.ContainerTypeDescription)
*/
public String[] getSupportedIntents(final ContainerTypeDescription description) {
diff --git a/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/container/JSLPDiscoveryContainer.java b/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/container/JSLPDiscoveryContainer.java
index 7f4e55065..2473908f8 100644
--- a/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/container/JSLPDiscoveryContainer.java
+++ b/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/container/JSLPDiscoveryContainer.java
@@ -22,8 +22,7 @@ import org.eclipse.ecf.core.security.IConnectContext;
import org.eclipse.ecf.core.util.ECFRuntimeException;
import org.eclipse.ecf.core.util.Trace;
import org.eclipse.ecf.discovery.*;
-import org.eclipse.ecf.discovery.identity.IServiceID;
-import org.eclipse.ecf.discovery.identity.IServiceTypeID;
+import org.eclipse.ecf.discovery.identity.*;
import org.eclipse.ecf.discovery.service.IDiscoveryService;
import org.eclipse.ecf.internal.provider.jslp.*;
import org.eclipse.ecf.provider.jslp.identity.*;
@@ -138,8 +137,8 @@ public class JSLPDiscoveryContainer extends AbstractDiscoveryContainerAdapter im
List aList = Activator.getDefault().getLocator().getServiceURLs((String) null, null);
for (Iterator itr = aList.iterator(); itr.hasNext();) {
ServiceURL serviceURL = (ServiceURL) itr.next();
- IServiceID serviceId = (IServiceID) getConnectNamespace().createInstance(new Object[] {serviceURL, "", new String[] {}}); //$NON-NLS-1$
- result.add(serviceId.getServiceTypeID());
+ IServiceTypeID serviceTypeId = (IServiceTypeID) getConnectNamespace().createInstance(new Object[] {serviceURL, new String[] {}});
+ result.add(serviceTypeId);
}
} catch (ServiceLocationException e) {
Trace.catching(Activator.PLUGIN_ID, JSLPDebugOptions.EXCEPTIONS_CATCHING, this.getClass(), "getServiceTypes(int)", e); //$NON-NLS-1$
@@ -167,8 +166,7 @@ public class JSLPDiscoveryContainer extends AbstractDiscoveryContainerAdapter im
public IServiceInfo[] getServices(IServiceTypeID type) {
Assert.isNotNull(type);
try {
- JSLPServiceID sid = (JSLPServiceID) IDFactory.getDefault().createID(getConnectNamespace(), new Object[] {type, null});
- JSLPServiceTypeID stid = (JSLPServiceTypeID) sid.getServiceTypeID();
+ JSLPServiceTypeID stid = (JSLPServiceTypeID) ServiceIDFactory.getDefault().createServiceTypeID(getConnectNamespace(), type);
return convertToIServiceInfo(Activator.getDefault().getLocator().getServiceURLs(stid.getServiceType(), Arrays.asList(stid.getScopes())), type.getScopes());
} catch (IDCreateException e) {
Trace.catching(Activator.PLUGIN_ID, JSLPDebugOptions.EXCEPTIONS_CATCHING, this.getClass(), "getServices(IServiceTypeID)", e); //$NON-NLS-1$
@@ -227,7 +225,8 @@ public class JSLPDiscoveryContainer extends AbstractDiscoveryContainerAdapter im
Map.Entry entry = (Entry) itr.next();
ServiceURL url = (ServiceURL) entry.getKey();
ServicePropertiesAdapter spa = new ServicePropertiesAdapter((List) entry.getValue());
- IServiceInfo serviceInfo = new JSLPServiceInfo(new ServiceURLAdapter(url, spa.getServiceName(), scopes), spa.getPriority(), spa.getWeight(), spa);
+ String serviceName = spa.getServiceName() == null ? url.toString() : spa.getServiceName();
+ IServiceInfo serviceInfo = new JSLPServiceInfo(serviceName, new ServiceURLAdapter(url, scopes), spa.getPriority(), spa.getWeight(), spa);
tmp.add(serviceInfo);
}
return (IServiceInfo[]) tmp.toArray(new IServiceInfo[tmp.size()]);
diff --git a/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/container/JSLPServiceInfo.java b/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/container/JSLPServiceInfo.java
index 4f4c65dc8..374ef3c95 100644
--- a/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/container/JSLPServiceInfo.java
+++ b/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/container/JSLPServiceInfo.java
@@ -25,24 +25,32 @@ public class JSLPServiceInfo extends ServiceInfo implements IServiceInfo {
private static final long serialVersionUID = 6828789192986625259L;
- public JSLPServiceInfo(final URI anURI, final IServiceID serviceID, final int priority, final int weight, final IServiceProperties props) {
- super(anURI, serviceID, priority, weight, props);
+// public JSLPServiceInfo(final URI anURI, final IServiceID serviceID, final int priority, final int weight, final IServiceProperties props) {
+// super(anURI, serviceID, priority, weight, props);
+// }
+//
+// /**
+// * @param serviceID
+// * @deprecated
+// */
+// public JSLPServiceInfo(final IServiceID serviceID) {
+// super(null, serviceID, DEFAULT_PRIORITY, DEFAULT_WEIGHT, new ServiceProperties());
+// }
+//
+ public JSLPServiceInfo(final IServiceInfo aSI) throws IDCreateException {
+ super(aSI.getServiceID().getLocation(), aSI.getServiceName(), ServiceIDFactory.getDefault().createServiceTypeID(IDFactory.getDefault().getNamespaceByName(JSLPNamespace.NAME), aSI.getServiceID().getServiceTypeID()), aSI.getPriority(), aSI.getWeight(), aSI.getServiceProperties());
}
/**
- * @param serviceID
- * @deprecated
+ * @param aServiceName
+ * @param anAdapter
+ * @param priority
+ * @param weight
+ * @param aServicePropertiesAdapter
+ * @since 3.0
*/
- public JSLPServiceInfo(final IServiceID serviceID) {
- super(null, serviceID, DEFAULT_PRIORITY, DEFAULT_WEIGHT, new ServiceProperties());
- }
-
- public JSLPServiceInfo(final IServiceInfo aSI) throws IDCreateException {
- this(aSI.getLocation(), ServiceIDFactory.getDefault().createServiceID(IDFactory.getDefault().getNamespaceByName(JSLPNamespace.NAME), aSI.getServiceID().getServiceTypeID(), aSI.getServiceID().getServiceName()), aSI.getPriority(), aSI.getWeight(), aSI.getServiceProperties());
- }
-
- public JSLPServiceInfo(final ServiceURLAdapter anAdapter, final int priority, final int weight, final ServicePropertiesAdapter aServicePropertiesAdapter) {
- this(anAdapter.getURI(), anAdapter.getIServiceID(), priority, weight, aServicePropertiesAdapter.toServiceProperties());
+ public JSLPServiceInfo(final String aServiceName, final ServiceURLAdapter anAdapter, final int priority, final int weight, final ServicePropertiesAdapter aServicePropertiesAdapter) {
+ super(anAdapter.getURI(), aServiceName, anAdapter.getIServiceTypeID(), priority, weight, aServicePropertiesAdapter.toServiceProperties());
}
public ServiceURL getServiceURL() throws ServiceLocationException {
diff --git a/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/identity/JSLPNamespace.java b/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/identity/JSLPNamespace.java
index 044bbb68e..e2f8fd99b 100644
--- a/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/identity/JSLPNamespace.java
+++ b/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/identity/JSLPNamespace.java
@@ -12,6 +12,7 @@ package org.eclipse.ecf.provider.jslp.identity;
import ch.ethz.iks.slp.ServiceType;
import ch.ethz.iks.slp.ServiceURL;
+import java.net.URI;
import org.eclipse.ecf.core.identity.*;
import org.eclipse.ecf.discovery.identity.*;
import org.eclipse.ecf.internal.provider.jslp.Messages;
@@ -28,7 +29,7 @@ public class JSLPNamespace extends Namespace {
*/
public ID createInstance(Object[] parameters) {
// error case
- if (parameters == null || parameters.length < 1 || parameters.length > 3) {
+ if (parameters == null || parameters.length < 1 || parameters.length > 2) {
throw new IDCreateException(Messages.JSLPNamespace_2);
// error case
@@ -36,18 +37,19 @@ public class JSLPNamespace extends Namespace {
throw new IDCreateException(Messages.JSLPNamespace_3);
// create by jSLP ServiceURL
- } else if (parameters[0] instanceof ServiceURL) {
+ } else if (parameters.length == 2 && parameters[0] instanceof ServiceURL) {
final ServiceURL anURL = (ServiceURL) parameters[0];
- final IServiceTypeID stid = new JSLPServiceTypeID(this, anURL, (String[]) parameters[2]);
- final String serviceName = (String) (parameters[1] != null ? parameters[1] : anURL.getHost());
- return new JSLPServiceID(this, stid, serviceName);
+ final String[] scopes = (String[]) parameters[1];
+ return new JSLPServiceTypeID(this, anURL, scopes);
+ // final String serviceName = (String) (parameters[1] != null ? parameters[1] : anURL.getHost());
+ // return null /*new JSLPServiceID(this, stid, serviceName)*/;
// conversion call where conversion isn't necessary
- } else if (parameters[0] instanceof JSLPServiceID) {
+ } else if (parameters.length == 1 && parameters[0] instanceof JSLPServiceID) {
return (ID) parameters[0];
// convert from IServiceID to IServiceTypeID, String
- } else if (parameters[0] instanceof IServiceID && parameters.length == 1) {
+ } else if (parameters.length == 1 && parameters[0] instanceof IServiceID) {
final IServiceID anId = (IServiceID) parameters[0];
final Object[] newParams = new Object[2];
newParams[0] = anId.getServiceTypeID();
@@ -61,28 +63,26 @@ public class JSLPNamespace extends Namespace {
return createInstance(parameters);
// create by jSLP ServiceType
- } else if (parameters[0] instanceof ServiceType) {
- IServiceTypeID stid = new JSLPServiceTypeID(this, (ServiceType) parameters[0]);
- return new JSLPServiceID(this, stid, (String) parameters[1]);
+ } else if (parameters.length == 1 && parameters[0] instanceof ServiceType) {
+ return new JSLPServiceTypeID(this, (ServiceType) parameters[0]);
+ //return new JSLPServiceID(this, stid, (String) parameters[1]);
// create by jSLP ServiceType String representation (from external)
} else if (parameters[0] instanceof String && ((String) parameters[0]).startsWith("service:")) { //$NON-NLS-1$
parameters[0] = new ServiceType((String) parameters[0]);
return createInstance(parameters);
- // create by ECF discovery generic String representation
- } else if (parameters[0] instanceof String && ((String) parameters[0]).startsWith("_")) { //$NON-NLS-1$
+ // create IServiceID by ECF discovery generic String representation
+ } else if (parameters.length == 2 && parameters[0] instanceof String && ((String) parameters[0]).startsWith("_")) { //$NON-NLS-1$
final String type = (String) parameters[0];
- final String name = (String) parameters[1];
- final IServiceTypeID stid = new JSLPServiceTypeID(this, new ServiceTypeID(this, type));
- return new JSLPServiceID(this, stid, name);
-
- // create by "jslp:..."
- } else if (parameters[0] instanceof String && ((String) parameters[0]).startsWith(getScheme() + Namespace.SCHEME_SEPARATOR)) {
- final String str = (String) parameters[0];
- final int index = str.indexOf(Namespace.SCHEME_SEPARATOR);
- parameters[0] = str.substring(index + 1);
- return createInstance(parameters);
+ final URI anURI = (URI) parameters[1];
+ final JSLPServiceTypeID serviceType = new JSLPServiceTypeID(this, new ServiceTypeID(this, type));
+ return new JSLPServiceID(this, serviceType, anURI);
+
+ // create IServiceTypeID by ECF discovery generic ServiceType
+ } else if (parameters.length == 1 && parameters[0] instanceof String && ((String) parameters[0]).startsWith("_")) { //$NON-NLS-1$
+ final String type = (String) parameters[0];
+ return new JSLPServiceTypeID(this, new ServiceTypeID(this, type));
// error case second parameter not a String
} else if (parameters.length == 2 && parameters[1] != null && !(parameters[1] instanceof String)) {
diff --git a/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/identity/JSLPServiceID.java b/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/identity/JSLPServiceID.java
index 530692007..4ffce8bef 100644
--- a/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/identity/JSLPServiceID.java
+++ b/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/identity/JSLPServiceID.java
@@ -10,6 +10,8 @@
******************************************************************************/
package org.eclipse.ecf.provider.jslp.identity;
+import java.net.URI;
+
import org.eclipse.ecf.core.identity.Namespace;
import org.eclipse.ecf.discovery.identity.IServiceTypeID;
import org.eclipse.ecf.discovery.identity.ServiceID;
@@ -17,7 +19,7 @@ import org.eclipse.ecf.discovery.identity.ServiceID;
public class JSLPServiceID extends ServiceID {
private static final long serialVersionUID = -8211896244921087422L;
- JSLPServiceID(Namespace namespace, IServiceTypeID type, String name) {
- super(namespace, type, name);
+ JSLPServiceID(Namespace namespace, IServiceTypeID type, URI anURI) {
+ super(namespace, type, anURI);
}
}
diff --git a/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/identity/JSLPServiceTypeID.java b/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/identity/JSLPServiceTypeID.java
index ba8eea314..d26805839 100644
--- a/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/identity/JSLPServiceTypeID.java
+++ b/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/identity/JSLPServiceTypeID.java
@@ -81,7 +81,7 @@ public class JSLPServiceTypeID extends ServiceTypeID {
for (int i = 0; i < services.length; i++) {
buf.append(services[i]);
// #228876
- if (!namingAuthority.equalsIgnoreCase(JSLP_DEFAULT_NA) && i == 1) {
+ if (!namingAuthority.equalsIgnoreCase(JSLP_DEFAULT_NA) && i == 0) {
buf.append('.');
buf.append(namingAuthority);
}

Back to the top