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()));
}
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);
}
}
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;
}
Aggregations