Search in sources :

Example 1 with JSLPNamespace

use of org.eclipse.ecf.provider.jslp.identity.JSLPNamespace 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(final BundleContext context) throws Exception {
    bundleContext = context;
    SafeRunner.run(new ExtensionRegistryRunnable(context) {

        protected void runWithoutRegistry() throws Exception {
            context.registerService(Namespace.class, new JSLPNamespace(), null);
            // $NON-NLS-1$//$NON-NLS-2$
            context.registerService(ContainerTypeDescription.class, new ContainerTypeDescription("ecf.discovery.jslp", new ContainerInstantiator(), "JSLP Discovery Container", true, false), null);
            // $NON-NLS-1$//$NON-NLS-2$
            context.registerService(ContainerTypeDescription.class, new ContainerTypeDescription("ecf.discovery.jslp.locator", new ContainerInstantiator(), "JSLP Discovery Locator Container", true, false), null);
            // $NON-NLS-1$//$NON-NLS-2$
            context.registerService(ContainerTypeDescription.class, new ContainerTypeDescription("ecf.discovery.jslp.advertiser", new ContainerInstantiator(), "JSLP Discovery Advertiser Container", true, false), null);
        }
    });
    // initially get the locator and add a life cycle listener
    locatorSt = new ServiceTracker(context, Locator.class.getName(), null);
    // initially get the advertiser and add a life cycle listener
    advertiserSt = new ServiceTracker(context, Advertiser.class.getName(), null);
    // register ourself as an OSGi service
    final Properties props = new Properties();
    props.put(IDiscoveryService.CONTAINER_NAME, JSLPDiscoveryContainer.NAME);
    props.put(Constants.SERVICE_RANKING, new Integer(500));
    String[] clazzes = new String[] { IDiscoveryService.class.getName(), IDiscoveryLocator.class.getName(), IDiscoveryAdvertiser.class.getName() };
    serviceRegistration = context.registerService(clazzes, serviceFactory, props);
}
Also used : ContainerInstantiator(org.eclipse.ecf.provider.jslp.container.ContainerInstantiator) ServiceTracker(org.osgi.util.tracker.ServiceTracker) JSLPNamespace(org.eclipse.ecf.provider.jslp.identity.JSLPNamespace) ExtensionRegistryRunnable(org.eclipse.ecf.core.util.ExtensionRegistryRunnable) Properties(java.util.Properties) JSLPNamespace(org.eclipse.ecf.provider.jslp.identity.JSLPNamespace) Namespace(org.eclipse.ecf.core.identity.Namespace)

Example 2 with JSLPNamespace

use of org.eclipse.ecf.provider.jslp.identity.JSLPNamespace in project ecf by eclipse.

the class JSLPServiceIDTest method testCreateServiceTypeIDFromSLPStringWithDefaultNamingAuthority.

/* (non-Javadoc)
	 * @see org.eclipse.ecf.tests.discovery.identity.ServiceIDTest#testCreateServiceTypeIDFromInternalString()
	 */
public void testCreateServiceTypeIDFromSLPStringWithDefaultNamingAuthority() {
    final String internalRep = "service:foo.iana:bar";
    final IServiceTypeID stid = (IServiceTypeID) new JSLPNamespace().createInstance(new Object[] { internalRep });
    // the internalRep contains "iana" but getInternal may not!
    final int indexOf = stid.getInternal().toLowerCase().indexOf("iana");
    assertTrue(indexOf == -1);
    assertEquals(IServiceTypeID.DEFAULT_NA, stid.getNamingAuthority());
    assertNotSame(internalRep, stid.getName());
}
Also used : IServiceTypeID(org.eclipse.ecf.discovery.identity.IServiceTypeID) JSLPNamespace(org.eclipse.ecf.provider.jslp.identity.JSLPNamespace)

Example 3 with JSLPNamespace

use of org.eclipse.ecf.provider.jslp.identity.JSLPNamespace in project ecf by eclipse.

the class JSLPServiceIDTest method testCreateServiceTypeIDWithProviderSpecificString.

/* (non-Javadoc)
	 * @see org.eclipse.ecf.tests.discovery.identity.ServiceIDTest#testCreateServiceTypeIDFromInternalString()
	 */
public void testCreateServiceTypeIDWithProviderSpecificString() {
    final String internalRep = "service:foo.eclipse:bar";
    IServiceTypeID stid = (IServiceTypeID) new JSLPNamespace().createInstance(new Object[] { internalRep });
    assertEquals(internalRep, stid.getInternal());
    assertTrue(stid.getName().startsWith("_foo._bar"));
    assertTrue(stid.getName().endsWith("._eclipse"));
    assertEquals("eclipse", stid.getNamingAuthority());
    assertTrue(Arrays.equals(new String[] { "foo", "bar" }, stid.getServices()));
    assertTrue(Arrays.equals(IServiceTypeID.DEFAULT_SCOPE, stid.getScopes()));
    assertTrue(Arrays.equals(IServiceTypeID.DEFAULT_PROTO, stid.getProtocols()));
}
Also used : IServiceTypeID(org.eclipse.ecf.discovery.identity.IServiceTypeID) JSLPNamespace(org.eclipse.ecf.provider.jslp.identity.JSLPNamespace)

Aggregations

JSLPNamespace (org.eclipse.ecf.provider.jslp.identity.JSLPNamespace)3 IServiceTypeID (org.eclipse.ecf.discovery.identity.IServiceTypeID)2 Properties (java.util.Properties)1 Namespace (org.eclipse.ecf.core.identity.Namespace)1 ExtensionRegistryRunnable (org.eclipse.ecf.core.util.ExtensionRegistryRunnable)1 ContainerInstantiator (org.eclipse.ecf.provider.jslp.container.ContainerInstantiator)1 ServiceTracker (org.osgi.util.tracker.ServiceTracker)1