diff options
Diffstat (limited to 'framework/bundles/org.eclipse.ecf.discovery')
10 files changed, 187 insertions, 132 deletions
diff --git a/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/AbstractDiscoveryContainerAdapter.java b/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/AbstractDiscoveryContainerAdapter.java index c84bc936d..d67ec89c2 100644 --- a/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/AbstractDiscoveryContainerAdapter.java +++ b/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/AbstractDiscoveryContainerAdapter.java @@ -21,28 +21,25 @@ import org.eclipse.ecf.discovery.identity.IServiceTypeID; import org.eclipse.ecf.internal.discovery.*; import org.eclipse.equinox.concurrent.future.*; -public abstract class AbstractDiscoveryContainerAdapter extends - AbstractContainer implements IDiscoveryLocator, IDiscoveryAdvertiser { +public abstract class AbstractDiscoveryContainerAdapter extends AbstractContainer + implements IDiscoveryLocator, IDiscoveryAdvertiser { /** - * Collection of service listeners i.e. Collection<IServiceListener>. NOTE: - * Access to this collection is synchronized, so subclasses should take this - * into account. + * Collection of service listeners. NOTE: Access to this collection is + * synchronized, so subclasses should take this into account. */ protected final Set allServiceListeners; private DiscoveryContainerConfig config; /** - * Map of service type to collection of service listeners i.e. - * <String,Collection<IServiceListener>>. NOTE: Access to this map is - * synchronized, so subclasses should take this into account. + * Map of service type to collection of service listeners. NOTE: Access to + * this map is synchronized, so subclasses should take this into account. */ protected final Map serviceListeners; protected final String servicesNamespaceName; /** - * Collection of service type listeners i.e. - * Collection<IServiceTypeListener>. NOTE: Access to this collection is + * Collection of service type listeners. NOTE: Access to this collection is * synchronized, so subclasses should take this into account. */ protected final Collection serviceTypeListeners; @@ -55,10 +52,11 @@ public abstract class AbstractDiscoveryContainerAdapter extends /** * @param aNamespaceName + * namespace name * @param aConfig + * discovery container config */ - public AbstractDiscoveryContainerAdapter(String aNamespaceName, - DiscoveryContainerConfig aConfig) { + public AbstractDiscoveryContainerAdapter(String aNamespaceName, DiscoveryContainerConfig aConfig) { servicesNamespaceName = aNamespaceName; Assert.isNotNull(servicesNamespaceName); config = aConfig; @@ -67,10 +65,8 @@ public abstract class AbstractDiscoveryContainerAdapter extends serviceListeners = Collections.synchronizedMap(new HashMap()); allServiceListeners = Collections.synchronizedSet(new HashSet()); - discoveryServiceListener = new DiscoveryServiceListener(this, - IServiceListener.class); - discoveryServiceTypeListener = new DiscoveryServiceListener(this, - IServiceTypeListener.class); + discoveryServiceListener = new DiscoveryServiceListener(this, IServiceListener.class); + discoveryServiceTypeListener = new DiscoveryServiceListener(this, IServiceTypeListener.class); discoveryServiceListenerComparator = new ServiceTypeComparator(); @@ -95,8 +91,7 @@ public abstract class AbstractDiscoveryContainerAdapter extends for (int i = 0; i < services.length; i++) { final IServiceInfo iServiceInfo = services[i]; - aListener.serviceDiscovered(getServiceEvent( - iServiceInfo, getConfig().getID())); + aListener.serviceDiscovered(getServiceEvent(iServiceInfo, getConfig().getID())); } allServiceListeners.add(aListener); return null; @@ -108,6 +103,11 @@ public abstract class AbstractDiscoveryContainerAdapter extends } /** + * @param iServiceInfo + * service info + * @param id + * id + * @return IServiceEvent created service event * @since 5.0 */ protected IServiceEvent getServiceEvent(IServiceInfo iServiceInfo, ID id) { @@ -122,8 +122,7 @@ public abstract class AbstractDiscoveryContainerAdapter extends * (org.eclipse.ecf.discovery.identity.IServiceTypeID, * org.eclipse.ecf.discovery.IServiceListener) */ - public void addServiceListener(final IServiceTypeID aType, - final IServiceListener aListener) { + public void addServiceListener(final IServiceTypeID aType, final IServiceListener aListener) { Assert.isNotNull(aListener); Assert.isNotNull(aType); @@ -135,8 +134,7 @@ public abstract class AbstractDiscoveryContainerAdapter extends for (int i = 0; i < services.length; i++) { final IServiceInfo iServiceInfo = services[i]; - aListener.serviceDiscovered(getServiceEvent( - iServiceInfo, getConfig().getID())); + aListener.serviceDiscovered(getServiceEvent(iServiceInfo, getConfig().getID())); } // Add the listener _after_ explicitly discovering services // to _reduce_ the chance of notifying the listener more @@ -155,8 +153,7 @@ public abstract class AbstractDiscoveryContainerAdapter extends } } - private void addServiceListener0(final IServiceTypeID aType, - final IServiceListener aListener) { + private void addServiceListener0(final IServiceTypeID aType, final IServiceListener aListener) { synchronized (serviceListeners) { // put-if-absent idiom race // condition Collection v = (Collection) serviceListeners.get(aType); @@ -171,9 +168,8 @@ public abstract class AbstractDiscoveryContainerAdapter extends /* * (non-Javadoc) * - * @see - * org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#addServiceTypeListener - * (org.eclipse.ecf.discovery.IServiceTypeListener) + * @see org.eclipse.ecf.discovery.IDiscoveryContainerAdapter# + * addServiceTypeListener (org.eclipse.ecf.discovery.IServiceTypeListener) */ public void addServiceTypeListener(IServiceTypeListener aListener) { Assert.isNotNull(aListener); @@ -210,14 +206,12 @@ public abstract class AbstractDiscoveryContainerAdapter extends */ protected void fireServiceDiscovered(IServiceEvent aServiceEvent) { Assert.isNotNull(aServiceEvent); - final Collection listeners = getListeners(aServiceEvent - .getServiceInfo().getServiceID().getServiceTypeID()); + final Collection listeners = getListeners(aServiceEvent.getServiceInfo().getServiceID().getServiceTypeID()); if (listeners != null) { for (final Iterator i = listeners.iterator(); i.hasNext();) { final IServiceListener l = (IServiceListener) i.next(); l.serviceDiscovered(aServiceEvent); - Trace.trace(DiscoveryPlugin.PLUGIN_ID, - DiscoveryDebugOption.METHODS_TRACING, this.getClass(), + Trace.trace(DiscoveryPlugin.PLUGIN_ID, DiscoveryDebugOption.METHODS_TRACING, this.getClass(), "fireServiceDiscovered", aServiceEvent.toString()); //$NON-NLS-1$ } } @@ -240,8 +234,7 @@ public abstract class AbstractDiscoveryContainerAdapter extends for (final Iterator i = notify.iterator(); i.hasNext();) { final IServiceTypeListener l = (IServiceTypeListener) i.next(); l.serviceTypeDiscovered(aServiceTypeEvent); - Trace.trace(DiscoveryPlugin.PLUGIN_ID, - DiscoveryDebugOption.METHODS_TRACING, this.getClass(), + Trace.trace(DiscoveryPlugin.PLUGIN_ID, DiscoveryDebugOption.METHODS_TRACING, this.getClass(), "fireServiceTypeDiscovered", aServiceTypeEvent.toString()); //$NON-NLS-1$ } } @@ -255,14 +248,12 @@ public abstract class AbstractDiscoveryContainerAdapter extends */ protected void fireServiceUndiscovered(IServiceEvent aServiceEvent) { Assert.isNotNull(aServiceEvent); - final Collection listeners = getListeners(aServiceEvent - .getServiceInfo().getServiceID().getServiceTypeID()); + final Collection listeners = getListeners(aServiceEvent.getServiceInfo().getServiceID().getServiceTypeID()); if (listeners != null) { for (final Iterator i = listeners.iterator(); i.hasNext();) { final IServiceListener l = (IServiceListener) i.next(); l.serviceUndiscovered(aServiceEvent); - Trace.trace(DiscoveryPlugin.PLUGIN_ID, - DiscoveryDebugOption.METHODS_TRACING, this.getClass(), + Trace.trace(DiscoveryPlugin.PLUGIN_ID, DiscoveryDebugOption.METHODS_TRACING, this.getClass(), "fireServiceUndiscovered", aServiceEvent.toString()); //$NON-NLS-1$ } } @@ -321,14 +312,11 @@ public abstract class AbstractDiscoveryContainerAdapter extends Assert.isNotNull(aServiceType); Collection listeners = new HashSet(); synchronized (serviceListeners) { - for (Iterator itr = serviceListeners.keySet().iterator(); itr - .hasNext();) { + for (Iterator itr = serviceListeners.keySet().iterator(); itr.hasNext();) { final IServiceTypeID typeID = (IServiceTypeID) itr.next(); - int compare = discoveryServiceListenerComparator.compare( - aServiceType, typeID); + int compare = discoveryServiceListenerComparator.compare(aServiceType, typeID); if (compare == 0) { - Collection collection = (Collection) serviceListeners - .get(typeID); + Collection collection = (Collection) serviceListeners.get(typeID); if (collection != null) { listeners.addAll(collection); } @@ -355,9 +343,8 @@ public abstract class AbstractDiscoveryContainerAdapter extends /* * (non-Javadoc) * - * @see - * org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#removeServiceListener - * (org.eclipse.ecf.discovery.IServiceListener) + * @see org.eclipse.ecf.discovery.IDiscoveryContainerAdapter# + * removeServiceListener (org.eclipse.ecf.discovery.IServiceListener) */ public void removeServiceListener(IServiceListener aListener) { Assert.isNotNull(aListener); @@ -367,13 +354,11 @@ public abstract class AbstractDiscoveryContainerAdapter extends /* * (non-Javadoc) * - * @see - * org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#removeServiceListener - * (org.eclipse.ecf.discovery.identity.IServiceTypeID, + * @see org.eclipse.ecf.discovery.IDiscoveryContainerAdapter# + * removeServiceListener (org.eclipse.ecf.discovery.identity.IServiceTypeID, * org.eclipse.ecf.discovery.IServiceListener) */ - public void removeServiceListener(IServiceTypeID aType, - IServiceListener aListener) { + public void removeServiceListener(IServiceTypeID aType, IServiceListener aListener) { Assert.isNotNull(aListener); Assert.isNotNull(aType); synchronized (serviceListeners) { diff --git a/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/DiscoveryContainerConfig.java b/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/DiscoveryContainerConfig.java index f7975e7f5..b09bb9c13 100644 --- a/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/DiscoveryContainerConfig.java +++ b/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/DiscoveryContainerConfig.java @@ -18,12 +18,15 @@ public class DiscoveryContainerConfig { /** * @param anID + * an ID */ public DiscoveryContainerConfig(ID anID) { id = anID; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.eclipse.ecf.discovery.IContainerConfig#getID() */ public ID getID() { diff --git a/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/IServiceInfo.java b/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/IServiceInfo.java index 3083e56ed..9d2bfe2b1 100644 --- a/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/IServiceInfo.java +++ b/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/IServiceInfo.java @@ -17,8 +17,8 @@ import org.eclipse.ecf.discovery.identity.IServiceID; * Service information contract. Defines the information associated with a * remotely discoverable service * - * @see "http://www.dns-sd.org/ServiceTypes.html" - * @see "http://www.ietf.org/rfc/rfc2782.txt" + * see http://www.dns-sd.org/ServiceTypes.html and + * http://www.ietf.org/rfc/rfc2782.txt * */ public interface IServiceInfo extends IAdaptable { @@ -32,15 +32,18 @@ public interface IServiceInfo extends IAdaptable { /** * Get ServiceID for service. * - * @return ServiceID the serviceID for the service. Will not be <code>null</code>. + * @return ServiceID the serviceID for the service. Will not be + * <code>null</code>. */ public IServiceID getServiceID(); /** * The priority for the service * - * Priority: The priority of this target host. A client MUST attempt to contact the target host with the lowest-numbered priority it can reach; - * target hosts with the same priority SHOULD be tried in an order defined by the weight field. + * Priority: The priority of this target host. A client MUST attempt to + * contact the target host with the lowest-numbered priority it can reach; + * target hosts with the same priority SHOULD be tried in an order defined + * by the weight field. * * @return int the priority. 0 if no priority information for service. */ @@ -49,10 +52,12 @@ public interface IServiceInfo extends IAdaptable { /** * The weight for the service. 0 if no weight information for service. * - * Weight: A server selection mechanism. The weight field specifies a relative weight for entries with the same priority. - * Larger weights SHOULD be given a proportionately higher probability of being selected. - * Domain administrators SHOULD use Weight 0 when there isn't any server selection to do. - * In the presence of records containing weights greater than 0, records with weight 0 should have a very small chance of being selected. + * Weight: A server selection mechanism. The weight field specifies a + * relative weight for entries with the same priority. Larger weights SHOULD + * be given a proportionately higher probability of being selected. Domain + * administrators SHOULD use Weight 0 when there isn't any server selection + * to do. In the presence of records containing weights greater than 0, + * records with weight 0 should have a very small chance of being selected. * * @return int the weight */ @@ -72,10 +77,11 @@ public interface IServiceInfo extends IAdaptable { * Map with any/all properties associated with the service. Properties are * assumed to be name/value pairs, both of type String. * - * @return Map the properties associated with this service. Will not be <code>null</code>. + * @return Map the properties associated with this service. Will not be + * <code>null</code>. */ public IServiceProperties getServiceProperties(); - + /** * A user choose label used for pretty printing this service. * diff --git a/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/IServiceListener.java b/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/IServiceListener.java index 3810e61fc..73b670a7e 100644 --- a/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/IServiceListener.java +++ b/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/IServiceListener.java @@ -13,13 +13,11 @@ package org.eclipse.ecf.discovery; * Listener for receiving service events * * <p> - * </p> * Note these methods will be called asynchronously when notifications of remote * changes are received by the provider implementation code. The provider is * free to call the methods below with an arbitrary thread, so the * implementation of these methods must be appropriately prepared. * <p> - * </p> * For example, if the code implementing any of these methods must interact with * user interface code, then it should use code such as the following to execute * on the SWT UI thread: @@ -32,8 +30,8 @@ package org.eclipse.ecf.discovery; * }); * </pre> * - * Further, the code in the implementations of these methods should <b>not block</b> - * via I/O operations or blocking UI calls. + * Further, the code in the implementations of these methods should <b>not + * block</b> via I/O operations or blocking UI calls. */ public interface IServiceListener { @@ -45,18 +43,21 @@ public interface IServiceListener { * {@link IServiceEvent} will be fired asynchronously. */ public boolean triggerDiscovery(); - + /** - * Notification that a service has been discovered (the service is fully resolved). + * Notification that a service has been discovered (the service is fully + * resolved). * - * @param anEvent Will not be <code>null</code> + * @param anEvent + * Will not be <code>null</code> */ public void serviceDiscovered(IServiceEvent anEvent); /** * Notification that a previously discovered service has been undiscovered. * - * @param anEvent Will not be <code>null</code> + * @param anEvent + * Will not be <code>null</code> */ public void serviceUndiscovered(IServiceEvent anEvent); } diff --git a/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/IServiceTypeListener.java b/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/IServiceTypeListener.java index 4c469d1cf..bccb57e7e 100644 --- a/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/IServiceTypeListener.java +++ b/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/IServiceTypeListener.java @@ -12,13 +12,11 @@ package org.eclipse.ecf.discovery; /** * Listener for service type notifications * <p> - * </p> * Note these methods will be called asynchronously when notifications of remote * changes are received by the provider implementation code. The provider is * free to call the methods below with an arbitrary thread, so the * implementation of these methods must be appropriately prepared. * <p> - * </p> * For example, if the code implementing any of these methods must interact with * user interface code, then it should use code such as the following to execute * on the SWT UI thread: @@ -31,15 +29,16 @@ package org.eclipse.ecf.discovery; * }); * </pre> * - * Further, the code in the implementations of these methods should <b>not block</b> - * via I/O operations or blocking UI calls. + * Further, the code in the implementations of these methods should <b>not + * block</b> via I/O operations or blocking UI calls. */ public interface IServiceTypeListener { /** * Notification that a service type has been discovered * - * @param event Must not be <code>null</code>. + * @param event + * Must not be <code>null</code>. */ public void serviceTypeDiscovered(IServiceTypeEvent event); } 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 5c91bc06e..3ace71000 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 @@ -9,15 +9,12 @@ package org.eclipse.ecf.discovery; -import org.eclipse.ecf.discovery.identity.ServiceID; - import java.io.Serializable; import java.net.URI; import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.IAdapterManager; 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.discovery.identity.*; import org.eclipse.ecf.internal.discovery.DiscoveryPlugin; /** @@ -48,7 +45,7 @@ public class ServiceInfo implements IServiceInfo, Serializable { protected int weight; protected IServiceProperties properties; - + /** * @since 4.0 */ @@ -59,49 +56,105 @@ public class ServiceInfo implements IServiceInfo, Serializable { } /** + * Create an IServiceInfo instance. + * + * @param anURI + * The (absolute) location of the service. + * @param aServiceName + * a user chosen service name. Only ASCII characters are allowed. + * @param aServiceTypeID + * the service type identifier. * @since 3.0 - * @see ServiceInfo#ServiceInfo(URI, String, IServiceTypeID, int, int, IServiceProperties) */ public ServiceInfo(URI anURI, String aServiceName, IServiceTypeID aServiceTypeID) { this(anURI, aServiceName, aServiceTypeID, DEFAULT_PRIORITY, DEFAULT_WEIGHT, null); } - + /** + * Create an IServiceInfo instance. + * + * @param anURI + * The (absolute) location of the service. + * @param aServiceName + * a user chosen service name. Only ASCII characters are allowed. + * @param aServiceTypeID + * the service type identifier. + * @param props + * generic service properties. * @since 3.0 - * @see ServiceInfo#ServiceInfo(URI, String, IServiceTypeID, int, int, IServiceProperties) */ public ServiceInfo(URI anURI, String aServiceName, IServiceTypeID aServiceTypeID, IServiceProperties props) { this(anURI, aServiceName, aServiceTypeID, DEFAULT_PRIORITY, DEFAULT_WEIGHT, props); } - /** + * Create an IServiceInfo instance. + * + * @param anURI + * The (absolute) location of the service. + * @param aServiceName + * a user chosen service name. Only ASCII characters are allowed. + * @param aServiceTypeID + * the service type identifier. + * @param priority + * the service priority. The priority of this target host. A + * client MUST attempt to contact the target host with the + * lowest-numbered priority it can reach; target hosts with the + * same priority SHOULD be tried in an order defined by the + * weight field. + * + * @param weight + * the service weight. A server selection mechanism. The weight + * field specifies a relative weight for entries with the same + * priority. Larger weights SHOULD be given a proportionately + * higher probability of being selected. Domain administrators + * SHOULD use Weight 0 when there isn't any server selection to + * do. In the presence of records containing weights greater than + * 0, records with weight 0 should have a very small chance of + * being selected. + * @param props + * generic service properties. * @since 3.0 - * @see ServiceInfo#ServiceInfo(URI, String, IServiceTypeID, int, int, IServiceProperties) */ - public ServiceInfo(URI anURI, String aServiceName, IServiceTypeID aServiceTypeID, int priority, - int weight, IServiceProperties props) { + public ServiceInfo(URI anURI, String aServiceName, IServiceTypeID aServiceTypeID, int priority, int weight, + IServiceProperties props) { this(anURI, aServiceName, aServiceTypeID, priority, weight, props, DEFAULT_TTL); } + /** * Create an IServiceInfo instance. - * @param anURI The (absolute) location of the service. - * @param aServiceName a user chosen service name. Only ASCII characters are allowed. - * @param aServiceTypeID the service type identifier. - * @param priority the service priority. The priority of this target host. A client MUST attempt to contact the target host with the lowest-numbered priority it can reach; - * target hosts with the same priority SHOULD be tried in an order defined by the weight field. + * + * @param anURI + * The (absolute) location of the service. + * @param aServiceName + * a user chosen service name. Only ASCII characters are allowed. + * @param aServiceTypeID + * the service type identifier. + * @param priority + * the service priority. The priority of this target host. A + * client MUST attempt to contact the target host with the + * lowest-numbered priority it can reach; target hosts with the + * same priority SHOULD be tried in an order defined by the + * weight field. * - * @param weight the service weight. A server selection mechanism. The weight field specifies a relative weight for entries with the same priority. - * Larger weights SHOULD be given a proportionately higher probability of being selected. - * Domain administrators SHOULD use Weight 0 when there isn't any server selection to do. - * In the presence of records containing weights greater than 0, records with weight 0 should have a very small chance of being selected. - * @param props generic service properties. - * @param ttl time to live + * @param weight + * the service weight. A server selection mechanism. The weight + * field specifies a relative weight for entries with the same + * priority. Larger weights SHOULD be given a proportionately + * higher probability of being selected. Domain administrators + * SHOULD use Weight 0 when there isn't any server selection to + * do. In the presence of records containing weights greater than + * 0, records with weight 0 should have a very small chance of + * being selected. + * @param props + * generic service properties. + * @param ttl + * time to live * * @since 4.0 */ - public ServiceInfo(URI anURI, String aServiceName, IServiceTypeID aServiceTypeID, int priority, - int weight, IServiceProperties props, long ttl) { + public ServiceInfo(URI anURI, String aServiceName, IServiceTypeID aServiceTypeID, int priority, int weight, + IServiceProperties props, long ttl) { Assert.isNotNull(anURI); Assert.isNotNull(aServiceName); Assert.isNotNull(aServiceTypeID); @@ -157,19 +210,19 @@ public class ServiceInfo implements IServiceInfo, Serializable { fragment = "#" + fragment; } URI uri = URI.create(scheme + "://" + userInfo + host + ":" + port + path + query + fragment); - + // service id Namespace ns = aServiceTypeID.getNamespace(); - this.serviceID = (IServiceID) ns.createInstance(new Object[]{aServiceTypeID, uri}); + this.serviceID = (IServiceID) ns.createInstance(new Object[] { aServiceTypeID, uri }); ((ServiceID) serviceID).setServiceInfo(this); - + this.serviceName = aServiceName; - + this.weight = weight; this.priority = priority; - + properties = (props == null) ? new ServiceProperties() : props; - + this.timeToLive = ttl; } @@ -226,9 +279,11 @@ public class ServiceInfo implements IServiceInfo, Serializable { public String toString() { final StringBuffer buf = new StringBuffer("ServiceInfo["); //$NON-NLS-1$ buf.append("uri=").append(getLocation()).append(";id=").append(serviceID) //$NON-NLS-1$ //$NON-NLS-2$ - .append(";priority=").append( //$NON-NLS-1$ - priority).append(";weight=").append(weight).append( //$NON-NLS-1$ - ";props=").append(properties).append("]"); //$NON-NLS-1$ //$NON-NLS-2$ + .append(";priority=") //$NON-NLS-1$ + .append(priority).append(";weight=").append(weight) //$NON-NLS-1$ + .append( + ";props=") + .append(properties).append("]"); //$NON-NLS-1$ return buf.toString(); } @@ -241,8 +296,7 @@ public class ServiceInfo implements IServiceInfo, Serializable { if (adapter.isInstance(this)) { return this; } - final IAdapterManager adapterManager = DiscoveryPlugin.getDefault() - .getAdapterManager(); + final IAdapterManager adapterManager = DiscoveryPlugin.getDefault().getAdapterManager(); if (adapterManager == null) return null; return adapterManager.loadAdapter(this, adapter.getName()); @@ -250,15 +304,17 @@ public class ServiceInfo implements IServiceInfo, Serializable { /** * (non-Javadoc) - * @see org.eclipse.ecf.discovery.IServiceInfo#getServiceName() + * + * @see org.eclipse.ecf.discovery.IServiceInfo#getServiceName() * @since 3.0 */ public String getServiceName() { return serviceName; } - + /** * (non-Javadoc) + * * @see org.eclipse.ecf.discovery.IServiceInfo#getTTL() * @since 4.0 */ 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 43c32945f..352df0006 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 @@ -35,6 +35,7 @@ public class ServiceProperties implements IServiceProperties { * Creates a copy of the given {@link IServiceProperties} * * @param sp + * service properties * @since 2.1 */ public ServiceProperties(IServiceProperties sp) { 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 c013b2188..f363b2206 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 @@ -11,11 +11,9 @@ package org.eclipse.ecf.discovery.identity; -import org.eclipse.ecf.discovery.IServiceInfo; - import java.net.URI; - import org.eclipse.ecf.core.identity.ID; +import org.eclipse.ecf.discovery.IServiceInfo; /** * Service identity contract. @@ -24,19 +22,21 @@ public interface IServiceID extends ID { /** * Get service type ID for this ID. - * @return IServiceTypeID. Will not be <code>null</code>. + * + * @return IServiceTypeID. Will not be <code>null</code>. */ public IServiceTypeID getServiceTypeID(); /** - * Get service name for this ID. + * Get service name for this ID. * - * @return String service name. May be <code>null</code>. + * @return String service name. May be <code>null</code>. * @deprecated Use {@link IServiceInfo#getServiceName()} instead */ public String getServiceName(); - + /** + * @return URI the location for this serviceID * @since 3.0 */ public URI getLocation(); 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 6dd17c271..7466c048f 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 @@ -35,6 +35,12 @@ public class ServiceID extends BaseID implements IServiceID { protected URI location; /** + * @param namespace + * namespace should not be <code>null</code> + * @param type + * service type ID should not be <code>null</code> + * @param anURI + * uri for service location should not be <code>null</code> * @since 3.0 */ protected ServiceID(Namespace namespace, IServiceTypeID type, URI anURI) { @@ -136,9 +142,8 @@ public class ServiceID extends BaseID implements IServiceID { */ public String toString() { final StringBuffer buf = new StringBuffer("ServiceID["); //$NON-NLS-1$ - buf - .append("type=").append(type).append(";location=").append(getLocation()).append( //$NON-NLS-1$ //$NON-NLS-2$ - ";full=" + getFullyQualifiedName()).append("]"); //$NON-NLS-1$ //$NON-NLS-2$ + buf.append("type=").append(type).append(";location=").append(getLocation()).append( //$NON-NLS-1$ //$NON-NLS-2$ + ";full=" + getFullyQualifiedName()).append("]"); //$NON-NLS-1$ //$NON-NLS-2$ return buf.toString(); } @@ -177,8 +182,7 @@ public class ServiceID extends BaseID implements IServiceID { public int hashCode() { final int prime = 31; int result = super.hashCode(); - result = prime * result - + ((location == null) ? 0 : location.hashCode()); + result = prime * result + ((location == null) ? 0 : location.hashCode()); result = prime * result + ((type == null) ? 0 : type.hashCode()); return result; } 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 index 09a2be666..3dfecbc7b 100644 --- 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 @@ -35,8 +35,8 @@ public class ServiceTypeID extends BaseID implements IServiceTypeID { super(namespace); } - protected ServiceTypeID(Namespace namespace, String[] services, - String[] scopes, String[] protocols, String namingAuthority) { + protected ServiceTypeID(Namespace namespace, String[] services, String[] scopes, String[] protocols, + String namingAuthority) { super(namespace); Assert.isNotNull(services); this.services = services; @@ -51,8 +51,7 @@ public class ServiceTypeID extends BaseID implements IServiceTypeID { } protected ServiceTypeID(Namespace ns, IServiceTypeID id) { - this(ns, id.getServices(), id.getScopes(), id.getProtocols(), id - .getNamingAuthority()); + this(ns, id.getServices(), id.getScopes(), id.getProtocols(), id.getNamingAuthority()); } /** @@ -60,7 +59,9 @@ public class ServiceTypeID extends BaseID implements IServiceTypeID { * and/or {@link ServiceIDFactory} instead. * * @param namespace + * namespace should not be <code>null</code> * @param aType + * type should not be <code>null</code> */ public ServiceTypeID(Namespace namespace, String aType) { this(namespace); @@ -88,8 +89,7 @@ public class ServiceTypeID extends BaseID implements IServiceTypeID { // protocol and scope String string = split[--offset]; - String[] protoAndScope = StringUtils.split(string, - ".", string.indexOf(".") - 1); //$NON-NLS-1$ //$NON-NLS-2$ + String[] protoAndScope = StringUtils.split(string, ".", string.indexOf(".") - 1); //$NON-NLS-1$ //$NON-NLS-2$ this.protocols = new String[] { protoAndScope[0] }; this.scopes = new String[] { protoAndScope[1] }; |