use of org.eclipse.ecf.core.identity.Namespace in project ecf by eclipse.
the class DnsSdDiscoveryLocator method connect.
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ecf.core.IContainer#connect(org.eclipse.ecf.core.identity.ID,
* org.eclipse.ecf.core.security.IConnectContext)
*/
public void connect(ID aTargetID, IConnectContext connectContext) throws ContainerConnectException {
// connect can only be called once
if (targetID != null || getConfig() == null) {
throw new ContainerConnectException(Messages.DnsSdDiscoveryLocator_Container_Already_Connected);
}
// fall back to the search path as last resort
if (aTargetID == null || !(aTargetID instanceof DnsSdServiceTypeID)) {
ResolverConfig config = new ResolverConfig();
Name[] searchPaths = config.searchPath();
if (searchPaths != null && searchPaths.length > 0) {
targetID = new DnsSdServiceTypeID();
targetID.setSearchPath(searchPaths);
} else {
throw new ContainerConnectException(Messages.DnsSdDiscoveryLocator_No_Target_ID);
}
} 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();
} catch (UnknownHostException e) {
throw new ContainerConnectException(e);
}
}
// read browsing domains for the given targetID/searchpath and merge with existing
targetID.addSearchPath(getBrowsingDomains(targetID));
// 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 RestContainerTest method testGetRemoteServiceNamespace.
public void testGetRemoteServiceNamespace() throws Exception {
IContainer container = createRestContainer(RestConstants.TEST_DE_TARGET);
IRemoteServiceClientContainerAdapter adapter = getRemoteServiceClientContainerAdapter(container);
assertNotNull(adapter);
Namespace namespace = adapter.getRemoteServiceNamespace();
assertNotNull(namespace);
}
use of org.eclipse.ecf.core.identity.Namespace in project ecf by eclipse.
the class AbstractConcatConsumerTestCase method testGetNamespace.
public void testGetNamespace() throws Exception {
Namespace ns = rsContainer.getContainer().getConnectNamespace();
assertNotNull(ns);
}
use of org.eclipse.ecf.core.identity.Namespace in project ecf by eclipse.
the class AbstractConcatConsumerTestCase method testGetRSNamespace.
public void testGetRSNamespace() throws Exception {
Namespace ns = rsContainer.getContainerAdapter().getRemoteServiceNamespace();
assertNotNull(ns);
}
use of org.eclipse.ecf.core.identity.Namespace in project ecf by eclipse.
the class JMDNSPlugin method start.
/**
* This method is called upon plug-in activation
*/
public void start(final BundleContext ctxt) throws Exception {
this.context = ctxt;
final Properties props = new Properties();
props.put(IDiscoveryService.CONTAINER_NAME, NAME);
props.put(Constants.SERVICE_RANKING, new Integer(750));
String[] clazzes = new String[] { IDiscoveryService.class.getName(), IDiscoveryLocator.class.getName(), IDiscoveryAdvertiser.class.getName() };
serviceRegistration = context.registerService(clazzes, serviceFactory, props);
SafeRunner.run(new ExtensionRegistryRunnable(ctxt) {
protected void runWithoutRegistry() throws Exception {
ctxt.registerService(Namespace.class, new JMDNSNamespace("JMDNS Discovery Namespace"), null);
ctxt.registerService(ContainerTypeDescription.class, new ContainerTypeDescription(ContainerInstantiator.JMDNS_CONTAINER_NAME, new ContainerInstantiator(), "JMDNS Discovery Container", true, false), null);
ctxt.registerService(ContainerTypeDescription.class, new ContainerTypeDescription(ContainerInstantiator.JMDNS_LOCATOR_NAME, new ContainerInstantiator(), "JMDNS Discovery Locator"), null);
ctxt.registerService(ContainerTypeDescription.class, new ContainerTypeDescription(ContainerInstantiator.JMDNS_ADVERTISER_NAME, new ContainerInstantiator(), "JMDNS Discovery Advertiser"), null);
}
});
}
Aggregations