Search in sources :

Example 1 with Namespace

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));
}
Also used : ResolverConfig(org.xbill.DNS.ResolverConfig) ContainerConnectException(org.eclipse.ecf.core.ContainerConnectException) UnknownHostException(java.net.UnknownHostException) IDCreateException(org.eclipse.ecf.core.identity.IDCreateException) ContainerConnectedEvent(org.eclipse.ecf.core.events.ContainerConnectedEvent) ContainerConnectingEvent(org.eclipse.ecf.core.events.ContainerConnectingEvent) SimpleResolver(org.xbill.DNS.SimpleResolver) Namespace(org.eclipse.ecf.core.identity.Namespace) Name(org.xbill.DNS.Name)

Example 2 with Namespace

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);
}
Also used : IRemoteServiceClientContainerAdapter(org.eclipse.ecf.remoteservice.client.IRemoteServiceClientContainerAdapter) IContainer(org.eclipse.ecf.core.IContainer) Namespace(org.eclipse.ecf.core.identity.Namespace)

Example 3 with 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);
}
Also used : Namespace(org.eclipse.ecf.core.identity.Namespace)

Example 4 with Namespace

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);
}
Also used : Namespace(org.eclipse.ecf.core.identity.Namespace)

Example 5 with Namespace

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);
        }
    });
}
Also used : ContainerInstantiator(org.eclipse.ecf.provider.jmdns.container.ContainerInstantiator) Properties(java.util.Properties) JMDNSNamespace(org.eclipse.ecf.provider.jmdns.identity.JMDNSNamespace) IDCreateException(org.eclipse.ecf.core.identity.IDCreateException) Namespace(org.eclipse.ecf.core.identity.Namespace) JMDNSNamespace(org.eclipse.ecf.provider.jmdns.identity.JMDNSNamespace)

Aggregations

Namespace (org.eclipse.ecf.core.identity.Namespace)51 ID (org.eclipse.ecf.core.identity.ID)10 IServiceTypeID (org.eclipse.ecf.discovery.identity.IServiceTypeID)10 IDCreateException (org.eclipse.ecf.core.identity.IDCreateException)9 ContainerConnectException (org.eclipse.ecf.core.ContainerConnectException)5 JSLPNamespace (org.eclipse.ecf.provider.jslp.identity.JSLPNamespace)4 GUID (org.eclipse.ecf.core.identity.GUID)3 UnknownHostException (java.net.UnknownHostException)2 UUID (java.util.UUID)2 IContainer (org.eclipse.ecf.core.IContainer)2 ContainerConnectedEvent (org.eclipse.ecf.core.events.ContainerConnectedEvent)2 ContainerConnectingEvent (org.eclipse.ecf.core.events.ContainerConnectingEvent)2 StringID (org.eclipse.ecf.core.identity.StringID)2 IConnectContext (org.eclipse.ecf.core.security.IConnectContext)2 ECFException (org.eclipse.ecf.core.util.ECFException)2 ServiceTypeID (org.eclipse.ecf.discovery.identity.ServiceTypeID)2 IPresenceContainerAdapter (org.eclipse.ecf.presence.IPresenceContainerAdapter)2 SimpleResolver (org.xbill.DNS.SimpleResolver)2 URI (java.net.URI)1 Map (java.util.Map)1