org.eclipse.ecf.discovery_4.0.0.v20111230-0120

16:43:05.448 INFO  jd.cli.Main - Decompiling org.eclipse.ecf.discovery_4.0.0.v20111230-0120.jar
package org.eclipse.ecf.discovery;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.ecf.discovery.identity.IServiceID;
import org.eclipse.equinox.concurrent.future.IProgressRunnable;

class AbstractDiscoveryContainerAdapter$1
  implements IProgressRunnable
{
  final AbstractDiscoveryContainerAdapter this$0;
  private final IServiceID val$service;
  
  AbstractDiscoveryContainerAdapter$1(AbstractDiscoveryContainerAdapter paramAbstractDiscoveryContainerAdapter, IServiceID paramIServiceID)
  {
    this$0 = paramAbstractDiscoveryContainerAdapter;val$service = paramIServiceID;
  }
  
  public Object run(IProgressMonitor monitor)
    throws Exception
  {
    return this$0.getServiceInfo(val$service);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ecf.discovery.AbstractDiscoveryContainerAdapter.1
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ecf.discovery;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.equinox.concurrent.future.IProgressRunnable;

class AbstractDiscoveryContainerAdapter$2
  implements IProgressRunnable
{
  final AbstractDiscoveryContainerAdapter this$0;
  
  AbstractDiscoveryContainerAdapter$2(AbstractDiscoveryContainerAdapter paramAbstractDiscoveryContainerAdapter)
  {
    this$0 = paramAbstractDiscoveryContainerAdapter;
  }
  
  public Object run(IProgressMonitor monitor)
    throws Exception
  {
    return this$0.getServiceTypes();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ecf.discovery.AbstractDiscoveryContainerAdapter.2
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ecf.discovery;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.equinox.concurrent.future.IProgressRunnable;

class AbstractDiscoveryContainerAdapter$3
  implements IProgressRunnable
{
  final AbstractDiscoveryContainerAdapter this$0;
  
  AbstractDiscoveryContainerAdapter$3(AbstractDiscoveryContainerAdapter paramAbstractDiscoveryContainerAdapter)
  {
    this$0 = paramAbstractDiscoveryContainerAdapter;
  }
  
  public Object run(IProgressMonitor monitor)
    throws Exception
  {
    return this$0.getServices();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ecf.discovery.AbstractDiscoveryContainerAdapter.3
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ecf.discovery;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.ecf.discovery.identity.IServiceTypeID;
import org.eclipse.equinox.concurrent.future.IProgressRunnable;

class AbstractDiscoveryContainerAdapter$4
  implements IProgressRunnable
{
  final AbstractDiscoveryContainerAdapter this$0;
  private final IServiceTypeID val$type;
  
  AbstractDiscoveryContainerAdapter$4(AbstractDiscoveryContainerAdapter paramAbstractDiscoveryContainerAdapter, IServiceTypeID paramIServiceTypeID)
  {
    this$0 = paramAbstractDiscoveryContainerAdapter;val$type = paramIServiceTypeID;
  }
  
  public Object run(IProgressMonitor monitor)
    throws Exception
  {
    return this$0.getServices(val$type);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ecf.discovery.AbstractDiscoveryContainerAdapter.4
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ecf.discovery;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.ecf.core.AbstractContainer;
import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.core.identity.IDFactory;
import org.eclipse.ecf.core.identity.IIDFactory;
import org.eclipse.ecf.core.identity.Namespace;
import org.eclipse.ecf.core.util.Trace;
import org.eclipse.ecf.discovery.identity.IServiceID;
import org.eclipse.ecf.discovery.identity.IServiceTypeID;
import org.eclipse.ecf.internal.discovery.DiscoveryServiceListener;
import org.eclipse.ecf.internal.discovery.ServiceTypeComparator;
import org.eclipse.equinox.concurrent.future.IExecutor;
import org.eclipse.equinox.concurrent.future.IFuture;
import org.eclipse.equinox.concurrent.future.IProgressRunnable;
import org.eclipse.equinox.concurrent.future.ThreadsExecutor;

public abstract class AbstractDiscoveryContainerAdapter
  extends AbstractContainer
  implements IDiscoveryLocator, IDiscoveryAdvertiser
{
  protected final Set allServiceListeners;
  private DiscoveryContainerConfig config;
  protected final Map serviceListeners;
  protected final String servicesNamespaceName;
  protected final Collection serviceTypeListeners;
  private DiscoveryServiceListener discoveryServiceListener;
  private DiscoveryServiceListener discoveryServiceTypeListener;
  private ServiceTypeComparator discoveryServiceListenerComparator;
  
  public AbstractDiscoveryContainerAdapter(String aNamespaceName, DiscoveryContainerConfig aConfig)
  {
    servicesNamespaceName = aNamespaceName;
    Assert.isNotNull(servicesNamespaceName);
    config = aConfig;
    Assert.isNotNull(config);
    serviceTypeListeners = Collections.synchronizedSet(new HashSet());
    serviceListeners = Collections.synchronizedMap(new HashMap());
    allServiceListeners = Collections.synchronizedSet(new HashSet());
    
    discoveryServiceListener = new DiscoveryServiceListener(this, 
      IServiceListener.class);
    discoveryServiceTypeListener = new DiscoveryServiceListener(this, 
      IServiceTypeListener.class);
    
    discoveryServiceListenerComparator = new ServiceTypeComparator();
  }
  
  public void addServiceListener(IServiceListener aListener)
  {
    Assert.isNotNull(aListener);
    allServiceListeners.add(aListener);
  }
  
  public void addServiceListener(IServiceTypeID aType, IServiceListener aListener)
  {
    Assert.isNotNull(aListener);
    Assert.isNotNull(aType);
    synchronized (serviceListeners)
    {
      Collection v = (Collection)serviceListeners.get(aType);
      if (v == null)
      {
        v = Collections.synchronizedSet(new HashSet());
        serviceListeners.put(aType, v);
      }
      v.add(aListener);
    }
  }
  
  public void addServiceTypeListener(IServiceTypeListener aListener)
  {
    Assert.isNotNull(aListener);
    serviceTypeListeners.add(aListener);
  }
  
  protected void clearListeners()
  {
    serviceListeners.clear();
    serviceTypeListeners.clear();
    allServiceListeners.clear();
  }
  
  public void dispose()
  {
    disconnect();
    clearListeners();
    config = null;
    discoveryServiceListener.dispose();
    discoveryServiceTypeListener.dispose();
    super.dispose();
  }
  
  protected void fireServiceDiscovered(IServiceEvent aServiceEvent)
  {
    Assert.isNotNull(aServiceEvent);
    Collection listeners = getListeners(aServiceEvent
      .getServiceInfo().getServiceID().getServiceTypeID());
    if (listeners != null) {
      for (Iterator i = listeners.iterator(); i.hasNext();)
      {
        IServiceListener l = (IServiceListener)i.next();
        l.serviceDiscovered(aServiceEvent);
        Trace.trace("org.eclipse.ecf.discovery", 
          "org.eclipse.ecf.discovery/debug/methods/tracing", getClass(), 
          "fireServiceDiscovered", aServiceEvent.toString());
      }
    }
  }
  
  protected void fireServiceTypeDiscovered(IServiceTypeEvent aServiceTypeEvent)
  {
    Assert.isNotNull(aServiceTypeEvent);
    List notify = null;
    synchronized (serviceTypeListeners)
    {
      notify = new ArrayList(serviceTypeListeners);
    }
    for (Iterator i = notify.iterator(); i.hasNext();)
    {
      IServiceTypeListener l = (IServiceTypeListener)i.next();
      l.serviceTypeDiscovered(aServiceTypeEvent);
      Trace.trace("org.eclipse.ecf.discovery", 
        "org.eclipse.ecf.discovery/debug/methods/tracing", getClass(), 
        "fireServiceTypeDiscovered", aServiceTypeEvent.toString());
    }
  }
  
  protected void fireServiceUndiscovered(IServiceEvent aServiceEvent)
  {
    Assert.isNotNull(aServiceEvent);
    Collection listeners = getListeners(aServiceEvent
      .getServiceInfo().getServiceID().getServiceTypeID());
    if (listeners != null) {
      for (Iterator i = listeners.iterator(); i.hasNext();)
      {
        IServiceListener l = (IServiceListener)i.next();
        l.serviceUndiscovered(aServiceEvent);
        Trace.trace("org.eclipse.ecf.discovery", 
          "org.eclipse.ecf.discovery/debug/methods/tracing", getClass(), 
          "fireServiceUndiscovered", aServiceEvent.toString());
      }
    }
  }
  
  protected DiscoveryContainerConfig getConfig()
  {
    return config;
  }
  
  public Namespace getConnectNamespace()
  {
    return IDFactory.getDefault().getNamespaceByName(servicesNamespaceName);
  }
  
  public ID getID()
  {
    if (config != null) {
      return config.getID();
    }
    return null;
  }
  
  public abstract String getContainerName();
  
  protected Collection getListeners(IServiceTypeID aServiceType)
  {
    Assert.isNotNull(aServiceType);
    Collection listeners = new HashSet();
    synchronized (serviceListeners)
    {
      for (Iterator itr = serviceListeners.keySet().iterator(); itr
            .hasNext();)
      {
        IServiceTypeID typeID = (IServiceTypeID)itr.next();
        int compare = discoveryServiceListenerComparator.compare(
          aServiceType, typeID);
        if (compare == 0)
        {
          Collection collection = (Collection)serviceListeners
            .get(typeID);
          if (collection != null) {
            listeners.addAll(collection);
          }
        }
      }
    }
    synchronized (allServiceListeners)
    {
      listeners.addAll(allServiceListeners);
    }
    return Collections.unmodifiableCollection(listeners);
  }
  
  public Namespace getServicesNamespace()
  {
    return IDFactory.getDefault().getNamespaceByName(servicesNamespaceName);
  }
  
  public void removeServiceListener(IServiceListener aListener)
  {
    Assert.isNotNull(aListener);
    allServiceListeners.remove(aListener);
  }
  
  public void removeServiceListener(IServiceTypeID aType, IServiceListener aListener)
  {
    Assert.isNotNull(aListener);
    Assert.isNotNull(aType);
    synchronized (serviceListeners)
    {
      Collection v = (Collection)serviceListeners.get(aType);
      if (v != null) {
        v.remove(aListener);
      }
    }
  }
  
  public void removeServiceTypeListener(IServiceTypeListener aListener)
  {
    Assert.isNotNull(aListener);
    serviceTypeListeners.remove(aListener);
  }
  
  public void unregisterAllServices()
  {
    throw new UnsupportedOperationException("Not yet implemeted");
  }
  
  public IServiceInfo[] purgeCache()
  {
    return new IServiceInfo[0];
  }
  
  public IFuture getAsyncServiceInfo(IServiceID service)
  {
    IExecutor executor = new ThreadsExecutor();
    executor.execute(new IProgressRunnable()
    {
      private final IServiceID val$service;
      
      public Object run(IProgressMonitor monitor)
        throws Exception
      {
        return getServiceInfo(val$service);
      }
    }, null);
  }
  
  public IFuture getAsyncServiceTypes()
  {
    IExecutor executor = new ThreadsExecutor();
    executor.execute(new IProgressRunnable()
    {
      public Object run(IProgressMonitor monitor)
        throws Exception
      {
        return getServiceTypes();
      }
    }, null);
  }
  
  public IFuture getAsyncServices()
  {
    IExecutor executor = new ThreadsExecutor();
    executor.execute(new IProgressRunnable()
    {
      public Object run(IProgressMonitor monitor)
        throws Exception
      {
        return getServices();
      }
    }, null);
  }
  
  public IFuture getAsyncServices(IServiceTypeID type)
  {
    IExecutor executor = new ThreadsExecutor();
    executor.execute(new IProgressRunnable()
    {
      private final IServiceTypeID val$type;
      
      public Object run(IProgressMonitor monitor)
        throws Exception
      {
        return getServices(val$type);
      }
    }, null);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ecf.discovery.AbstractDiscoveryContainerAdapter
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ecf.discovery;

import org.eclipse.ecf.core.identity.ID;

public class DiscoveryContainerConfig
{
  private ID id;
  
  public DiscoveryContainerConfig(ID anID)
  {
    id = anID;
  }
  
  public ID getID()
  {
    return id;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ecf.discovery.DiscoveryContainerConfig
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ecf.discovery;

public abstract interface IContainerServiceInfoAdapter
{
  public static final String CONTAINER_FACTORY_NAME_PROPERTY = "org.eclipse.ecf.containerFactoryName";
  public static final String CONTAINER_CONNECT_TARGET = "org.eclipse.ecf.connectTarget";
  public static final String CONTAINER_CONNECT_TARGET_PROTOCOL = "org.eclipse.ecf.connectTargetProtocol";
  public static final String CONTAINER_CONNECT_TARGET_PATH = "org.eclipse.ecf.connectTargetPath";
  public static final String CONTAINER_CONNECT_REQUIRES_PASSWORD = "org.eclipse.ecf.connectContextRequiresPassword";
  
  public abstract String getContainerFactoryName();
  
  public abstract String getConnectTarget();
  
  public abstract Boolean connectRequiresPassword();
  
  public abstract void setContainerProperties(String paramString1, String paramString2, String paramString3, Boolean paramBoolean);
  
  public abstract void setContainerProperties(String paramString1, String paramString2, Boolean paramBoolean);
}

/* Location:
 * Qualified Name:     org.eclipse.ecf.discovery.IContainerServiceInfoAdapter
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ecf.discovery;

import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.ecf.core.identity.Namespace;

public abstract interface IDiscoveryAdvertiser
  extends IAdaptable
{
  public static final String CONTAINER_NAME = "org.eclipse.ecf.discovery.containerName";
  
  public abstract void registerService(IServiceInfo paramIServiceInfo);
  
  public abstract void unregisterService(IServiceInfo paramIServiceInfo);
  
  public abstract void unregisterAllServices();
  
  public abstract Namespace getServicesNamespace();
}

/* Location:
 * Qualified Name:     org.eclipse.ecf.discovery.IDiscoveryAdvertiser
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ecf.discovery;

/**
 * @deprecated
 */
public abstract interface IDiscoveryContainerAdapter
  extends IDiscoveryLocator, IDiscoveryAdvertiser
{}

/* Location:
 * Qualified Name:     org.eclipse.ecf.discovery.IDiscoveryContainerAdapter
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ecf.discovery;

import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.ecf.core.identity.Namespace;
import org.eclipse.ecf.discovery.identity.IServiceID;
import org.eclipse.ecf.discovery.identity.IServiceTypeID;
import org.eclipse.equinox.concurrent.future.IFuture;

public abstract interface IDiscoveryLocator
  extends IAdaptable
{
  public static final String CONTAINER_NAME = "org.eclipse.ecf.discovery.containerName";
  
  public abstract IServiceInfo getServiceInfo(IServiceID paramIServiceID);
  
  public abstract IServiceInfo[] getServices();
  
  public abstract IServiceInfo[] getServices(IServiceTypeID paramIServiceTypeID);
  
  public abstract IServiceTypeID[] getServiceTypes();
  
  public abstract Namespace getServicesNamespace();
  
  public abstract IServiceInfo[] purgeCache();
  
  public abstract void addServiceListener(IServiceListener paramIServiceListener);
  
  public abstract void addServiceListener(IServiceTypeID paramIServiceTypeID, IServiceListener paramIServiceListener);
  
  public abstract void addServiceTypeListener(IServiceTypeListener paramIServiceTypeListener);
  
  public abstract void removeServiceListener(IServiceListener paramIServiceListener);
  
  public abstract void removeServiceListener(IServiceTypeID paramIServiceTypeID, IServiceListener paramIServiceListener);
  
  public abstract void removeServiceTypeListener(IServiceTypeListener paramIServiceTypeListener);
  
  public abstract IFuture getAsyncServiceInfo(IServiceID paramIServiceID);
  
  public abstract IFuture getAsyncServices();
  
  public abstract IFuture getAsyncServices(IServiceTypeID paramIServiceTypeID);
  
  public abstract IFuture getAsyncServiceTypes();
}

/* Location:
 * Qualified Name:     org.eclipse.ecf.discovery.IDiscoveryLocator
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ecf.discovery;

import org.eclipse.ecf.core.events.IContainerEvent;

public abstract interface IServiceEvent
  extends IContainerEvent
{
  public abstract IServiceInfo getServiceInfo();
}

/* Location:
 * Qualified Name:     org.eclipse.ecf.discovery.IServiceEvent
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ecf.discovery;

import java.net.URI;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.ecf.discovery.identity.IServiceID;

public abstract interface IServiceInfo
  extends IAdaptable
{
  public abstract URI getLocation();
  
  public abstract IServiceID getServiceID();
  
  public abstract int getPriority();
  
  public abstract int getWeight();
  
  public abstract long getTTL();
  
  public abstract IServiceProperties getServiceProperties();
  
  public abstract String getServiceName();
}

/* Location:
 * Qualified Name:     org.eclipse.ecf.discovery.IServiceInfo
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ecf.discovery;

public abstract interface IServiceListener
{
  public abstract void serviceDiscovered(IServiceEvent paramIServiceEvent);
  
  public abstract void serviceUndiscovered(IServiceEvent paramIServiceEvent);
}

/* Location:
 * Qualified Name:     org.eclipse.ecf.discovery.IServiceListener
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ecf.discovery;

import java.io.Serializable;
import java.util.Enumeration;

public abstract interface IServiceProperties
  extends Serializable
{
  public abstract Enumeration getPropertyNames();
  
  public abstract String getPropertyString(String paramString);
  
  public abstract byte[] getPropertyBytes(String paramString);
  
  public abstract Object getProperty(String paramString);
  
  public abstract Object setPropertyString(String paramString1, String paramString2);
  
  public abstract Object setPropertyBytes(String paramString, byte[] paramArrayOfByte);
  
  public abstract Object setProperty(String paramString, Object paramObject);
  
  public abstract boolean equals(Object paramObject);
  
  public abstract int hashCode();
  
  public abstract int size();
}

/* Location:
 * Qualified Name:     org.eclipse.ecf.discovery.IServiceProperties
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ecf.discovery;

import org.eclipse.ecf.core.events.IContainerEvent;
import org.eclipse.ecf.discovery.identity.IServiceTypeID;

public abstract interface IServiceTypeEvent
  extends IContainerEvent
{
  public abstract IServiceTypeID getServiceTypeID();
}

/* Location:
 * Qualified Name:     org.eclipse.ecf.discovery.IServiceTypeEvent
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ecf.discovery;

public abstract interface IServiceTypeListener
{
  public abstract void serviceTypeDiscovered(IServiceTypeEvent paramIServiceTypeEvent);
}

/* Location:
 * Qualified Name:     org.eclipse.ecf.discovery.IServiceTypeListener
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ecf.discovery;

import org.eclipse.ecf.core.identity.ID;

public class ServiceContainerEvent
  implements IServiceEvent
{
  private static final long serialVersionUID = -2704247495748252242L;
  protected IServiceInfo info;
  protected ID containerID;
  
  public ServiceContainerEvent(IServiceInfo info, ID containerID)
  {
    this.info = info;
    this.containerID = containerID;
  }
  
  public IServiceInfo getServiceInfo()
  {
    return info;
  }
  
  public ID getLocalContainerID()
  {
    return containerID;
  }
  
  public String toString()
  {
    StringBuffer buf = new StringBuffer("ServiceContainerEvent[");
    buf.append("serviceinfo=").append(info).append("]");
    return buf.toString();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ecf.discovery.ServiceContainerEvent
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ecf.discovery;

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.ServiceID;
import org.eclipse.ecf.internal.discovery.DiscoveryPlugin;

public class ServiceInfo
  implements IServiceInfo, Serializable
{
  private static final long serialVersionUID = -5651115550295457142L;
  public static final long DEFAULT_TTL = 3600L;
  public static final int DEFAULT_PRIORITY = 0;
  public static final int DEFAULT_WEIGHT = 0;
  public static final String UNKNOWN_PROTOCOL = "unknown";
  protected String serviceName;
  protected IServiceID serviceID;
  protected int priority;
  protected int weight;
  protected IServiceProperties properties;
  protected long timeToLive;
  
  protected ServiceInfo() {}
  
  public ServiceInfo(URI anURI, String aServiceName, IServiceTypeID aServiceTypeID)
  {
    this(anURI, aServiceName, aServiceTypeID, 0, 0, null);
  }
  
  public ServiceInfo(URI anURI, String aServiceName, IServiceTypeID aServiceTypeID, IServiceProperties props)
  {
    this(anURI, aServiceName, aServiceTypeID, 0, 0, props);
  }
  
  public ServiceInfo(URI anURI, String aServiceName, IServiceTypeID aServiceTypeID, int priority, int weight, IServiceProperties props)
  {
    this(anURI, aServiceName, aServiceTypeID, priority, weight, props, 3600L);
  }
  
  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);
    
    String scheme = anURI.getScheme();
    if (scheme == null) {
      scheme = "unknown";
    }
    String userInfo = anURI.getUserInfo();
    if (userInfo == null) {
      userInfo = "";
    } else {
      userInfo = userInfo + "@";
    }
    String host = anURI.getHost();
    Assert.isNotNull(host);
    
    int port = anURI.getPort();
    if (port == -1) {
      port = 0;
    }
    String path = anURI.getPath();
    if (path == null) {
      path = "/";
    }
    String query = anURI.getQuery();
    if (query == null) {
      query = "";
    } else {
      query = "?" + query;
    }
    String fragment = anURI.getFragment();
    if (fragment == null) {
      fragment = "";
    } else {
      fragment = "#" + fragment;
    }
    URI uri = URI.create(scheme + "://" + userInfo + host + ":" + port + path + query + fragment);
    
    Namespace ns = aServiceTypeID.getNamespace();
    serviceID = ((IServiceID)ns.createInstance(new Object[] { aServiceTypeID, uri }));
    ((ServiceID)serviceID).setServiceInfo(this);
    
    serviceName = aServiceName;
    
    this.weight = weight;
    this.priority = priority;
    
    properties = (props == null ? new ServiceProperties() : props);
    
    timeToLive = ttl;
  }
  
  public URI getLocation()
  {
    return serviceID.getLocation();
  }
  
  public IServiceID getServiceID()
  {
    return serviceID;
  }
  
  public int getPriority()
  {
    return priority;
  }
  
  public int getWeight()
  {
    return weight;
  }
  
  public IServiceProperties getServiceProperties()
  {
    return properties;
  }
  
  public String toString()
  {
    StringBuffer buf = new StringBuffer("ServiceInfo[");
    buf.append("uri=").append(getLocation()).append(";id=").append(serviceID)
      .append(";priority=").append(
      priority).append(";weight=").append(weight).append(
      ";props=").append(properties).append("]");
    return buf.toString();
  }
  
  public Object getAdapter(Class adapter)
  {
    if (adapter.isInstance(this)) {
      return this;
    }
    IAdapterManager adapterManager = DiscoveryPlugin.getDefault()
      .getAdapterManager();
    if (adapterManager == null) {
      return null;
    }
    return adapterManager.loadAdapter(this, adapter.getName());
  }
  
  public String getServiceName()
  {
    return serviceName;
  }
  
  public long getTTL()
  {
    return timeToLive;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ecf.discovery.ServiceInfo
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ecf.discovery;

import java.io.Serializable;
import java.util.Arrays;

class ServiceProperties$ByteArrayWrapper
  implements Serializable
{
  private static final long serialVersionUID = -8528836675536956297L;
  private final byte[] value;
  
  public ServiceProperties$ByteArrayWrapper(byte[] value)
  {
    this.value = value;
  }
  
  public byte[] getByte()
  {
    return value;
  }
  
  public boolean equals(Object obj)
  {
    if ((obj instanceof ByteArrayWrapper))
    {
      ByteArrayWrapper baw = (ByteArrayWrapper)obj;
      return Arrays.equals(value, value);
    }
    return false;
  }
  
  public int hashCode()
  {
    return value.hashCode();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ecf.discovery.ServiceProperties.ByteArrayWrapper
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ecf.discovery;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.Properties;
import java.util.Set;

public class ServiceProperties
  implements IServiceProperties
{
  private static final long serialVersionUID = -1033681952881598670L;
  private final Properties props;
  
  public ServiceProperties()
  {
    props = new Properties();
  }
  
  public ServiceProperties(Properties props)
  {
    this.props = (props == null ? new Properties() : props);
  }
  
  public ServiceProperties(IServiceProperties sp)
  {
    props = new Properties();
    Enumeration names = sp.getPropertyNames();
    while (names.hasMoreElements())
    {
      String key = (String)names.nextElement();
      Object value = sp.getProperty(key);
      props.put(key, value);
    }
  }
  
  public Enumeration getPropertyNames()
  {
    return props.keys();
  }
  
  public String getPropertyString(String name)
  {
    Object val = props.get(name);
    if ((val instanceof String)) {
      return (String)val;
    }
    return null;
  }
  
  public byte[] getPropertyBytes(String name)
  {
    Object val = props.get(name);
    if ((val instanceof ByteArrayWrapper))
    {
      ByteArrayWrapper baw = (ByteArrayWrapper)val;
      return baw.getByte();
    }
    return null;
  }
  
  public Object getProperty(String name)
  {
    return props.get(name);
  }
  
  public Object setProperty(String name, Object value)
  {
    return props.put(name, value);
  }
  
  public Object setPropertyBytes(String name, byte[] value)
  {
    return props.put(name, new ByteArrayWrapper(value));
  }
  
  public Object setPropertyString(String name, String value)
  {
    return props.put(name, value);
  }
  
  public boolean equals(Object obj)
  {
    if ((obj instanceof ServiceProperties))
    {
      ServiceProperties sp = (ServiceProperties)obj;
      return props.equals(props);
    }
    return false;
  }
  
  public int hashCode()
  {
    return props.hashCode();
  }
  
  public String toString()
  {
    StringBuffer buf = new StringBuffer("ServiceProperties[");
    buf.append(props).append("]");
    return buf.toString();
  }
  
  public int size()
  {
    return props.size();
  }
  
  public Properties asProperties()
  {
    Properties result = new Properties();
    Set keySet = props.keySet();
    for (Iterator iterator = keySet.iterator(); iterator.hasNext();)
    {
      Object key = iterator.next();
      Object value = props.get(key);
      if ((value instanceof ByteArrayWrapper))
      {
        ByteArrayWrapper baw = (ByteArrayWrapper)value;
        result.put(key, baw.getByte());
      }
      else
      {
        result.put(key, value);
      }
    }
    return result;
  }
  
  private static class ByteArrayWrapper
    implements Serializable
  {
    private static final long serialVersionUID = -8528836675536956297L;
    private final byte[] value;
    
    public ByteArrayWrapper(byte[] value)
    {
      this.value = value;
    }
    
    public byte[] getByte()
    {
      return value;
    }
    
    public boolean equals(Object obj)
    {
      if ((obj instanceof ByteArrayWrapper))
      {
        ByteArrayWrapper baw = (ByteArrayWrapper)obj;
        return Arrays.equals(value, value);
      }
      return false;
    }
    
    public int hashCode()
    {
      return value.hashCode();
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ecf.discovery.ServiceProperties
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ecf.discovery;

import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.discovery.identity.IServiceTypeID;

public class ServiceTypeContainerEvent
  implements IServiceTypeEvent
{
  private static final long serialVersionUID = -2989101661453584041L;
  protected IServiceTypeID serviceType;
  protected ID containerID;
  
  public ServiceTypeContainerEvent(IServiceTypeID serviceType, ID containerID)
  {
    this.serviceType = serviceType;
    this.containerID = containerID;
  }
  
  public ID getLocalContainerID()
  {
    return containerID;
  }
  
  public String toString()
  {
    StringBuffer buf = new StringBuffer("ServiceTypeContainerEvent[");
    buf.append("servicetypeid=").append(getServiceTypeID()).append(";containerid=").append(getLocalContainerID()).append("]");
    return buf.toString();
  }
  
  public IServiceTypeID getServiceTypeID()
  {
    return serviceType;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ecf.discovery.ServiceTypeContainerEvent
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ecf.discovery.identity;

import java.net.URI;
import org.eclipse.ecf.core.identity.ID;

public abstract interface IServiceID
  extends ID
{
  public abstract IServiceTypeID getServiceTypeID();
  
  /**
   * @deprecated
   */
  public abstract String getServiceName();
  
  public abstract URI getLocation();
}

/* Location:
 * Qualified Name:     org.eclipse.ecf.discovery.identity.IServiceID
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ecf.discovery.identity;

import org.eclipse.ecf.core.identity.Namespace;

public abstract interface IServiceIDFactory
{
  public abstract IServiceTypeID createServiceTypeID(Namespace paramNamespace, String paramString);
  
  public abstract IServiceTypeID createServiceTypeID(Namespace paramNamespace, String[] paramArrayOfString);
  
  public abstract IServiceTypeID createServiceTypeID(Namespace paramNamespace, String[] paramArrayOfString1, String[] paramArrayOfString2, String[] paramArrayOfString3, String paramString);
  
  public abstract IServiceTypeID createServiceTypeID(Namespace paramNamespace, String[] paramArrayOfString1, String[] paramArrayOfString2);
  
  public abstract IServiceTypeID createServiceTypeID(Namespace paramNamespace, IServiceTypeID paramIServiceTypeID);
}

/* Location:
 * Qualified Name:     org.eclipse.ecf.discovery.identity.IServiceIDFactory
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ecf.discovery.identity;

import org.eclipse.ecf.core.identity.ID;

public abstract interface IServiceTypeID
  extends ID
{
  public static final String[] DEFAULT_PROTO = { "tcp" };
  public static final String[] DEFAULT_SCOPE = { "default" };
  public static final String DEFAULT_NA = "iana";
  
  public abstract String getNamingAuthority();
  
  public abstract String[] getProtocols();
  
  public abstract String[] getScopes();
  
  public abstract String[] getServices();
  
  public abstract String getInternal();
}

/* Location:
 * Qualified Name:     org.eclipse.ecf.discovery.identity.IServiceTypeID
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ecf.discovery.identity;

import java.net.URI;
import org.eclipse.core.runtime.Assert;
import org.eclipse.ecf.core.identity.BaseID;
import org.eclipse.ecf.core.identity.Namespace;
import org.eclipse.ecf.discovery.IServiceInfo;

public class ServiceID
  extends BaseID
  implements IServiceID
{
  private static final long serialVersionUID = 4362768703249025783L;
  protected IServiceInfo serviceInfo;
  protected IServiceTypeID type;
  protected URI location;
  
  protected ServiceID(Namespace namespace, IServiceTypeID type, URI anURI)
  {
    super(namespace);
    Assert.isNotNull(type);
    Assert.isNotNull(anURI);
    this.type = type;
    location = anURI;
  }
  
  protected String getFullyQualifiedName()
  {
    return type.getName() + "@" + location;
  }
  
  protected int namespaceCompareTo(BaseID o)
  {
    if ((o instanceof ServiceID))
    {
      ServiceID other = (ServiceID)o;
      String typename = other.getFullyQualifiedName();
      return getFullyQualifiedName().compareTo(typename);
    }
    return 1;
  }
  
  protected boolean namespaceEquals(BaseID o)
  {
    if (o == null) {
      return false;
    }
    if ((o instanceof ServiceID))
    {
      ServiceID other = (ServiceID)o;
      if (other.getName().equals(getName())) {
        return true;
      }
    }
    return false;
  }
  
  protected String namespaceGetName()
  {
    return getFullyQualifiedName();
  }
  
  protected int namespaceHashCode()
  {
    return getFullyQualifiedName().hashCode();
  }
  
  public String getServiceType()
  {
    return type.getName();
  }
  
  public IServiceTypeID getServiceTypeID()
  {
    return type;
  }
  
  public String getServiceName()
  {
    return serviceInfo.getServiceName();
  }
  
  public String toString()
  {
    StringBuffer buf = new StringBuffer("ServiceID[");
    buf
      .append("type=").append(type).append(";location=").append(getLocation()).append(
      ";full=" + getFullyQualifiedName()).append("]");
    return buf.toString();
  }
  
  public URI getLocation()
  {
    return location;
  }
  
  public IServiceInfo getServiceInfo()
  {
    return serviceInfo;
  }
  
  public void setServiceInfo(IServiceInfo serviceInfo)
  {
    this.serviceInfo = serviceInfo;
  }
  
  public int hashCode()
  {
    int prime = 31;
    int result = super.hashCode();
    result = 31 * result + (
      location == null ? 0 : location.hashCode());
    result = 31 * result + (type == null ? 0 : type.hashCode());
    return result;
  }
  
  public boolean equals(Object obj)
  {
    if (this == obj) {
      return true;
    }
    if (!super.equals(obj)) {
      return false;
    }
    if (getClass() != obj.getClass()) {
      return false;
    }
    ServiceID other = (ServiceID)obj;
    if (location == null)
    {
      if (location != null) {
        return false;
      }
    }
    else if (!location.equals(location)) {
      return false;
    }
    if (type == null)
    {
      if (type != null) {
        return false;
      }
    }
    else if (!type.equals(type)) {
      return false;
    }
    return true;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ecf.discovery.identity.ServiceID
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ecf.discovery.identity;

import org.eclipse.core.runtime.AssertionFailedException;
import org.eclipse.ecf.core.identity.IDCreateException;
import org.eclipse.ecf.core.identity.IDFactory;
import org.eclipse.ecf.core.identity.IIDFactory;
import org.eclipse.ecf.core.identity.Namespace;

public class ServiceIDFactory
  implements IServiceIDFactory
{
  private static final IServiceIDFactory instance = new ServiceIDFactory();
  
  public static IServiceIDFactory getDefault()
  {
    return instance;
  }
  
  public IServiceTypeID createServiceTypeID(Namespace namespace, String serviceType)
  {
    return createServiceTypeID(namespace, new String[] { serviceType });
  }
  
  public IServiceTypeID createServiceTypeID(Namespace namespace, String[] serviceType)
  {
    return createServiceTypeID(namespace, serviceType, 
      IServiceTypeID.DEFAULT_SCOPE, IServiceTypeID.DEFAULT_PROTO, 
      "iana");
  }
  
  public IServiceTypeID createServiceTypeID(Namespace namespace, String[] serviceType, String[] scopes, String[] protocols, String namingAuthority)
  {
    try
    {
      IServiceTypeID aServiceType = new ServiceTypeID(namespace, 
        serviceType, scopes, protocols, namingAuthority);
      return (IServiceTypeID)IDFactory.getDefault().createID(namespace, 
        new Object[] { aServiceType });
    }
    catch (AssertionFailedException e)
    {
      throw new IDCreateException("service type id creation failed", e);
    }
  }
  
  public IServiceTypeID createServiceTypeID(Namespace namespace, String[] serviceType, String[] protocols)
  {
    return createServiceTypeID(namespace, serviceType, 
      IServiceTypeID.DEFAULT_SCOPE, protocols, 
      "iana");
  }
  
  public IServiceTypeID createServiceTypeID(Namespace namespace, IServiceTypeID aServiceTypeId)
  {
    return (IServiceTypeID)IDFactory.getDefault().createID(namespace, 
      new Object[] { aServiceTypeId });
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ecf.discovery.identity.ServiceIDFactory
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ecf.discovery.identity;

import java.util.Arrays;
import java.util.List;
import org.eclipse.core.runtime.Assert;
import org.eclipse.ecf.core.identity.BaseID;
import org.eclipse.ecf.core.identity.IDCreateException;
import org.eclipse.ecf.core.identity.Namespace;
import org.eclipse.ecf.core.util.StringUtils;

public class ServiceTypeID
  extends BaseID
  implements IServiceTypeID
{
  private static final long serialVersionUID = 2546630451825262145L;
  protected static final String DELIM = "._";
  protected String typeName = "";
  protected String namingAuthority;
  protected String[] protocols;
  protected String[] scopes;
  protected String[] services;
  
  protected ServiceTypeID(Namespace namespace)
  {
    super(namespace);
  }
  
  protected ServiceTypeID(Namespace namespace, String[] services, String[] scopes, String[] protocols, String namingAuthority)
  {
    super(namespace);
    Assert.isNotNull(services);
    this.services = services;
    Assert.isNotNull(scopes);
    this.scopes = scopes;
    Assert.isNotNull(protocols);
    this.protocols = protocols;
    Assert.isNotNull(namingAuthority);
    this.namingAuthority = namingAuthority;
    createType();
    Assert.isNotNull(typeName);
  }
  
  protected ServiceTypeID(Namespace ns, IServiceTypeID id)
  {
    this(ns, id.getServices(), id.getScopes(), id.getProtocols(), id.getNamingAuthority());
  }
  
  public ServiceTypeID(Namespace namespace, String aType)
  {
    this(namespace);
    if (aType != null) {
      try
      {
        aType = aType.trim();
        if (aType.endsWith(".")) {
          aType = aType.substring(0, aType.length() - 1);
        }
        int lastDot = aType.lastIndexOf('.');
        int lastUnderscore = aType.lastIndexOf('_');
        if (lastDot + 1 != lastUnderscore) {
          aType = aType + "._" + "ia
1 2

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd