Search in sources :

Example 1 with ExtensionRegistryRunnable

use of org.eclipse.ecf.core.util.ExtensionRegistryRunnable in project ecf by eclipse.

the class Activator method start.

/**
 * Called when the OSGi framework starts the bundle.
 *
 * @param bc
 *            the bundle context.
 * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
 */
public void start(final BundleContext bc) throws Exception {
    this.context = bc;
    r_osgi_tracker = new ServiceTracker(context, RemoteOSGiService.class.getName(), null);
    r_osgi_tracker.open();
    // bug 495535
    if (DELETE_PROXY_BUNDLES_ON_INIT)
        deleteProxyBundles();
    SafeRunner.run(new ExtensionRegistryRunnable(bc) {

        protected void runWithoutRegistry() throws Exception {
            bc.registerService(Namespace.class, new R_OSGiNamespace(), null);
            bc.registerService(Namespace.class, new R_OSGiWSNamespace(), null);
            bc.registerService(Namespace.class, new R_OSGiWSSNamespace(), null);
            bc.registerService(Namespace.class, new R_OSGiRemoteServiceNamespace(), null);
            // $NON-NLS-1$
            bc.registerService(ContainerTypeDescription.class, new ContainerTypeDescription(R_OSGiContainerInstantiator.NAME, new R_OSGiContainerInstantiator(), "R_OSGi Container", true, false), null);
            // $NON-NLS-1$
            bc.registerService(ContainerTypeDescription.class, new ContainerTypeDescription(R_OSGiContainerInstantiator.NAME_HTTP, new R_OSGiContainerInstantiator(), "R_OSGi Websockets Container", true, false), null);
            // $NON-NLS-1$
            bc.registerService(ContainerTypeDescription.class, new ContainerTypeDescription(R_OSGiContainerInstantiator.NAME_HTTPS, new R_OSGiContainerInstantiator(), "R_OSGi Secure Websockets Container", true, false), null);
        }
    });
}
Also used : ServiceTracker(org.osgi.util.tracker.ServiceTracker) ContainerTypeDescription(org.eclipse.ecf.core.ContainerTypeDescription) ExtensionRegistryRunnable(org.eclipse.ecf.core.util.ExtensionRegistryRunnable) Namespace(org.eclipse.ecf.core.identity.Namespace)

Example 2 with ExtensionRegistryRunnable

use of org.eclipse.ecf.core.util.ExtensionRegistryRunnable 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 3 with ExtensionRegistryRunnable

use of org.eclipse.ecf.core.util.ExtensionRegistryRunnable 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 4 with ExtensionRegistryRunnable

use of org.eclipse.ecf.core.util.ExtensionRegistryRunnable in project ecf by eclipse.

the class Activator method start.

/*
	 * (non-Javadoc)
	 * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
	 */
public void start(final BundleContext bundleContext) throws Exception {
    Activator.context = bundleContext;
    SafeRunner.run(new ExtensionRegistryRunnable(bundleContext) {

        protected void runWithoutRegistry() throws Exception {
            bundleContext.registerService(Namespace.class, new LocalNamespace(), null);
            // $NON-NLS-1$//$NON-NLS-2$
            bundleContext.registerService(ContainerTypeDescription.class, new ContainerTypeDescription("ecf.local", new LocalRemoteServiceContainerInstantiator(), "Local Container Instantiator", false, false), null);
        }
    });
}
Also used : LocalRemoteServiceContainerInstantiator(org.eclipse.ecf.internal.provider.local.container.LocalRemoteServiceContainerInstantiator) LocalNamespace(org.eclipse.ecf.provider.local.identity.LocalNamespace) ContainerTypeDescription(org.eclipse.ecf.core.ContainerTypeDescription) ExtensionRegistryRunnable(org.eclipse.ecf.core.util.ExtensionRegistryRunnable) Namespace(org.eclipse.ecf.core.identity.Namespace) LocalNamespace(org.eclipse.ecf.provider.local.identity.LocalNamespace)

Example 5 with ExtensionRegistryRunnable

use of org.eclipse.ecf.core.util.ExtensionRegistryRunnable in project ecf by eclipse.

the class Activator method start.

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

        protected void runWithoutRegistry() throws Exception {
            context.registerService(Namespace.class, new DnsSdNamespace(), null);
            context.registerService(ContainerTypeDescription.class, new ContainerTypeDescription(DISCOVERY_CONTAINER_NAME_VALUE + LOCATOR, new ContainerInstantiator(), "Discovery Locator Container"), null);
            context.registerService(ContainerTypeDescription.class, new ContainerTypeDescription(DISCOVERY_CONTAINER_NAME_VALUE + ADVERTISER, new ContainerInstantiator(), "Discovery Advertiser Container"), null);
        }
    });
    // register a managed factory for the locator service
    final Properties locCmProps = new Properties();
    locCmProps.put(Constants.SERVICE_PID, DISCOVERY_CONTAINER_NAME_VALUE + LOCATOR);
    context.registerService(ManagedServiceFactory.class.getName(), new DnsSdManagedServiceFactory(DnsSdDiscoveryLocator.class), locCmProps);
    // register the locator service
    final Properties locProps = new Properties();
    locProps.put(DISCOVERY_CONTAINER_NAME_KEY, DISCOVERY_CONTAINER_NAME_VALUE + LOCATOR);
    locProps.put(Constants.SERVICE_RANKING, new Integer(750));
    serviceRegistrations.put(null, context.registerService(IDiscoveryLocator.class.getName(), new DnsSdServiceFactory(DnsSdDiscoveryLocator.class), locProps));
    // register a managed factory for the advertiser service
    final Properties advCmProps = new Properties();
    advCmProps.put(Constants.SERVICE_PID, DISCOVERY_CONTAINER_NAME_VALUE + ADVERTISER);
    context.registerService(ManagedServiceFactory.class.getName(), new DnsSdManagedServiceFactory(DnsSdDiscoveryAdvertiser.class), advCmProps);
    // register the advertiser service
    final Properties advProps = new Properties();
    advProps.put(DISCOVERY_CONTAINER_NAME_KEY, DISCOVERY_CONTAINER_NAME_VALUE + ADVERTISER);
    advProps.put(Constants.SERVICE_RANKING, new Integer(750));
    serviceRegistrations.put(null, context.registerService(IDiscoveryAdvertiser.class.getName(), new DnsSdServiceFactory(DnsSdDiscoveryAdvertiser.class), advProps));
}
Also used : ContainerTypeDescription(org.eclipse.ecf.core.ContainerTypeDescription) ExtensionRegistryRunnable(org.eclipse.ecf.core.util.ExtensionRegistryRunnable) Properties(java.util.Properties) ContainerConnectException(org.eclipse.ecf.core.ContainerConnectException) ConfigurationException(org.osgi.service.cm.ConfigurationException) Namespace(org.eclipse.ecf.core.identity.Namespace) ManagedServiceFactory(org.osgi.service.cm.ManagedServiceFactory)

Aggregations

Namespace (org.eclipse.ecf.core.identity.Namespace)6 ExtensionRegistryRunnable (org.eclipse.ecf.core.util.ExtensionRegistryRunnable)6 ContainerTypeDescription (org.eclipse.ecf.core.ContainerTypeDescription)5 Properties (java.util.Properties)3 ServiceTracker (org.osgi.util.tracker.ServiceTracker)3 Dictionary (java.util.Dictionary)1 ContainerConnectException (org.eclipse.ecf.core.ContainerConnectException)1 TrivialNamespace (org.eclipse.ecf.examples.provider.trivial.identity.TrivialNamespace)1 TrivialContainerInstantiator (org.eclipse.ecf.internal.examples.provider.trivial.container.TrivialContainerInstantiator)1 LocalRemoteServiceContainerInstantiator (org.eclipse.ecf.internal.provider.local.container.LocalRemoteServiceContainerInstantiator)1 ContainerInstantiator (org.eclipse.ecf.provider.jslp.container.ContainerInstantiator)1 JSLPNamespace (org.eclipse.ecf.provider.jslp.identity.JSLPNamespace)1 LocalNamespace (org.eclipse.ecf.provider.local.identity.LocalNamespace)1 ZooDiscoveryContainer (org.eclipse.ecf.provider.zookeeper.core.ZooDiscoveryContainer)1 ZooDiscoveryContainerInstantiator (org.eclipse.ecf.provider.zookeeper.core.ZooDiscoveryContainerInstantiator)1 ZooDiscoveryNamespace (org.eclipse.ecf.provider.zookeeper.core.ZooDiscoveryNamespace)1 Bundle (org.osgi.framework.Bundle)1 ServiceFactory (org.osgi.framework.ServiceFactory)1 ServiceReference (org.osgi.framework.ServiceReference)1 ServiceRegistration (org.osgi.framework.ServiceRegistration)1