Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2007-09-05 23:24:14 +0000
committerslewis2007-09-05 23:24:14 +0000
commitd1b2c2da8aa1a826e95889fe732ac0c244f40fbd (patch)
tree46b564728fe741182aee5d645258194cb95883db /framework/bundles/org.eclipse.ecf.discovery
parentdd3a9dad46c2bbc2f65c7d47253e7c55c81088c1 (diff)
downloadorg.eclipse.ecf-d1b2c2da8aa1a826e95889fe732ac0c244f40fbd.tar.gz
org.eclipse.ecf-d1b2c2da8aa1a826e95889fe732ac0c244f40fbd.tar.xz
org.eclipse.ecf-d1b2c2da8aa1a826e95889fe732ac0c244f40fbd.zip
Changes to discovery API and implementations as per bug 200791 and bug 202036
Diffstat (limited to 'framework/bundles/org.eclipse.ecf.discovery')
-rw-r--r--framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/IDiscoveryContainerAdapter.java61
-rw-r--r--framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/ServiceContainerEvent.java4
-rw-r--r--framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/ServiceInfo.java30
-rw-r--r--framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/ServiceProperties.java14
-rw-r--r--framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/identity/IServiceID.java9
-rw-r--r--framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/identity/IServiceIDFactory.java66
-rw-r--r--framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/identity/IServiceTypeID.java66
-rw-r--r--framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/identity/ServiceID.java36
-rw-r--r--framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/identity/ServiceIDFactory.java56
-rw-r--r--framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/identity/ServiceTypeID.java127
-rw-r--r--framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/internal/discovery/Messages.java36
-rw-r--r--framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/internal/discovery/messages.properties1
12 files changed, 405 insertions, 101 deletions
diff --git a/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/IDiscoveryContainerAdapter.java b/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/IDiscoveryContainerAdapter.java
index c8ea5f3cc..b80aaa8e6 100644
--- a/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/IDiscoveryContainerAdapter.java
+++ b/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/IDiscoveryContainerAdapter.java
@@ -10,8 +10,11 @@
package org.eclipse.ecf.discovery;
import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.ecf.core.identity.Namespace;
import org.eclipse.ecf.core.util.ECFException;
import org.eclipse.ecf.discovery.identity.IServiceID;
+import org.eclipse.ecf.discovery.identity.IServiceTypeID;
+import org.eclipse.ecf.discovery.identity.ServiceIDFactory;
/**
* Entry point discovery container adapter. This interface exposes the ability
@@ -28,6 +31,25 @@ import org.eclipse.ecf.discovery.identity.IServiceID;
*
*/
public interface IDiscoveryContainerAdapter extends IAdaptable {
+
+ /**
+ * Add a service type listener. The given listener will have its method
+ * called when a service type is discovered.
+ *
+ * @param listener
+ * the listener to be notified. Must not be <code>null</code>.
+ */
+ public void addServiceTypeListener(IServiceTypeListener listener);
+
+ /**
+ * Remove a service type listener. Remove the type listener.
+ *
+ * @param listener
+ * IServiceTypeListener to be removed. Must not be
+ * <code>null</code>.
+ */
+ public void removeServiceTypeListener(IServiceTypeListener listener);
+
/**
* Add a service listener. The given listener will have its method called
* when a service with a type matching that specified by the first parameter
@@ -35,11 +57,15 @@ public interface IDiscoveryContainerAdapter extends IAdaptable {
*
* @param type
* String type to listen for. Must not be <code>null</code>.
+ * Must be formatted accroding to this specific IDiscoveryContainer
* @param listener
* IServiceListener to be notified. Must not be <code>null</code>.
+ * @deprecated Use addServiceListener(IServiceTypeID, IServiceListener) instead.
*/
public void addServiceListener(String type, IServiceListener listener);
+ public void addServiceListener(IServiceTypeID type, IServiceListener listener);
+
/**
* Remove a service listener. Remove the listener associated with the type
* specified by the first parameter.
@@ -47,29 +73,15 @@ public interface IDiscoveryContainerAdapter extends IAdaptable {
* @param type
* String of the desired type to remove the listener. Must not be
* <code>null</code>.
+ * Must be formatted accroding to this specific IDiscoveryContainer
* @param listener
* IServiceListener listener to be removed. Must not be
* <code>null</code>.
+ * @deprecated Use removeServiceListener(IServiceTypeID, IServiceListener) instead.
*/
public void removeServiceListener(String type, IServiceListener listener);
- /**
- * Add a service type listener. The given listener will have its method
- * called when a service type is discovered.
- *
- * @param listener
- * the listener to be notified. Must not be <code>null</code>.
- */
- public void addServiceTypeListener(IServiceTypeListener listener);
-
- /**
- * Remove a service type listener. Remove the type listener.
- *
- * @param listener
- * IServiceTypeListener to be removed. Must not be
- * <code>null</code>.
- */
- public void removeServiceTypeListener(IServiceTypeListener listener);
+ public void removeServiceListener(IServiceTypeID type, IServiceListener listener);
/**
* Register the given service type. This publishes the given service type to
@@ -78,9 +90,13 @@ public interface IDiscoveryContainerAdapter extends IAdaptable {
* @param serviceType
* String of the serviceType to be published. Must not be
* <code>null</code>.
+ * Must be formatted accroding to this specific IDiscoveryContainer
+ * @deprecated Use registerServiceType(IServiceTypeID) instead.
*/
public void registerServiceType(String serviceType);
+ public void registerServiceType(IServiceTypeID type);
+
/**
* Register the given service. This publishes the service defined by the
* first parameter to the underlying publishing mechanism
@@ -141,4 +157,15 @@ public interface IDiscoveryContainerAdapter extends IAdaptable {
* Will not be <code>null</code>. May be of length 0.
*/
public IServiceInfo[] getServices(String type);
+
+ /**
+ * Get a namespace for services associated with this discovery container adapter. The given namespace
+ * may be used via {@link ServiceIDFactory} to create IServiceIDs rather than simple IDs. For example:
+ * <pre>
+ * IServiceID serviceID = ServiceIDFactory.getDefault().createServiceID(container.getServicesNamespace(),serviceType,serviceName);
+ * </pre>
+ *
+ * @return Namespace for creating service IDs. Will not be <code>null</code>.
+ */
+ public Namespace getServicesNamespace();
}
diff --git a/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/ServiceContainerEvent.java b/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/ServiceContainerEvent.java
index 789c96b2d..b980615c0 100644
--- a/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/ServiceContainerEvent.java
+++ b/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/ServiceContainerEvent.java
@@ -17,7 +17,7 @@ import org.eclipse.ecf.core.identity.ID;
*/
public class ServiceContainerEvent implements IServiceEvent {
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = -2704247495748252242L;
protected IServiceInfo info;
@@ -46,7 +46,7 @@ public class ServiceContainerEvent implements IServiceEvent {
* @see java.lang.Object#toString()
*/
public String toString() {
- StringBuffer buf = new StringBuffer("ServiceContainerEvent["); //$NON-NLS-1$
+ final StringBuffer buf = new StringBuffer("ServiceContainerEvent["); //$NON-NLS-1$
buf.append("serviceinfo=").append(info).append("]"); //$NON-NLS-1$ //$NON-NLS-2$
return buf.toString();
}
diff --git a/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/ServiceInfo.java b/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/ServiceInfo.java
index 45edc638a..bb35fc597 100644
--- a/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/ServiceInfo.java
+++ b/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/ServiceInfo.java
@@ -13,7 +13,6 @@ import java.io.Serializable;
import java.net.InetAddress;
import org.eclipse.ecf.discovery.identity.IServiceID;
-import org.eclipse.ecf.discovery.identity.ServiceID;
/**
* Base implementation of {@link IServiceInfo}. Subclasses
@@ -21,32 +20,21 @@ import org.eclipse.ecf.discovery.identity.ServiceID;
*/
public class ServiceInfo implements IServiceInfo, Serializable {
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = -5651115550295457142L;
- InetAddress addr = null;
+ protected InetAddress addr = null;
- IServiceID serviceID;
+ protected IServiceID serviceID;
- int port;
+ protected int port;
- int priority;
+ protected int priority;
- int weight;
+ protected int weight;
- IServiceProperties properties;
+ protected IServiceProperties properties;
- public ServiceInfo(InetAddress address, String type, int port,
- int priority, int weight, IServiceProperties props) {
- this.addr = address;
- this.serviceID = new ServiceID(type, null);
- this.port = port;
- this.priority = priority;
- this.weight = weight;
- this.properties = props;
- }
-
- public ServiceInfo(InetAddress address, IServiceID serviceID, int port,
- int priority, int weight, IServiceProperties props) {
+ public ServiceInfo(InetAddress address, IServiceID serviceID, int port, int priority, int weight, IServiceProperties props) {
this.addr = address;
this.serviceID = serviceID;
this.port = port;
@@ -112,7 +100,7 @@ public class ServiceInfo implements IServiceInfo, Serializable {
* @see java.lang.Object#toString()
*/
public String toString() {
- StringBuffer buf = new StringBuffer("ServiceInfo["); //$NON-NLS-1$
+ final StringBuffer buf = new StringBuffer("ServiceInfo["); //$NON-NLS-1$
buf.append("addr=").append(addr).append(";id=").append(serviceID) //$NON-NLS-1$ //$NON-NLS-2$
.append(";port=").append(port).append(";priority=").append( //$NON-NLS-1$ //$NON-NLS-2$
priority).append(";weight=").append(weight).append( //$NON-NLS-1$
diff --git a/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/ServiceProperties.java b/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/ServiceProperties.java
index d7e305df8..b0939eec7 100644
--- a/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/ServiceProperties.java
+++ b/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/ServiceProperties.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004 Composent, Inc. and others. All rights reserved. This
+ * Copyright (c) 2007 Composent, Inc. 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
@@ -17,7 +17,7 @@ import java.util.Properties;
*/
public class ServiceProperties implements IServiceProperties {
- Properties props = new Properties();
+ private final Properties props;
public ServiceProperties() {
super();
@@ -26,7 +26,7 @@ public class ServiceProperties implements IServiceProperties {
public ServiceProperties(Properties props) {
super();
- this.props = (props == null)?new Properties():props;
+ this.props = (props == null) ? new Properties() : props;
}
/*
@@ -44,7 +44,7 @@ public class ServiceProperties implements IServiceProperties {
* @see org.eclipse.ecf.discovery.IServiceProperties#getPropertyString(java.lang.String)
*/
public String getPropertyString(String name) {
- Object val = props.get(name);
+ final Object val = props.get(name);
if (val instanceof String) {
return (String) val;
}
@@ -57,7 +57,7 @@ public class ServiceProperties implements IServiceProperties {
* @see org.eclipse.ecf.discovery.IServiceProperties#getPropertyBytes(java.lang.String)
*/
public byte[] getPropertyBytes(String name) {
- Object val = props.get(name);
+ final Object val = props.get(name);
if (val instanceof byte[]) {
return (byte[]) val;
}
@@ -84,13 +84,13 @@ public class ServiceProperties implements IServiceProperties {
* @see org.eclipse.ecf.discovery.IServiceProperties#setPropertyBytes(java.lang.String, byte[])
*/
public Object setPropertyBytes(String name, byte[] value) {
- return props.put(name,value);
+ return props.put(name, value);
}
/* (non-Javadoc)
* @see org.eclipse.ecf.discovery.IServiceProperties#setPropertyString(java.lang.String, java.lang.String)
*/
public Object setPropertyString(String name, String value) {
- return props.put(name,value);
+ return props.put(name, value);
}
}
diff --git a/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/identity/IServiceID.java b/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/identity/IServiceID.java
index 25bbfc84f..6c326bb5d 100644
--- a/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/identity/IServiceID.java
+++ b/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/identity/IServiceID.java
@@ -20,9 +20,18 @@ public interface IServiceID extends ID {
/**
* Get service type for this ID.
+ * Delegates to getServiceTypeID().getName()
* @return String service type. Will not be <code>null</code>.
+ * @deprecated Use getServiceTypeID() instead!
*/
public String getServiceType();
+
+ /**
+ * Get service type ID for this ID.
+ * @return IServiceTypeID. Will not be <code>null</code>.
+ */
+ public IServiceTypeID getServiceTypeID();
+
/**
* Get service name for this ID.
*
diff --git a/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/identity/IServiceIDFactory.java b/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/identity/IServiceIDFactory.java
new file mode 100644
index 000000000..538a21de7
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/identity/IServiceIDFactory.java
@@ -0,0 +1,66 @@
+/****************************************************************************
+ * Copyright (c) 2007 Composent, Inc. 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:
+ * Composent, Inc. - initial API and implementation
+ *****************************************************************************/
+
+package org.eclipse.ecf.discovery.identity;
+
+import org.eclipse.ecf.core.identity.IDCreateException;
+import org.eclipse.ecf.core.identity.Namespace;
+
+/**
+ * ServiceID factory contract.
+ *
+ * @see ServiceIDFactory
+ */
+public interface IServiceIDFactory {
+
+ /**
+ * Create an IServiceID. Creates an immutable IServiceID with a non-<code>null</code> {@link IServiceTypeID}
+ * and a potentially <code>null</code> service name.
+ * @param namespace the Namespace instance to create the service ID with. Must not be <code>null</code>.
+ * @param serviceType the service type to create the service ID with. Must not be <code>null</code>.
+ * @param serviceName the service name for the service ID. May be <code>null</code>.
+ * @return IServiceID created. Will not be <code>null</code>.
+ * @throws IDCreateException if some problem creating the new IServiceID.
+ */
+ public IServiceID createServiceID(Namespace namespace, IServiceTypeID serviceType, String serviceName) throws IDCreateException;
+
+ /**
+ * Create an IServiceID. Creates an immutable IServiceID with a non-<code>null</code> {@link IServiceTypeID}
+ * and a potentially <code>null</code> service name.
+ * @param namespace the Namespace instance to create the service ID with. Must not be <code>null</code>.
+ * @param serviceType the service type to create the service ID with. Must not be <code>null</code>.
+ * @return IServiceID created. Will not be <code>null</code>.
+ * @throws IDCreateException if some problem creating the new IServiceID.
+ */
+ public IServiceID createServiceID(Namespace namespace, IServiceTypeID serviceType) throws IDCreateException;
+
+ /**
+ * Create an IServiceID. Creates an immutable IServiceID with a non-<code>null</code> {@link IServiceTypeID}
+ * and a potentially <code>null</code> service name.
+ * @param namespace the Namespace instance to create the service ID with. Must not be <code>null</code>.
+ * @param serviceType the service type to create the service ID with. Must not be <code>null</code>.
+ * @param serviceName the service name for the service ID. May be <code>null</code>.
+ * @return IServiceID created. Will not be <code>null</code>.
+ * @throws IDCreateException if some problem creating the new IServiceID.
+ */
+ public IServiceID createServiceID(Namespace namespace, String serviceType, String serviceName) throws IDCreateException;
+
+ /**
+ * Create an IServiceID. Creates an immutable IServiceID with a non-<code>null</code> {@link IServiceTypeID}
+ * and a potentially <code>null</code> service name.
+ * @param namespace the Namespace instance to create the service ID with. Must not be <code>null</code>.
+ * @param serviceType the service type to create the service ID with. Must not be <code>null</code>.
+ * @return IServiceID created. Will not be <code>null</code>.
+ * @throws IDCreateException if some problem creating the new IServiceID.
+ */
+ public IServiceID createServiceID(Namespace namespace, String serviceType) throws IDCreateException;
+
+}
diff --git a/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/identity/IServiceTypeID.java b/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/identity/IServiceTypeID.java
new file mode 100644
index 000000000..6d5d3c1a3
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/identity/IServiceTypeID.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Versant Corp.
+ * 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:
+ * Markus Kuppe (mkuppe <at> versant <dot> com) - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.discovery.identity;
+
+import org.eclipse.ecf.core.identity.ID;
+
+/**
+ * Service type ID contract.
+ *
+ */
+public interface IServiceTypeID extends ID {
+ /*
+ * jSLP => getServices()[0]:getServices()[1][.getNamingAuthoriy():getService()[n]
+ * jmDNS => _getServices()[0]._getServices()[n]._getProtocol()[0]._getScopes()[0]
+ */
+ /*
+ * jSLP => naming authority (IANA or custom)
+ * jmDNS => IANA
+ */
+ /**
+ * @return String Naming Authority for this ServiceType. May be <code>null</code>.
+ */
+ public String getNamingAuthority();
+
+ /*
+ * jSLP => unknown (0) only known at the service consumer level
+ * jmDNS => protocols (udp/ip or tcp/ip or both) (1)
+ */
+ /**
+ * @return String[] of protocols supported. Will not be <code>null</code>, but may
+ * be empty array.
+ */
+ public String[] getProtocols();
+
+ /*
+ * jSLP => Scopes (n)
+ * jmDNS => domain (1)
+ */
+ /**
+ * @return The scopes in which this Service is registered. Will not be <code>null</code>, but may
+ * be empty array.
+ */
+ public String[] getScopes();
+
+ /*
+ * jSLP => abstract and concrete types (n)
+ * jmDNS => everything before port (n)
+ */
+
+ /**
+ * @return The name of the Service, if the underlying discovery mechanism
+ * supports naming hierarchies, the hierarchy will be returned
+ * flattened as an array. Will not be <code>null</code>, but may
+ * be empty array.
+ */
+ public String[] getServices();
+
+}
diff --git a/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/identity/ServiceID.java b/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/identity/ServiceID.java
index cf30935ba..48b9e9188 100644
--- a/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/identity/ServiceID.java
+++ b/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/identity/ServiceID.java
@@ -8,9 +8,9 @@
******************************************************************************/
package org.eclipse.ecf.discovery.identity;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.ecf.core.identity.BaseID;
import org.eclipse.ecf.core.identity.Namespace;
-import org.eclipse.ecf.internal.discovery.Messages;
/**
* Service identity type. ServiceIDs are IDs that uniquely identify
@@ -18,30 +18,25 @@ import org.eclipse.ecf.internal.discovery.Messages;
*
*/
public class ServiceID extends BaseID implements IServiceID {
- private static final long serialVersionUID = 1L;
- protected String type;
+ private static final long serialVersionUID = 4362768703249025783L;
+
+ protected IServiceTypeID type;
protected String name;
- protected ServiceID(Namespace namespace, String type, String name) {
+ protected ServiceID(Namespace namespace, IServiceTypeID type, String name) {
super(namespace);
- if (type == null)
- throw new NullPointerException(Messages.getString("ServiceID.ServiceID_Not_Null")); //$NON-NLS-1$
+ Assert.isNotNull(type);
this.type = type;
this.name = name;
}
- public ServiceID(String type, String name) {
- this.name = name;
- this.type = type;
- }
-
protected String getFullyQualifiedName() {
if (name == null)
- return type;
+ return type.getName();
else
- return type + name;
+ return type.getName() + name;
}
/* (non-Javadoc)
@@ -49,8 +44,8 @@ public class ServiceID extends BaseID implements IServiceID {
*/
protected int namespaceCompareTo(BaseID o) {
if (o instanceof ServiceID) {
- ServiceID other = (ServiceID) o;
- String typename = other.getFullyQualifiedName();
+ final ServiceID other = (ServiceID) o;
+ final String typename = other.getFullyQualifiedName();
return getFullyQualifiedName().compareTo(typename);
} else {
return 1;
@@ -64,7 +59,7 @@ public class ServiceID extends BaseID implements IServiceID {
if (o == null)
return false;
if (o instanceof ServiceID) {
- ServiceID other = (ServiceID) o;
+ final ServiceID other = (ServiceID) o;
if (other.getName().equals(getName())) {
return true;
}
@@ -91,6 +86,13 @@ public class ServiceID extends BaseID implements IServiceID {
* @return String service type. Will not be <code>null</code>.
*/
public String getServiceType() {
+ return type.getName();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.discovery.identity.IServiceID#getServiceTypeID()
+ */
+ public IServiceTypeID getServiceTypeID() {
return type;
}
@@ -107,7 +109,7 @@ public class ServiceID extends BaseID implements IServiceID {
* @see java.lang.Object#toString()
*/
public String toString() {
- StringBuffer buf = new StringBuffer("ServiceID["); //$NON-NLS-1$
+ final StringBuffer buf = new StringBuffer("ServiceID["); //$NON-NLS-1$
buf.append("type=").append(type).append(";name=").append(name).append( //$NON-NLS-1$ //$NON-NLS-2$
";full=" + getFullyQualifiedName()).append("]"); //$NON-NLS-1$ //$NON-NLS-2$
return buf.toString();
diff --git a/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/identity/ServiceIDFactory.java b/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/identity/ServiceIDFactory.java
new file mode 100644
index 000000000..36378afe7
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/identity/ServiceIDFactory.java
@@ -0,0 +1,56 @@
+/****************************************************************************
+ * Copyright (c) 2007 Composent, Inc. 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:
+ * Composent, Inc. - initial API and implementation
+ *****************************************************************************/
+
+package org.eclipse.ecf.discovery.identity;
+
+import org.eclipse.ecf.core.identity.IDCreateException;
+import org.eclipse.ecf.core.identity.IDFactory;
+import org.eclipse.ecf.core.identity.Namespace;
+
+/**
+ * ServiceIDFactory implementation.
+ */
+public class ServiceIDFactory implements IServiceIDFactory {
+
+ private static final IServiceIDFactory instance = new ServiceIDFactory();
+
+ public static IServiceIDFactory getDefault() {
+ return instance;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.discovery.identity.IServiceIDFactory#createServiceID(org.eclipse.ecf.core.identity.Namespace, org.eclipse.ecf.discovery.identity.IServiceTypeID, java.lang.String)
+ */
+ public IServiceID createServiceID(Namespace namespace, IServiceTypeID serviceType, String serviceName) throws IDCreateException {
+ return (IServiceID) IDFactory.getDefault().createID(namespace, new Object[] {serviceType, serviceName});
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.discovery.identity.IServiceIDFactory#createServiceID(org.eclipse.ecf.core.identity.Namespace, java.lang.String, java.lang.String)
+ */
+ public IServiceID createServiceID(Namespace namespace, String serviceType, String serviceName) throws IDCreateException {
+ return (IServiceID) IDFactory.getDefault().createID(namespace, new Object[] {serviceType, serviceName});
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.discovery.identity.IServiceIDFactory#createServiceID(org.eclipse.ecf.core.identity.Namespace, java.lang.String)
+ */
+ public IServiceID createServiceID(Namespace namespace, String serviceType) throws IDCreateException {
+ return this.createServiceID(namespace, serviceType, null);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.discovery.identity.IServiceIDFactory#createServiceID(org.eclipse.ecf.core.identity.Namespace, org.eclipse.ecf.discovery.identity.IServiceTypeID)
+ */
+ public IServiceID createServiceID(Namespace namespace, IServiceTypeID serviceType) throws IDCreateException {
+ return this.createServiceID(namespace, serviceType, null);
+ }
+}
diff --git a/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/identity/ServiceTypeID.java b/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/identity/ServiceTypeID.java
new file mode 100644
index 000000000..4e12a86a6
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/identity/ServiceTypeID.java
@@ -0,0 +1,127 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Versant Corp.
+ * 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:
+ * Markus Kuppe (mkuppe <at> versant <dot> com) - initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.ecf.discovery.identity;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.ecf.core.identity.BaseID;
+import org.eclipse.ecf.core.identity.Namespace;
+
+/**
+ * ServiceTypeID base class.
+ */
+public class ServiceTypeID extends BaseID implements IServiceTypeID {
+
+ private static final long serialVersionUID = 2546630451825262145L;
+ protected String type = null;
+ protected String namingAuthority;
+ protected String[] protocols;
+ protected String[] scopes;
+ protected String[] services;
+
+ protected ServiceTypeID(Namespace namespace, String aType) {
+ super(namespace);
+ Assert.isNotNull(aType);
+ type = aType;
+ }
+
+ protected ServiceTypeID(Namespace namespace, String typeName, String[] services, String[] scopes, String[] protocols, String namingAuthority) {
+ this(namespace, typeName);
+ this.services = services;
+ this.scopes = scopes;
+ this.protocols = protocols;
+ this.namingAuthority = namingAuthority;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.core.identity.BaseID#getName()
+ */
+ public String getName() {
+ return type;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.core.identity.BaseID#namespaceCompareTo(org.eclipse.ecf.core.identity.BaseID)
+ */
+ protected int namespaceCompareTo(BaseID o) {
+ if (o instanceof ServiceTypeID) {
+ final ServiceTypeID other = (ServiceTypeID) o;
+ final String typename = other.getName();
+ return getName().compareTo(typename);
+ } else {
+ return 1;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.core.identity.BaseID#namespaceEquals(org.eclipse.ecf.core.identity.BaseID)
+ */
+ protected boolean namespaceEquals(BaseID o) {
+ if (o == null)
+ return false;
+ if (o instanceof ServiceTypeID) {
+ final ServiceTypeID other = (ServiceTypeID) o;
+ if (other.getName().equals(getName())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.core.identity.BaseID#namespaceGetName()
+ */
+ protected String namespaceGetName() {
+ return getName();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.core.identity.BaseID#namespaceHashCode()
+ */
+ protected int namespaceHashCode() {
+ return getName().hashCode();
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ return type;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.discovery.identity.IServiceTypeID#getNamingAuthority()
+ */
+ public String getNamingAuthority() {
+ return namingAuthority;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.discovery.identity.IServiceTypeID#getProtocols()
+ */
+ public String[] getProtocols() {
+ return protocols;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.discovery.identity.IServiceTypeID#getScopes()
+ */
+ public String[] getScopes() {
+ return scopes;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.discovery.identity.IServiceTypeID#getServices()
+ */
+ public String[] getServices() {
+ return services;
+ }
+}
diff --git a/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/internal/discovery/Messages.java b/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/internal/discovery/Messages.java
deleted file mode 100644
index 95970e7fd..000000000
--- a/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/internal/discovery/Messages.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/****************************************************************************
- * Copyright (c) 2004 Composent, Inc. 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:
- * Composent, Inc. - initial API and implementation
- *****************************************************************************/
-
-package org.eclipse.ecf.internal.discovery;
-
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-/**
- *
- */
-public class Messages {
- private static final String BUNDLE_NAME = "org.eclipse.ecf.internal.discovery.messages"; //$NON-NLS-1$
-
- private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
- .getBundle(BUNDLE_NAME);
-
- private Messages() {
- }
-
- public static String getString(String key) {
- try {
- return RESOURCE_BUNDLE.getString(key);
- } catch (MissingResourceException e) {
- return '!' + key + '!';
- }
- }
-}
diff --git a/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/internal/discovery/messages.properties b/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/internal/discovery/messages.properties
deleted file mode 100644
index 24fe465ac..000000000
--- a/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/internal/discovery/messages.properties
+++ /dev/null
@@ -1 +0,0 @@
-ServiceID.ServiceID_Not_Null=ServiceID type cannot be null

Back to the top