Search in sources :

Example 6 with IContainerEvent

use of org.eclipse.ecf.core.events.IContainerEvent in project ecf by eclipse.

the class DiscoveryTest method addServiceListener.

protected void addServiceListener(TestServiceListener serviceListener) {
    discoveryLocator.addServiceListener(serviceListener);
    addListenerRegisterAndWait(serviceListener, serviceInfo);
    discoveryLocator.removeServiceListener(serviceListener);
    IContainerEvent[] event = serviceListener.getEvent();
    assertNotNull("Test listener didn't receive any discovery event", event);
    assertEquals("Test listener received unexpected amount of discovery events: \n\t" + Arrays.asList(event), eventsToExpect, event.length);
    IServiceInfo serviceInfo2 = ((IServiceEvent) event[eventsToExpect - 1]).getServiceInfo();
    assertTrue("IServiceInfo should match, expected:\n\t" + serviceInfo + " but was \n\t" + serviceInfo2, comparator.compare(serviceInfo2, serviceInfo) == 0);
}
Also used : IServiceInfo(org.eclipse.ecf.discovery.IServiceInfo) IContainerEvent(org.eclipse.ecf.core.events.IContainerEvent) IServiceEvent(org.eclipse.ecf.discovery.IServiceEvent)

Example 7 with IContainerEvent

use of org.eclipse.ecf.core.events.IContainerEvent in project ecf by eclipse.

the class DiscoveryTest method testAddServiceListenerIServiceTypeIDIServiceListener.

/**
 * Test method for
 * {@link org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#addServiceListener(org.eclipse.ecf.discovery.identity.IServiceTypeID, org.eclipse.ecf.discovery.IServiceListener)}.
 * @throws ContainerConnectException
 */
public void testAddServiceListenerIServiceTypeIDIServiceListener() throws ContainerConnectException {
    IServiceInfo[] services = discoveryLocator.getServices();
    assertTrue("No Services must be registerd at this point " + (services.length == 0 ? "" : services[0].toString()), services.length == 0);
    final TestServiceListener tsl = new TestServiceListener(eventsToExpect, discoveryLocator, getName(), getTestId());
    discoveryLocator.addServiceListener(serviceInfo.getServiceID().getServiceTypeID(), tsl);
    addListenerRegisterAndWait(tsl, serviceInfo);
    discoveryLocator.removeServiceListener(serviceInfo.getServiceID().getServiceTypeID(), tsl);
    IContainerEvent[] event = tsl.getEvent();
    assertNotNull("Test listener didn't receive discovery", event);
    assertEquals("Test listener received unexpected amount of discovery events: \n\t" + Arrays.asList(event), eventsToExpect, event.length);
    IServiceInfo serviceInfo2 = ((IServiceEvent) event[eventsToExpect - 1]).getServiceInfo();
    assertTrue("IServiceInfo should match, expected:\n\t" + serviceInfo + " but:\n\t" + serviceInfo2, comparator.compare(serviceInfo2, serviceInfo) == 0);
}
Also used : TestServiceListener(org.eclipse.ecf.tests.discovery.listener.TestServiceListener) IServiceInfo(org.eclipse.ecf.discovery.IServiceInfo) IContainerEvent(org.eclipse.ecf.core.events.IContainerEvent) IServiceEvent(org.eclipse.ecf.discovery.IServiceEvent)

Example 8 with IContainerEvent

use of org.eclipse.ecf.core.events.IContainerEvent in project ecf by eclipse.

the class DiscoveryTest method testAddServiceTypeListener.

/**
 * Test method for
 * {@link org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#addServiceTypeListener(org.eclipse.ecf.discovery.IServiceTypeListener)}.
 * @throws ContainerConnectException
 */
public void testAddServiceTypeListener() throws ContainerConnectException {
    IServiceInfo[] services = discoveryLocator.getServices();
    assertTrue("No Services must be registerd at this point " + (services.length == 0 ? "" : services[0].toString()), services.length == 0);
    final TestServiceTypeListener testTypeListener = new TestServiceTypeListener(eventsToExpect);
    discoveryLocator.addServiceTypeListener(testTypeListener);
    synchronized (testTypeListener) {
        // register a service which we expect the test listener to get notified of
        registerService();
        try {
            testTypeListener.wait(waitTimeForProvider);
        } catch (final InterruptedException e) {
            Thread.currentThread().interrupt();
            fail("Some discovery unrelated threading issues?");
        }
    }
    discoveryLocator.removeServiceTypeListener(testTypeListener);
    IContainerEvent[] event = testTypeListener.getEvent();
    assertNotNull("Test listener didn't receive discovery", event);
    assertEquals("Test listener received unexpected amount of discovery events: \n\t" + Arrays.asList(event), eventsToExpect, event.length);
}
Also used : TestServiceTypeListener(org.eclipse.ecf.tests.discovery.listener.TestServiceTypeListener) IServiceInfo(org.eclipse.ecf.discovery.IServiceInfo) IContainerEvent(org.eclipse.ecf.core.events.IContainerEvent)

Example 9 with IContainerEvent

use of org.eclipse.ecf.core.events.IContainerEvent in project ecf by eclipse.

the class MSNConnectWizard method performFinish.

public boolean performFinish() {
    final String connectID = page.getEmail();
    final String password = page.getPassword();
    // Save combo text even if we don't successfully login
    page.saveComboText();
    connectContext = ConnectContextFactory.createPasswordConnectContext(password);
    try {
        targetID = container.getConnectNamespace().createInstance(new Object[] { connectID });
    } catch (final IDCreateException e) {
        new IDCreateErrorDialog(null, connectID, e).open();
        return false;
    }
    page.saveComboItems();
    final IPresenceContainerAdapter adapter = (IPresenceContainerAdapter) container.getAdapter(IPresenceContainerAdapter.class);
    container.addListener(new IContainerListener() {

        public void handleEvent(IContainerEvent event) {
            if (event instanceof IContainerConnectedEvent) {
                Display.getDefault().asyncExec(new Runnable() {

                    public void run() {
                        openView();
                    }
                });
            }
        }
    });
    final IChatManager icm = adapter.getChatManager();
    icms = icm.getChatMessageSender();
    itms = icm.getTypingMessageSender();
    icm.addMessageListener(new IIMMessageListener() {

        public void handleMessageEvent(IIMMessageEvent e) {
            if (e instanceof IChatMessageEvent) {
                displayMessage((IChatMessageEvent) e);
            } else if (e instanceof ITypingMessageEvent) {
                displayTypingNotification((ITypingMessageEvent) e);
            }
        }
    });
    new AsynchContainerConnectAction(container, targetID, connectContext, null, new Runnable() {

        public void run() {
            cachePassword(connectID, password);
        }
    }).run();
    return true;
}
Also used : IDCreateException(org.eclipse.ecf.core.identity.IDCreateException) IContainerEvent(org.eclipse.ecf.core.events.IContainerEvent) IContainerListener(org.eclipse.ecf.core.IContainerListener) IChatMessageEvent(org.eclipse.ecf.presence.im.IChatMessageEvent) IContainerConnectedEvent(org.eclipse.ecf.core.events.IContainerConnectedEvent) IIMMessageEvent(org.eclipse.ecf.presence.IIMMessageEvent) IDCreateErrorDialog(org.eclipse.ecf.ui.dialogs.IDCreateErrorDialog) IPresenceContainerAdapter(org.eclipse.ecf.presence.IPresenceContainerAdapter) IIMMessageListener(org.eclipse.ecf.presence.IIMMessageListener) ITypingMessageEvent(org.eclipse.ecf.presence.im.ITypingMessageEvent) AsynchContainerConnectAction(org.eclipse.ecf.ui.actions.AsynchContainerConnectAction) IChatManager(org.eclipse.ecf.presence.im.IChatManager)

Example 10 with IContainerEvent

use of org.eclipse.ecf.core.events.IContainerEvent in project ecf by eclipse.

the class ClientContainerConnectTest method createServerAndClients.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.ecf.tests.connect.ContainerConnectTestCase#createServerAndClients()
	 */
protected void createServerAndClients() throws Exception {
    clientCount = 5;
    super.createServerAndClients();
    getServer().addListener(new IContainerListener() {

        public void handleEvent(IContainerEvent event) {
            if (event instanceof IContainerConnectedEvent)
                serverConnectEvents.add(event);
            if (event instanceof IContainerDisconnectedEvent)
                serverDisconnectEvents.add(event);
        }
    });
}
Also used : IContainerEvent(org.eclipse.ecf.core.events.IContainerEvent) IContainerDisconnectedEvent(org.eclipse.ecf.core.events.IContainerDisconnectedEvent) IContainerListener(org.eclipse.ecf.core.IContainerListener) IContainerConnectedEvent(org.eclipse.ecf.core.events.IContainerConnectedEvent)

Aggregations

IContainerEvent (org.eclipse.ecf.core.events.IContainerEvent)16 IServiceInfo (org.eclipse.ecf.discovery.IServiceInfo)8 IServiceEvent (org.eclipse.ecf.discovery.IServiceEvent)6 Properties (java.util.Properties)5 IContainerListener (org.eclipse.ecf.core.IContainerListener)5 BundleContext (org.osgi.framework.BundleContext)5 ServiceRegistration (org.osgi.framework.ServiceRegistration)5 IContainerConnectedEvent (org.eclipse.ecf.core.events.IContainerConnectedEvent)4 IServiceListener (org.eclipse.ecf.discovery.IServiceListener)4 TestServiceListener (org.eclipse.ecf.tests.discovery.listener.TestServiceListener)4 ThreadTestServiceListener (org.eclipse.ecf.tests.discovery.listener.ThreadTestServiceListener)4 IContainerDisconnectedEvent (org.eclipse.ecf.core.events.IContainerDisconnectedEvent)3 TestServiceTypeListener (org.eclipse.ecf.tests.discovery.listener.TestServiceTypeListener)3 HashSet (java.util.HashSet)2 AsynchContainerConnectAction (org.eclipse.ecf.ui.actions.AsynchContainerConnectAction)2 IDCreateErrorDialog (org.eclipse.ecf.ui.dialogs.IDCreateErrorDialog)2 Collection (java.util.Collection)1 Set (java.util.Set)1 IDCreateException (org.eclipse.ecf.core.identity.IDCreateException)1 ISharedObjectManager (org.eclipse.ecf.core.sharedobject.ISharedObjectManager)1