Search in sources :

Example 1 with IDiscoveryLocator

use of org.eclipse.ecf.discovery.IDiscoveryLocator in project ecf by eclipse.

the class AbstractMetadataFactoryTest method getDiscoveryLocator.

protected IDiscoveryLocator getDiscoveryLocator() {
    ServiceTracker serviceTracker = new ServiceTracker(Activator.getDefault().getContext(), IDiscoveryLocator.class.getName(), null);
    serviceTracker.open();
    IDiscoveryLocator result = (IDiscoveryLocator) serviceTracker.getService();
    serviceTracker.close();
    return result;
}
Also used : ServiceTracker(org.osgi.util.tracker.ServiceTracker) IDiscoveryLocator(org.eclipse.ecf.discovery.IDiscoveryLocator)

Example 2 with IDiscoveryLocator

use of org.eclipse.ecf.discovery.IDiscoveryLocator in project ecf by eclipse.

the class ZooDiscoveryTest method getDiscoveryLocator.

protected IDiscoveryLocator getDiscoveryLocator() {
    final IDiscoveryLocator adapter = (IDiscoveryLocator) this.container.getAdapter(IDiscoveryLocator.class);
    // $NON-NLS-1$
    assertNotNull("Adapter must not be null", adapter);
    return adapter;
}
Also used : IDiscoveryLocator(org.eclipse.ecf.discovery.IDiscoveryLocator)

Example 3 with IDiscoveryLocator

use of org.eclipse.ecf.discovery.IDiscoveryLocator in project ecf by eclipse.

the class Activator method getLocator.

public IDiscoveryLocator getLocator() {
    if (locatorTracker == null) {
        locatorTracker = new ServiceTracker(this.context, IDiscoveryLocator.class.getName(), null);
        locatorTracker.open();
    }
    try {
        return (IDiscoveryLocator) locatorTracker.waitForService(DISCOVERY_TIMEOUT);
    } catch (InterruptedException e) {
        // $NON-NLS-1$
        log("getLocator", "Cannot get IDiscoveryAdvertiser", e);
    }
    return null;
}
Also used : ServiceTracker(org.osgi.util.tracker.ServiceTracker) IDiscoveryLocator(org.eclipse.ecf.discovery.IDiscoveryLocator)

Example 4 with IDiscoveryLocator

use of org.eclipse.ecf.discovery.IDiscoveryLocator in project ecf by eclipse.

the class Activator method stop.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
	 */
public void stop(final BundleContext context) throws Exception {
    // TODO-mkuppe here we should do something like a deregisterAll(), but see ungetService(...);
    if (serviceRegistration != null && serviceFactory.isActive()) {
        ServiceReference reference = serviceRegistration.getReference();
        IDiscoveryLocator aLocator = (IDiscoveryLocator) context.getService(reference);
        serviceRegistration.unregister();
        IContainer container = (IContainer) aLocator.getAdapter(IContainer.class);
        container.disconnect();
        container.dispose();
        serviceRegistration = null;
    }
    plugin = null;
    bundleContext = null;
    if (advertiserSt != null) {
        advertiserSt.close();
        advertiserSt = null;
    }
    if (locatorSt != null) {
        locatorSt.close();
        locatorSt = null;
    }
}
Also used : IDiscoveryLocator(org.eclipse.ecf.discovery.IDiscoveryLocator)

Example 5 with IDiscoveryLocator

use of org.eclipse.ecf.discovery.IDiscoveryLocator in project ecf by eclipse.

the class JMDNSPlugin method stop.

/**
 * This method is called when the plug-in is stopped
 */
public void stop(final BundleContext ctxt) throws Exception {
    if (serviceRegistration != null && serviceFactory.isActive()) {
        ServiceReference reference = serviceRegistration.getReference();
        IDiscoveryLocator aLocator = (IDiscoveryLocator) ctxt.getService(reference);
        serviceRegistration.unregister();
        IContainer container = (IContainer) aLocator.getAdapter(IContainer.class);
        container.disconnect();
        container.dispose();
        serviceRegistration = null;
    }
    if (adapterManagerTracker != null) {
        adapterManagerTracker.close();
        adapterManagerTracker = null;
    }
    if (logServiceTracker != null) {
        logServiceTracker.close();
        logServiceTracker = null;
        logService = null;
    }
    this.context = ctxt;
    plugin = null;
}
Also used : IDiscoveryLocator(org.eclipse.ecf.discovery.IDiscoveryLocator)

Aggregations

IDiscoveryLocator (org.eclipse.ecf.discovery.IDiscoveryLocator)10 ServiceReference (org.osgi.framework.ServiceReference)2 ServiceTracker (org.osgi.util.tracker.ServiceTracker)2 Dictionary (java.util.Dictionary)1 Hashtable (java.util.Hashtable)1 IDiscoveryAdvertiser (org.eclipse.ecf.discovery.IDiscoveryAdvertiser)1 ServiceEvent (org.osgi.framework.ServiceEvent)1 ServiceListener (org.osgi.framework.ServiceListener)1 Configuration (org.osgi.service.cm.Configuration)1 ConfigurationAdmin (org.osgi.service.cm.ConfigurationAdmin)1