Search in sources :

Example 1 with ServiceDiscoveryConnector

use of org.eclipse.flux.core.ServiceDiscoveryConnector in project flux by eclipse.

the class JDTComponent method activate.

@Activate
public void activate(final ComponentContext context) throws Exception {
    final boolean lazyStart = org.eclipse.flux.core.Activator.getDefault().isLazyStart();
    final ChannelSwitcher channelSwitcher = org.eclipse.flux.core.Activator.getDefault().getChannelSwitcher();
    final MessageConnector messagingConnector = org.eclipse.flux.core.Activator.getDefault().getMessageConnector();
    if (messagingConnector != null) {
        new Thread() {

            @Override
            public void run() {
                String userChannel = channelSwitcher.getChannel();
                JdtChannelListener jdtChannelListener = new JdtChannelListener();
                for (; userChannel == null; userChannel = channelSwitcher.getChannel()) {
                    try {
                        sleep(WAIT_TIME_PERIOD);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                discoveryConnector = new ServiceDiscoveryConnector(channelSwitcher, messagingConnector, JDT_SERVICE_ID, lazyStart);
                if (lazyStart) {
                    keepAliveConnector = new KeepAliveConnector(channelSwitcher, messagingConnector, JDT_SERVICE_ID);
                }
                jdtChannelListener.connected(userChannel);
                messagingConnector.addChannelListener(jdtChannelListener);
            }
        }.start();
    }
}
Also used : MessageConnector(org.eclipse.flux.client.MessageConnector) KeepAliveConnector(org.eclipse.flux.core.KeepAliveConnector) ChannelSwitcher(org.eclipse.flux.core.ChannelSwitcher) ServiceDiscoveryConnector(org.eclipse.flux.core.ServiceDiscoveryConnector) Activate(org.osgi.service.component.annotations.Activate)

Aggregations

MessageConnector (org.eclipse.flux.client.MessageConnector)1 ChannelSwitcher (org.eclipse.flux.core.ChannelSwitcher)1 KeepAliveConnector (org.eclipse.flux.core.KeepAliveConnector)1 ServiceDiscoveryConnector (org.eclipse.flux.core.ServiceDiscoveryConnector)1 Activate (org.osgi.service.component.annotations.Activate)1