use of org.eclipse.ecf.core.identity.Namespace 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());
}
use of org.eclipse.ecf.core.identity.Namespace in project ecf by eclipse.
the class DnsSdDiscoveryAdvertiser method connect.
/* (non-Javadoc)
* @see org.eclipse.ecf.provider.dnssd.DnsSdDiscoveryLocator#connect(org.eclipse.ecf.core.identity.ID, org.eclipse.ecf.core.security.IConnectContext)
*/
public void connect(final ID aTargetID, final IConnectContext connectContext) throws ContainerConnectException {
// $NON-NLS-1$ //$NON-NLS-2$
Trace.trace(Activator.PLUGIN_ID, DnsSdDebugOptions.METHODS_TRACING, this.getClass(), "connect(ID aTargetID, IConnectContext connectContext)", "connecting container");
// connect can only be called once
if (targetID != null || getConfig() == null) {
throw new ContainerConnectException(Messages.DnsSdDiscoveryAdvertiser_Container_Already_Connected);
}
// TODO convert non DnsSdServiceTypeIDs into DSTIDs
if (aTargetID == null) {
targetID = new DnsSdServiceTypeID();
} else {
final Namespace ns = getConnectNamespace();
try {
targetID = (DnsSdServiceTypeID) ns.createInstance(new Object[] { aTargetID });
} catch (IDCreateException e) {
throw new ContainerConnectException(e);
}
}
// instantiate a default resolver
if (resolver == null) {
try {
resolver = new SimpleResolver();
resolver.setTCP(true);
} catch (UnknownHostException e) {
throw new ContainerConnectException(e);
}
}
// done setting up this provider, send event
fireContainerEvent(new ContainerConnectingEvent(this.getID(), targetID, connectContext));
fireContainerEvent(new ContainerConnectedEvent(this.getID(), targetID));
}
use of org.eclipse.ecf.core.identity.Namespace in project ecf by eclipse.
the class AbstractRemoteServiceTest method testRemoteServiceNamespace.
public void testRemoteServiceNamespace() throws Exception {
final IRemoteServiceContainerAdapter[] adapters = getRemoteServiceAdapters();
assertNotNull(adapters);
for (int i = 0; i < adapters.length; i++) {
Namespace namespace = adapters[i].getRemoteServiceNamespace();
assertNotNull(namespace);
}
Thread.sleep(SLEEPTIME);
}
use of org.eclipse.ecf.core.identity.Namespace in project ecf by eclipse.
the class IServiceInfoServiceListener method convertToProviderSpecific.
/**
* Converts the generic (not discovery provider specific WRT
* IServiceID/IServiceTypeID) IServiceInfo into a discovery provider
* specific one. This is required so that discovery providers can correctly
* advertise services.
*/
private IServiceInfo convertToProviderSpecific(final IDiscoveryAdvertiser advertiser, final IServiceInfo genericInfo) {
// Convert similar to
// org.eclipse.ecf.provider.discovery.CompositeDiscoveryContainer.getServiceIDForDiscoveryContainer(IServiceID,
// IDiscoveryLocator)
final Namespace servicesNamespace = advertiser.getServicesNamespace();
final IServiceID genericServiceID = genericInfo.getServiceID();
final ServiceID specificServiceID = (ServiceID) servicesNamespace.createInstance(new Object[] { genericServiceID.getServiceTypeID().getName(), genericServiceID.getLocation() });
final IServiceTypeID serviceTypeID = specificServiceID.getServiceTypeID();
return new ServiceInfo(genericServiceID.getLocation(), genericInfo.getServiceName(), serviceTypeID, genericInfo.getPriority(), genericInfo.getWeight(), genericInfo.getServiceProperties(), genericInfo.getTTL());
}
use of org.eclipse.ecf.core.identity.Namespace in project ecf by eclipse.
the class AbstractHostContainerSelector method matchHostContainerID.
/**
* @param serviceReference serviceReference
* @param properties properties
* @param container container
* @return boolean true if match, false otherwise
* @since 2.0
*/
protected boolean matchHostContainerID(ServiceReference serviceReference, Map<String, Object> properties, IContainer container) {
ID containerID = container.getID();
// No match if the container has no ID
if (containerID == null)
return false;
// Then get containerid if specified directly by user in properties
ID requiredContainerID = (ID) properties.get(RemoteConstants.SERVICE_EXPORTED_CONTAINER_ID);
// If the CONTAINER_I
if (requiredContainerID != null) {
return requiredContainerID.equals(containerID);
}
// Else get the container factory arguments, create an ID from the
// arguments
// and check if the ID matches that
Namespace ns = containerID.getNamespace();
Object cid = properties.get(RemoteConstants.SERVICE_EXPORTED_CONTAINER_FACTORY_ARGS);
// If no arguments are present, then any container ID should match
if (cid == null)
return true;
ID cID = null;
if (cid instanceof ID) {
cID = (ID) cid;
} else if (cid instanceof String) {
cID = IDUtil.createID(ns, (String) cid);
} else if (cid instanceof Object[]) {
Object cido = ((Object[]) cid)[0];
cID = IDUtil.createID(ns, new Object[] { cido });
}
if (cID == null)
return true;
return containerID.equals(cID);
}
Aggregations