Search in sources :

Example 31 with Namespace

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

Example 32 with Namespace

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));
}
Also used : 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)

Example 33 with Namespace

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

Example 34 with Namespace

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

Example 35 with Namespace

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

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