Search in sources :

Example 16 with IServiceTypeID

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

the class JSLPServiceInfo method getServiceURL.

public ServiceURL getServiceURL() throws ServiceLocationException {
    final IServiceTypeID stid = getServiceID().getServiceTypeID();
    final URI location = getLocation();
    final String scheme = location.getScheme();
    final String authority = location.getAuthority();
    // $NON-NLS-1$
    final String path = location.getPath() == null ? "" : location.getPath();
    // $NON-NLS-1$ //$NON-NLS-2$
    return new ServiceURL(stid.getInternal() + "://" + scheme + "://" + authority + path, ServiceURL.LIFETIME_PERMANENT);
}
Also used : IServiceTypeID(org.eclipse.ecf.discovery.identity.IServiceTypeID) ServiceURL(ch.ethz.iks.slp.ServiceURL) URI(java.net.URI)

Example 17 with IServiceTypeID

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

the class JSLPTestComparator method compare.

/* (non-Javadoc)
	 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
	 */
public int compare(final Object arg0, final Object arg1) {
    if (arg0 instanceof IServiceInfo && arg1 instanceof IServiceInfo) {
        final IServiceInfo first = (IServiceInfo) arg0;
        final IServiceInfo second = (IServiceInfo) arg1;
        final IServiceID firstID = first.getServiceID();
        final IServiceID secondID = second.getServiceID();
        final IServiceTypeID firstTypeID = firstID.getServiceTypeID();
        final IServiceTypeID secondTypeID = secondID.getServiceTypeID();
        final boolean protocolsSame = Arrays.equals(firstTypeID.getProtocols(), secondTypeID.getProtocols());
        final boolean weightSame = first.getWeight() == second.getWeight();
        final boolean prioSame = first.getPriority() == second.getPriority();
        final String firstName = firstID.getName();
        final String secondName = secondID.getName();
        final boolean nameSame = firstName.equals(secondName);
        final String[] firstServices = firstTypeID.getServices();
        final String[] secondServices = secondTypeID.getServices();
        final boolean serviceSame = Arrays.equals(firstServices, secondServices);
        final Namespace firstNamespace = firstID.getNamespace();
        final Namespace secondNamespace = secondID.getNamespace();
        final boolean namespaceSame = firstNamespace.equals(secondNamespace);
        final String firstNA = firstTypeID.getNamingAuthority();
        final String secondsSA = secondTypeID.getNamingAuthority();
        final boolean naSame = firstNA.equals(secondsSA);
        final URI firstLocation = first.getLocation();
        final URI secondLocation = second.getLocation();
        final boolean locationSame = firstLocation.equals(secondLocation);
        final boolean scopesSame = Arrays.equals(firstTypeID.getScopes(), secondTypeID.getScopes());
        final IServiceProperties firstProperty = first.getServiceProperties();
        final IServiceProperties secondProperty = second.getServiceProperties();
        final boolean propertySame = firstProperty.equals(secondProperty);
        final boolean result = protocolsSame && weightSame && prioSame && nameSame && namespaceSame && serviceSame && naSame && locationSame && scopesSame && propertySame;
        if (result == true) {
            return 0;
        }
    }
    return -1;
}
Also used : IServiceTypeID(org.eclipse.ecf.discovery.identity.IServiceTypeID) IServiceInfo(org.eclipse.ecf.discovery.IServiceInfo) IServiceID(org.eclipse.ecf.discovery.identity.IServiceID) IServiceProperties(org.eclipse.ecf.discovery.IServiceProperties) URI(java.net.URI) Namespace(org.eclipse.ecf.core.identity.Namespace)

Example 18 with IServiceTypeID

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

the class JSLPServiceIDTest method testCreateByjSLPAndRemoveServicePrefixWithServiceService.

/* (non-Javadoc)
	 * @see org.eclipse.ecf.tests.discovery.identity.ServiceIDTest#testRemoveServicePrefixWithServiceService()
	 * 
	 * test from jSLP -> ECF discovery which needs to remove the first occurrence of "service:"
	 */
public void testCreateByjSLPAndRemoveServicePrefixWithServiceService() throws ServiceLocationException {
    final String internalRep = "service:service.eclipse:foo:bar";
    final ServiceURL sUrl = new ServiceURL(internalRep + "://localhost:1234/a/path/to/something", ServiceURL.LIFETIME_PERMANENT);
    final IServiceInfo serviceInfo = new JSLPServiceInfo(DiscoveryTestHelper.SERVICENAME, new ServiceURLAdapter(sUrl), DiscoveryTestHelper.PRIORITY, DiscoveryTestHelper.WEIGHT, new ServicePropertiesAdapter(new ArrayList()));
    assertEquals(serviceInfo.getPriority(), DiscoveryTestHelper.PRIORITY);
    assertEquals(serviceInfo.getWeight(), DiscoveryTestHelper.WEIGHT);
    final IServiceID sid = serviceInfo.getServiceID();
    assertEquals(serviceInfo.getServiceName(), DiscoveryTestHelper.SERVICENAME);
    final IServiceTypeID stid = sid.getServiceTypeID();
    assertEquals(internalRep, stid.getInternal());
    assertEquals("_service._foo._bar._" + IServiceTypeID.DEFAULT_PROTO[0] + "." + IServiceTypeID.DEFAULT_SCOPE[0] + "._eclipse", stid.getName());
    assertEquals("eclipse", stid.getNamingAuthority());
    assertTrue(Arrays.equals(new String[] { "service", "foo", "bar" }, stid.getServices()));
    assertTrue(Arrays.equals(IServiceTypeID.DEFAULT_SCOPE, stid.getScopes()));
    assertTrue(Arrays.equals(IServiceTypeID.DEFAULT_PROTO, stid.getProtocols()));
}
Also used : IServiceTypeID(org.eclipse.ecf.discovery.identity.IServiceTypeID) ServiceURLAdapter(org.eclipse.ecf.internal.provider.jslp.ServiceURLAdapter) JSLPServiceInfo(org.eclipse.ecf.provider.jslp.container.JSLPServiceInfo) ServicePropertiesAdapter(org.eclipse.ecf.internal.provider.jslp.ServicePropertiesAdapter) IServiceInfo(org.eclipse.ecf.discovery.IServiceInfo) IServiceID(org.eclipse.ecf.discovery.identity.IServiceID) ArrayList(java.util.ArrayList) ServiceURL(ch.ethz.iks.slp.ServiceURL)

Example 19 with IServiceTypeID

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

the class JSLPServiceIDTest method testjSLPDefaultsToECF2.

public void testjSLPDefaultsToECF2() {
    Namespace namespaceByName = IDFactory.getDefault().getNamespaceByName(namespace);
    IServiceTypeID stid = ServiceIDFactory.getDefault().createServiceTypeID(namespaceByName, DiscoveryTestHelper.SERVICES, DiscoveryTestHelper.PROTOCOLS);
    assertNotNull(stid);
    assertEquals(IServiceTypeID.DEFAULT_NA, stid.getNamingAuthority());
    assertEquals("_ecf._junit._tests._someProtocol." + IServiceTypeID.DEFAULT_SCOPE[0] + "._" + IServiceTypeID.DEFAULT_NA, stid.getName());
}
Also used : IServiceTypeID(org.eclipse.ecf.discovery.identity.IServiceTypeID) JSLPNamespace(org.eclipse.ecf.provider.jslp.identity.JSLPNamespace) Namespace(org.eclipse.ecf.core.identity.Namespace)

Example 20 with IServiceTypeID

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

the class JSLPServiceIDTest method testCreateServiceTypeIDFromSLPStringWithDefaultNamingAuthority.

/* (non-Javadoc)
	 * @see org.eclipse.ecf.tests.discovery.identity.ServiceIDTest#testCreateServiceTypeIDFromInternalString()
	 */
public void testCreateServiceTypeIDFromSLPStringWithDefaultNamingAuthority() {
    final String internalRep = "service:foo.iana:bar";
    final IServiceTypeID stid = (IServiceTypeID) new JSLPNamespace().createInstance(new Object[] { internalRep });
    // the internalRep contains "iana" but getInternal may not!
    final int indexOf = stid.getInternal().toLowerCase().indexOf("iana");
    assertTrue(indexOf == -1);
    assertEquals(IServiceTypeID.DEFAULT_NA, stid.getNamingAuthority());
    assertNotSame(internalRep, stid.getName());
}
Also used : IServiceTypeID(org.eclipse.ecf.discovery.identity.IServiceTypeID) JSLPNamespace(org.eclipse.ecf.provider.jslp.identity.JSLPNamespace)

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