Search in sources :

Example 1 with ChannelSwitcher

use of org.eclipse.flux.core.ChannelSwitcher 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)

Example 2 with ChannelSwitcher

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

the class UiStartup method earlyStartup.

@Override
public void earlyStartup() {
    ChannelSwitcher channelSwitcher = org.eclipse.flux.core.Activator.getDefault().getChannelSwitcher();
    MessageConnector messagingConnector = org.eclipse.flux.core.Activator.getDefault().getMessageConnector();
    if (messagingConnector != null) {
        UiChannelListener uiChannelListener = new UiChannelListener();
        String userChannel = channelSwitcher.getChannel();
        for (; userChannel == null; userChannel = channelSwitcher.getChannel()) {
            try {
                Thread.sleep(WAIT_TIME_PERIOD);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        uiChannelListener.connected(userChannel);
        messagingConnector.addChannelListener(uiChannelListener);
    }
}
Also used : MessageConnector(org.eclipse.flux.client.MessageConnector) ChannelSwitcher(org.eclipse.flux.core.ChannelSwitcher)

Aggregations

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