Search in sources :

Example 6 with IServiceID

use of org.eclipse.ecf.discovery.identity.IServiceID 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 7 with IServiceID

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

the class DnsSdNamespace method createInstance.

/* (non-Javadoc)
	 * @see org.eclipse.ecf.core.identity.Namespace#createInstance(java.lang.Object[])
	 */
public ID createInstance(Object[] parameters) throws IDCreateException {
    if (parameters != null && parameters.length == 1 && parameters[0] instanceof String) {
        String str = (String) parameters[0];
        return new DnsSdServiceTypeID(this, str);
    } else if (parameters != null && parameters.length == 1 && parameters[0] instanceof IServiceTypeID) {
        IServiceTypeID serviceTypeID = (IServiceTypeID) parameters[0];
        return new DnsSdServiceTypeID(this, serviceTypeID);
    } else if (parameters != null && parameters.length == 1 && parameters[0] instanceof IServiceID) {
        IServiceID serviceID = (IServiceID) parameters[0];
        return new DnsSdServiceTypeID(this, serviceID.getServiceTypeID());
    } else if (parameters != null && parameters.length == 1 && parameters[0] instanceof StringID) {
        StringID stringID = (StringID) parameters[0];
        return new DnsSdServiceTypeID(this, stringID.getName());
    } else if (parameters != null && parameters.length == 2 && parameters[0] instanceof IServiceTypeID && parameters[1] instanceof URI) {
        IServiceTypeID serviceTypeID = (IServiceTypeID) parameters[0];
        URI uri = (URI) parameters[1];
        return new DnsSdServiceID(this, new DnsSdServiceTypeID(this, serviceTypeID), uri);
    } else if (parameters != null && parameters.length == 2 && parameters[0] instanceof String && parameters[1] instanceof URI) {
        String serviceType = (String) parameters[0];
        URI uri = (URI) parameters[1];
        return new DnsSdServiceID(this, new DnsSdServiceTypeID(this, serviceType), uri);
    } else {
        throw new IDCreateException(Messages.DnsSdNamespace_Wrong_Parameters);
    }
}
Also used : IServiceTypeID(org.eclipse.ecf.discovery.identity.IServiceTypeID) StringID(org.eclipse.ecf.core.identity.StringID) IDCreateException(org.eclipse.ecf.core.identity.IDCreateException) IServiceID(org.eclipse.ecf.discovery.identity.IServiceID) URI(java.net.URI)

Example 8 with IServiceID

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

the class EndpointDiscoveryView method createEndpointDescriptionNode.

protected EndpointNode createEndpointDescriptionNode(EndpointDescription ed) {
    EndpointNode edo = new EndpointNode(ed, findImportReference(ed));
    // Interfaces
    EndpointInterfacesNode ein = new EndpointInterfacesNode();
    for (String intf : ed.getInterfaces()) ein.addChild(new EndpointPackageVersionNode(EndpointNode.getPackageName(intf)));
    edo.addChild(ein);
    // Async Interfaces (if present)
    List<String> aintfs = ed.getAsyncInterfaces();
    if (aintfs.size() > 0) {
        EndpointAsyncInterfacesNode ain = new EndpointAsyncInterfacesNode();
        for (String intf : ed.getAsyncInterfaces()) ain.addChild(new EndpointPackageVersionNode(EndpointNode.getPackageName(intf)));
        edo.addChild(ain);
    }
    // ID
    edo.addChild(new EndpointIDNode());
    // Remote Service Host
    EndpointHostGroupNode idp = new EndpointHostGroupNode(Messages.EndpointDiscoveryView_REMOTE_HOST_NAME);
    // Host children
    idp.addChild(new EndpointNamespaceNode());
    idp.addChild(new EndpointRemoteServiceIDNode());
    org.eclipse.ecf.core.identity.ID connectTarget = ed.getConnectTargetID();
    if (connectTarget != null)
        idp.addChild(new EndpointConnectTargetIDNode());
    idp.addChild(new EndpointServiceIDNode());
    idp.addChild(new EndpointIntentsNode());
    idp.addChild(new EndpointConfigTypesNode());
    idp.addChild(new EndpointFrameworkIDNode());
    idp.addChild(new EndpointTimestampNode());
    String filter = ed.getRemoteServiceFilter();
    if (filter != null)
        idp.addChild(new EndpointRemoteServiceFilterNode());
    edo.addChild(idp);
    IEndpointDescriptionLocator locator = discovery.getEndpointDescriptionLocator();
    IServiceID serviceID = (locator == null) ? null : locator.getNetworkDiscoveredServiceID(ed);
    if (serviceID != null)
        edo.addChild(new EndpointDiscoveryGroupNode(Messages.EndpointDiscoveryView_DISCOVERY_GROUP_NAME, serviceID));
    return edo;
}
Also used : EndpointIntentsNode(org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointIntentsNode) EndpointNode(org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointNode) AbstractEndpointNode(org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.AbstractEndpointNode) EndpointDiscoveryGroupNode(org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointDiscoveryGroupNode) EndpointServiceIDNode(org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointServiceIDNode) EndpointConfigTypesNode(org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointConfigTypesNode) EndpointInterfacesNode(org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointInterfacesNode) EndpointIDNode(org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointIDNode) EndpointTimestampNode(org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointTimestampNode) EndpointRemoteServiceFilterNode(org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointRemoteServiceFilterNode) IEndpointDescriptionLocator(org.eclipse.ecf.osgi.services.remoteserviceadmin.IEndpointDescriptionLocator) EndpointHostGroupNode(org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointHostGroupNode) EndpointRemoteServiceIDNode(org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointRemoteServiceIDNode) EndpointPackageVersionNode(org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointPackageVersionNode) EndpointConnectTargetIDNode(org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointConnectTargetIDNode) EndpointNamespaceNode(org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointNamespaceNode) IServiceID(org.eclipse.ecf.discovery.identity.IServiceID) EndpointAsyncInterfacesNode(org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointAsyncInterfacesNode) EndpointFrameworkIDNode(org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointFrameworkIDNode)

Aggregations

IServiceID (org.eclipse.ecf.discovery.identity.IServiceID)8 IServiceInfo (org.eclipse.ecf.discovery.IServiceInfo)6 IServiceTypeID (org.eclipse.ecf.discovery.identity.IServiceTypeID)4 URI (java.net.URI)3 ServiceURL (ch.ethz.iks.slp.ServiceURL)2 ArrayList (java.util.ArrayList)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 IDCreateException (org.eclipse.ecf.core.identity.IDCreateException)1 Namespace (org.eclipse.ecf.core.identity.Namespace)1 StringID (org.eclipse.ecf.core.identity.StringID)1 IServiceProperties (org.eclipse.ecf.discovery.IServiceProperties)1 IEndpointDescriptionLocator (org.eclipse.ecf.osgi.services.remoteserviceadmin.IEndpointDescriptionLocator)1 AbstractEndpointNode (org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.AbstractEndpointNode)1 EndpointAsyncInterfacesNode (org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointAsyncInterfacesNode)1 EndpointConfigTypesNode (org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointConfigTypesNode)1 EndpointConnectTargetIDNode (org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointConnectTargetIDNode)1 EndpointDiscoveryGroupNode (org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointDiscoveryGroupNode)1 EndpointFrameworkIDNode (org.eclipse.ecf.remoteserviceadmin.ui.endpoint.model.EndpointFrameworkIDNode)1