Search in sources :

Example 26 with IServiceTypeID

use of org.eclipse.ecf.discovery.identity.IServiceTypeID in project ecf by eclipse.

the class AbstractDiscoveryContainerAdapter method getListeners.

// merges the allServiceListener with the serviceListeners for the given
// type
/**
 * Joins the {@link Collection} of {@link IServiceListener}s interested in
 * any {@link IServiceTypeID} with the {@link Collection} of the
 * {@link IServiceListener} registered for the given {@link IServiceTypeID}
 *
 * @param aServiceType
 *            The {@link IServiceTypeID} for which the
 *            {@link IServiceListener}s are returned
 * @return All {@link IServiceListener}s interested in the given
 *         {@link IServiceTypeID}
 */
protected Collection getListeners(IServiceTypeID aServiceType) {
    Assert.isNotNull(aServiceType);
    Collection listeners = new HashSet();
    synchronized (serviceListeners) {
        for (Iterator itr = serviceListeners.keySet().iterator(); itr.hasNext(); ) {
            final 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);
}
Also used : IServiceTypeID(org.eclipse.ecf.discovery.identity.IServiceTypeID)

Example 27 with IServiceTypeID

use of org.eclipse.ecf.discovery.identity.IServiceTypeID in project ecf by eclipse.

the class ServiceIDTest method testServiceTypeIDWithServiceTypeID.

/*
	 * use case: conversion from one IServiceTypeID to another (provider A -> provider B)
	 */
public void testServiceTypeIDWithServiceTypeID() {
    final IServiceTypeID aServiceTypeID = createIDFromStringWithEx("_service._ecf._foo._bar._tcp.ecf.eclipse.org._IANA");
    final IServiceTypeID stid = createIDFromServiceTypeID(aServiceTypeID);
    // this is the only differences
    assertNotSame(aServiceTypeID.getInternal(), stid.getInternal());
    // members should be the same
    assertTrue(aServiceTypeID.getNamingAuthority().equalsIgnoreCase(stid.getNamingAuthority()));
    assertTrue(Arrays.equals(aServiceTypeID.getServices(), stid.getServices()));
    assertTrue(Arrays.equals(aServiceTypeID.getScopes(), stid.getScopes()));
    assertTrue(Arrays.equals(aServiceTypeID.getProtocols(), stid.getProtocols()));
    // logically they should be the same
    assertTrue(aServiceTypeID.hashCode() == stid.hashCode());
    assertEquals(aServiceTypeID, stid);
    assertEquals(stid, aServiceTypeID);
    // should be possible to create a new instance from the string representation of the other
    createFromAnother(aServiceTypeID, stid);
    createFromAnother(stid, aServiceTypeID);
}
Also used : IServiceTypeID(org.eclipse.ecf.discovery.identity.IServiceTypeID)

Example 28 with IServiceTypeID

use of org.eclipse.ecf.discovery.identity.IServiceTypeID in project ecf by eclipse.

the class ServiceIDTest method testServiceTypeIDWithECFGenericString3.

/*
	 * use case: consumer instantiates a IServiceTypeID with the generic (ECF) String
	 */
public void testServiceTypeIDWithECFGenericString3() {
    final String serviceType = "_service._dns-srv._udp.ecf.eclipse.org._ECLIPSE";
    final IServiceTypeID stid = createIDFromString(serviceType);
    assertEquals(stid.getName(), serviceType);
    assertEquals(stid.getNamingAuthority(), "ECLIPSE");
    assertTrue(Arrays.equals(stid.getProtocols(), new String[] { "udp" }));
    assertTrue(Arrays.equals(stid.getScopes(), new String[] { "ecf.eclipse.org" }));
    assertTrue(Arrays.equals(stid.getServices(), new String[] { "service", "dns-srv" }));
}
Also used : IServiceTypeID(org.eclipse.ecf.discovery.identity.IServiceTypeID)

Example 29 with IServiceTypeID

use of org.eclipse.ecf.discovery.identity.IServiceTypeID in project ecf by eclipse.

the class ServiceIDTest method testServiceTypeIDWithECFGenericString.

/*
	 * use case: consumer instantiates a IServiceTypeID with the generic (ECF) String
	 */
public void testServiceTypeIDWithECFGenericString() {
    final IServiceTypeID stid = createIDFromString(DiscoveryTestHelper.SERVICE_TYPE);
    assertEquals(stid.getName(), DiscoveryTestHelper.SERVICE_TYPE);
    assertEquals(stid.getNamingAuthority(), DiscoveryTestHelper.NAMINGAUTHORITY);
    assertTrue(Arrays.equals(stid.getProtocols(), new String[] { DiscoveryTestHelper.PROTOCOL }));
    assertTrue(Arrays.equals(stid.getScopes(), new String[] { DiscoveryTestHelper.SCOPE }));
    assertTrue(Arrays.equals(stid.getServices(), DiscoveryTestHelper.SERVICES));
}
Also used : IServiceTypeID(org.eclipse.ecf.discovery.identity.IServiceTypeID)

Example 30 with IServiceTypeID

use of org.eclipse.ecf.discovery.identity.IServiceTypeID in project ecf by eclipse.

the class ServiceIDTest method testServiceIDFactory.

/*
	 * org.eclipse.ecf.discovery.identity.IServiceIDFactory.createServiceID(Namespace, String, String)
	 */
public void testServiceIDFactory() {
    Namespace namespaceByName = IDFactory.getDefault().getNamespaceByName(namespace);
    IServiceTypeID serviceType = ServiceIDFactory.getDefault().createServiceTypeID(namespaceByName, services, scopes, protocols, namingAuthority);
    assertNotNull(serviceType);
    assertEquals(namingAuthority, serviceType.getNamingAuthority());
    assertTrue(Arrays.equals(services, serviceType.getServices()));
    assertTrue(Arrays.equals(scopes, serviceType.getScopes()));
    assertTrue(Arrays.equals(protocols, serviceType.getProtocols()));
}
Also used : IServiceTypeID(org.eclipse.ecf.discovery.identity.IServiceTypeID) Namespace(org.eclipse.ecf.core.identity.Namespace)

Aggregations

IServiceTypeID (org.eclipse.ecf.discovery.identity.IServiceTypeID)35 Namespace (org.eclipse.ecf.core.identity.Namespace)10 URI (java.net.URI)9 IServiceInfo (org.eclipse.ecf.discovery.IServiceInfo)9 ServiceInfo (org.eclipse.ecf.discovery.ServiceInfo)5 JSLPNamespace (org.eclipse.ecf.provider.jslp.identity.JSLPNamespace)5 ArrayList (java.util.ArrayList)4 Properties (java.util.Properties)4 IServiceID (org.eclipse.ecf.discovery.identity.IServiceID)4 ServiceURL (ch.ethz.iks.slp.ServiceURL)3 ServiceProperties (org.eclipse.ecf.discovery.ServiceProperties)3 URISyntaxException (java.net.URISyntaxException)2 List (java.util.List)2 Map (java.util.Map)2 IServiceProperties (org.eclipse.ecf.discovery.IServiceProperties)2 ServiceTypeID (org.eclipse.ecf.discovery.identity.ServiceTypeID)2 ServicePropertiesAdapter (org.eclipse.ecf.internal.provider.jslp.ServicePropertiesAdapter)2 ServiceURLAdapter (org.eclipse.ecf.internal.provider.jslp.ServiceURLAdapter)2 JSLPServiceInfo (org.eclipse.ecf.provider.jslp.container.JSLPServiceInfo)2 PTRRecord (org.xbill.DNS.PTRRecord)2