Search in sources :

Example 26 with Namespace

use of org.eclipse.ecf.core.identity.Namespace in project ecf by eclipse.

the class ServiceIDTest method testServiceIDFactory2.

/*
	 * org.eclipse.ecf.discovery.identity.IServiceIDFactory.createServiceID(Namespace, String, String)
	 */
public void testServiceIDFactory2() {
    Namespace namespaceByName = IDFactory.getDefault().getNamespaceByName(namespace);
    ServiceTypeID serviceTypeID = new ServiceTypeID(new TestNamespace(), "_service._ecf._foo._bar._tcp.ecf.eclipse.org._IANA");
    IServiceTypeID aServiceTypeID = ServiceIDFactory.getDefault().createServiceTypeID(namespaceByName, serviceTypeID);
    assertNotNull(aServiceTypeID);
    // members should be the same
    assertEquals(aServiceTypeID.getNamingAuthority(), serviceTypeID.getNamingAuthority());
    assertTrue(Arrays.equals(aServiceTypeID.getServices(), serviceTypeID.getServices()));
    assertTrue(Arrays.equals(aServiceTypeID.getScopes(), serviceTypeID.getScopes()));
    assertTrue(Arrays.equals(aServiceTypeID.getProtocols(), serviceTypeID.getProtocols()));
    assertSame(namespaceByName, aServiceTypeID.getNamespace());
}
Also used : IServiceTypeID(org.eclipse.ecf.discovery.identity.IServiceTypeID) ServiceTypeID(org.eclipse.ecf.discovery.identity.ServiceTypeID) IServiceTypeID(org.eclipse.ecf.discovery.identity.IServiceTypeID) Namespace(org.eclipse.ecf.core.identity.Namespace)

Example 27 with Namespace

use of org.eclipse.ecf.core.identity.Namespace in project ecf by eclipse.

the class ServiceIDTest method testServiceIDFactoryDefaults.

/*
	 * org.eclipse.ecf.discovery.identity.IServiceIDFactory.createServiceID(Namespace, String[], String)
	 */
public void testServiceIDFactoryDefaults() {
    Namespace namespaceByName = IDFactory.getDefault().getNamespaceByName(namespace);
    IServiceTypeID serviceType = ServiceIDFactory.getDefault().createServiceTypeID(namespaceByName, services, protocols);
    assertNotNull(serviceType);
    assertTrue(Arrays.equals(services, serviceType.getServices()));
    assertEquals(IServiceTypeID.DEFAULT_NA, serviceType.getNamingAuthority());
    assertTrue(Arrays.equals(IServiceTypeID.DEFAULT_SCOPE, serviceType.getScopes()));
    assertTrue(Arrays.equals(protocols, serviceType.getProtocols()));
}
Also used : IServiceTypeID(org.eclipse.ecf.discovery.identity.IServiceTypeID) Namespace(org.eclipse.ecf.core.identity.Namespace)

Example 28 with Namespace

use of org.eclipse.ecf.core.identity.Namespace in project ecf by eclipse.

the class Activator method start.

/*
	 * (non-Javadoc)
	 * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
	 */
public void start(BundleContext context) throws Exception {
    this.context = context;
    plugin = this;
    SafeRunner.run(new ExtensionRegistryRunnable(this.context) {

        protected void runWithoutRegistry() throws Exception {
            // If we don't have a registry, then register trivial namespace
            Activator.this.context.registerService(Namespace.class, new TrivialNamespace(TrivialNamespace.NAME), null);
            // And create and register ContainerTypeDescription
            Activator.this.context.registerService(ContainerTypeDescription.class, new ContainerTypeDescription(TrivialContainerInstantiator.NAME, (IContainerInstantiator) new TrivialContainerInstantiator()), null);
        }
    });
}
Also used : TrivialNamespace(org.eclipse.ecf.examples.provider.trivial.identity.TrivialNamespace) ContainerTypeDescription(org.eclipse.ecf.core.ContainerTypeDescription) ExtensionRegistryRunnable(org.eclipse.ecf.core.util.ExtensionRegistryRunnable) TrivialContainerInstantiator(org.eclipse.ecf.internal.examples.provider.trivial.container.TrivialContainerInstantiator) TrivialNamespace(org.eclipse.ecf.examples.provider.trivial.identity.TrivialNamespace) Namespace(org.eclipse.ecf.core.identity.Namespace)

Example 29 with Namespace

use of org.eclipse.ecf.core.identity.Namespace in project ecf by eclipse.

the class Activator method start.

public void start(final BundleContext ctxt) throws Exception {
    this.context = ctxt;
    SafeRunner.run(new ExtensionRegistryRunnable(this.context) {

        protected void runWithoutRegistry() throws Exception {
            // $NON-NLS-1$
            ctxt.registerService(Namespace.class, new RemoteServiceNamespace(org.eclipse.ecf.provider.remoteservice.generic.RemoteServiceNamespace.NAME, "Generic remote service namespace"), null);
            IAdapterManager am = getAdapterManager(ctxt);
            if (am != null) {
                rscAdapterFactories = new ArrayList();
                IAdapterFactory af = new RemoteServiceContainerAdapterFactory();
                am.registerAdapters(af, org.eclipse.ecf.provider.generic.SSLServerSOContainer.class);
                rscAdapterFactories.add(af);
                af = new RemoteServiceContainerAdapterFactory();
                am.registerAdapters(af, org.eclipse.ecf.provider.generic.TCPServerSOContainer.class);
                rscAdapterFactories.add(af);
                af = new RemoteServiceContainerAdapterFactory();
                am.registerAdapters(af, org.eclipse.ecf.provider.generic.SSLClientSOContainer.class);
                rscAdapterFactories.add(af);
                af = new RemoteServiceContainerAdapterFactory();
                am.registerAdapters(af, org.eclipse.ecf.provider.generic.TCPClientSOContainer.class);
                rscAdapterFactories.add(af);
            }
        }
    });
}
Also used : RemoteServiceContainerAdapterFactory(org.eclipse.ecf.provider.remoteservice.generic.RemoteServiceContainerAdapterFactory) RemoteServiceNamespace(org.eclipse.ecf.provider.remoteservice.generic.RemoteServiceNamespace) Namespace(org.eclipse.ecf.core.identity.Namespace) RemoteServiceNamespace(org.eclipse.ecf.provider.remoteservice.generic.RemoteServiceNamespace)

Example 30 with Namespace

use of org.eclipse.ecf.core.identity.Namespace in project ecf by eclipse.

the class JSLPTestComparator method compare.

/* (non-Javadoc)
	 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
	 */
public int compare(final Object arg0, final Object arg1) {
    if (arg0 instanceof IServiceInfo && arg1 instanceof IServiceInfo) {
        final IServiceInfo first = (IServiceInfo) arg0;
        final IServiceInfo second = (IServiceInfo) arg1;
        final IServiceID firstID = first.getServiceID();
        final IServiceID secondID = second.getServiceID();
        final IServiceTypeID firstTypeID = firstID.getServiceTypeID();
        final IServiceTypeID secondTypeID = secondID.getServiceTypeID();
        final boolean protocolsSame = Arrays.equals(firstTypeID.getProtocols(), secondTypeID.getProtocols());
        final boolean weightSame = first.getWeight() == second.getWeight();
        final boolean prioSame = first.getPriority() == second.getPriority();
        final String firstName = firstID.getName();
        final String secondName = secondID.getName();
        final boolean nameSame = firstName.equals(secondName);
        final String[] firstServices = firstTypeID.getServices();
        final String[] secondServices = secondTypeID.getServices();
        final boolean serviceSame = Arrays.equals(firstServices, secondServices);
        final Namespace firstNamespace = firstID.getNamespace();
        final Namespace secondNamespace = secondID.getNamespace();
        final boolean namespaceSame = firstNamespace.equals(secondNamespace);
        final String firstNA = firstTypeID.getNamingAuthority();
        final String secondsSA = secondTypeID.getNamingAuthority();
        final boolean naSame = firstNA.equals(secondsSA);
        final URI firstLocation = first.getLocation();
        final URI secondLocation = second.getLocation();
        final boolean locationSame = firstLocation.equals(secondLocation);
        final boolean scopesSame = Arrays.equals(firstTypeID.getScopes(), secondTypeID.getScopes());
        final IServiceProperties firstProperty = first.getServiceProperties();
        final IServiceProperties secondProperty = second.getServiceProperties();
        final boolean propertySame = firstProperty.equals(secondProperty);
        final boolean result = protocolsSame && weightSame && prioSame && nameSame && namespaceSame && serviceSame && naSame && locationSame && scopesSame && propertySame;
        if (result == true) {
            return 0;
        }
    }
    return -1;
}
Also used : IServiceTypeID(org.eclipse.ecf.discovery.identity.IServiceTypeID) IServiceInfo(org.eclipse.ecf.discovery.IServiceInfo) IServiceID(org.eclipse.ecf.discovery.identity.IServiceID) IServiceProperties(org.eclipse.ecf.discovery.IServiceProperties) URI(java.net.URI) 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