Search in sources :

Example 1 with IRemoteServiceListener

use of org.eclipse.ecf.remoteservice.IRemoteServiceListener in project ecf by eclipse.

the class RestRemoteServiceAdapterTest method testRemoteServiceRegisteredEvent.

public void testRemoteServiceRegisteredEvent() {
    IRemoteServiceClientContainerAdapter adapter = getRemoteServiceClientContainerAdapter();
    adapter.addRemoteServiceListener(new IRemoteServiceListener() {

        public void handleServiceEvent(IRemoteServiceEvent event) {
            assertTrue(event instanceof IRemoteServiceRegisteredEvent);
        }
    });
    createRestRegistration("resourcePath");
}
Also used : IRemoteServiceClientContainerAdapter(org.eclipse.ecf.remoteservice.client.IRemoteServiceClientContainerAdapter) IRemoteServiceListener(org.eclipse.ecf.remoteservice.IRemoteServiceListener) IRemoteServiceEvent(org.eclipse.ecf.remoteservice.events.IRemoteServiceEvent) IRemoteServiceRegisteredEvent(org.eclipse.ecf.remoteservice.events.IRemoteServiceRegisteredEvent)

Example 2 with IRemoteServiceListener

use of org.eclipse.ecf.remoteservice.IRemoteServiceListener in project ecf by eclipse.

the class RemoteServiceProxyTest method testServiceListener.

public void testServiceListener() throws Exception {
    final IRemoteServiceContainerAdapter[] adapters = getRemoteServiceAdapters();
    done = false;
    final Object lock = new Object();
    adapters[1].addRemoteServiceListener(new IRemoteServiceListener() {

        public void handleServiceEvent(IRemoteServiceEvent event) {
            if (event instanceof IRemoteServiceRegisteredEvent) {
                IRemoteServiceRegisteredEvent e = (IRemoteServiceRegisteredEvent) event;
                IRemoteServiceReference ref = e.getReference();
                remoteService = adapters[1].getRemoteService(ref);
                assertNotNull(remoteService);
                synchronized (lock) {
                    done = true;
                    lock.notify();
                }
            }
        }
    });
    // Now register service on server (adapters[0]).  This should result in notification on client (adapters[1])
    // in above handleServiceEvent
    adapters[0].registerRemoteService(new String[] { IConcatService.class.getName() }, createService(), customizeProperties(null));
    // wait until block above called asynchronously
    int count = 0;
    synchronized (lock) {
        while (!done && count++ < 10) {
            try {
                lock.wait(1000);
            } catch (InterruptedException e) {
                fail();
            }
        }
    }
    assertTrue(done);
    if (remoteService == null)
        return;
    // We've got the remote service, so we're good to go
    assertTrue(remoteService != null);
    traceCallStart("callAsynchResult");
    final IFuture result = remoteService.callAsync(createRemoteConcat("ECF AsynchResults ", "are cool"));
    traceCallEnd("callAsynch");
    assertNotNull(result);
    Thread.sleep(SLEEPTIME);
}
Also used : IRemoteServiceReference(org.eclipse.ecf.remoteservice.IRemoteServiceReference) IConcatService(org.eclipse.ecf.tests.remoteservice.IConcatService) IRemoteServiceContainerAdapter(org.eclipse.ecf.remoteservice.IRemoteServiceContainerAdapter) IRemoteServiceListener(org.eclipse.ecf.remoteservice.IRemoteServiceListener) IRemoteServiceEvent(org.eclipse.ecf.remoteservice.events.IRemoteServiceEvent) IFuture(org.eclipse.equinox.concurrent.future.IFuture) IRemoteServiceRegisteredEvent(org.eclipse.ecf.remoteservice.events.IRemoteServiceRegisteredEvent)

Example 3 with IRemoteServiceListener

use of org.eclipse.ecf.remoteservice.IRemoteServiceListener in project ecf by eclipse.

the class RemoteServiceTrackerTest method testServiceListener.

public void testServiceListener() throws Exception {
    final IRemoteServiceContainerAdapter[] adapters = getRemoteServiceAdapters();
    done = false;
    final Object lock = new Object();
    adapters[1].addRemoteServiceListener(new IRemoteServiceListener() {

        public void handleServiceEvent(IRemoteServiceEvent event) {
            if (event instanceof IRemoteServiceRegisteredEvent) {
                IRemoteServiceRegisteredEvent e = (IRemoteServiceRegisteredEvent) event;
                IRemoteServiceReference ref = e.getReference();
                remoteService = adapters[1].getRemoteService(ref);
                assertNotNull(remoteService);
                synchronized (lock) {
                    done = true;
                    lock.notify();
                }
            }
        }
    });
    // Now register service on server (adapters[0]).  This should result in notification on client (adapters[1])
    // in above handleServiceEvent
    adapters[0].registerRemoteService(new String[] { IConcatService.class.getName() }, createService(), customizeProperties(null));
    // wait until block above called asynchronously
    int count = 0;
    synchronized (lock) {
        while (!done && count++ < 10) {
            try {
                lock.wait(1000);
            } catch (InterruptedException e) {
                fail();
            }
        }
    }
    assertTrue(done);
    if (remoteService == null)
        return;
    // We've got the remote service, so we're good to go
    assertTrue(remoteService != null);
    traceCallStart("callAsynchResult");
    final IFuture result = remoteService.callAsync(createRemoteConcat("ECF AsynchResults ", "are cool"));
    traceCallEnd("callAsynch");
    assertNotNull(result);
    Thread.sleep(SLEEPTIME);
}
Also used : IRemoteServiceReference(org.eclipse.ecf.remoteservice.IRemoteServiceReference) IConcatService(org.eclipse.ecf.tests.remoteservice.IConcatService) IRemoteServiceContainerAdapter(org.eclipse.ecf.remoteservice.IRemoteServiceContainerAdapter) IRemoteServiceListener(org.eclipse.ecf.remoteservice.IRemoteServiceListener) IRemoteServiceEvent(org.eclipse.ecf.remoteservice.events.IRemoteServiceEvent) IFuture(org.eclipse.equinox.concurrent.future.IFuture) IRemoteServiceRegisteredEvent(org.eclipse.ecf.remoteservice.events.IRemoteServiceRegisteredEvent)

Example 4 with IRemoteServiceListener

use of org.eclipse.ecf.remoteservice.IRemoteServiceListener in project ecf by eclipse.

the class SSLRemoteServiceProxyTest method testServiceListener.

public void testServiceListener() throws Exception {
    final IRemoteServiceContainerAdapter[] adapters = getRemoteServiceAdapters();
    done = false;
    final Object lock = new Object();
    adapters[1].addRemoteServiceListener(new IRemoteServiceListener() {

        public void handleServiceEvent(IRemoteServiceEvent event) {
            if (event instanceof IRemoteServiceRegisteredEvent) {
                IRemoteServiceRegisteredEvent e = (IRemoteServiceRegisteredEvent) event;
                IRemoteServiceReference ref = e.getReference();
                remoteService = adapters[1].getRemoteService(ref);
                assertNotNull(remoteService);
                synchronized (lock) {
                    done = true;
                    lock.notify();
                }
            }
        }
    });
    // Now register service on server (adapters[0]).  This should result in notification on client (adapters[1])
    // in above handleServiceEvent
    adapters[0].registerRemoteService(new String[] { IConcatService.class.getName() }, createService(), customizeProperties(null));
    // wait until block above called asynchronously
    int count = 0;
    synchronized (lock) {
        while (!done && count++ < 10) {
            try {
                lock.wait(1000);
            } catch (InterruptedException e) {
                fail();
            }
        }
    }
    assertTrue(done);
    if (remoteService == null)
        return;
    // We've got the remote service, so we're good to go
    assertTrue(remoteService != null);
    traceCallStart("callAsynchResult");
    final IFuture result = remoteService.callAsync(createRemoteConcat("ECF AsynchResults ", "are cool"));
    traceCallEnd("callAsynch");
    assertNotNull(result);
    Thread.sleep(SLEEPTIME);
}
Also used : IRemoteServiceReference(org.eclipse.ecf.remoteservice.IRemoteServiceReference) IConcatService(org.eclipse.ecf.tests.remoteservice.IConcatService) IRemoteServiceContainerAdapter(org.eclipse.ecf.remoteservice.IRemoteServiceContainerAdapter) IRemoteServiceListener(org.eclipse.ecf.remoteservice.IRemoteServiceListener) IRemoteServiceEvent(org.eclipse.ecf.remoteservice.events.IRemoteServiceEvent) IFuture(org.eclipse.equinox.concurrent.future.IFuture) IRemoteServiceRegisteredEvent(org.eclipse.ecf.remoteservice.events.IRemoteServiceRegisteredEvent)

Example 5 with IRemoteServiceListener

use of org.eclipse.ecf.remoteservice.IRemoteServiceListener in project ecf by eclipse.

the class RpcRemoteServiceAdapterTest method testRemoteServiceRegisteredEvent.

public void testRemoteServiceRegisteredEvent() {
    IRemoteServiceClientContainerAdapter adapter = getRemoteServiceClientContainerAdapter();
    adapter.addRemoteServiceListener(new IRemoteServiceListener() {

        public void handleServiceEvent(IRemoteServiceEvent event) {
            assertTrue(event instanceof IRemoteServiceRegisteredEvent);
        }
    });
    createRpcRegistration(RpcConstants.TEST_ECHO_METHOD);
}
Also used : IRemoteServiceClientContainerAdapter(org.eclipse.ecf.remoteservice.client.IRemoteServiceClientContainerAdapter) IRemoteServiceListener(org.eclipse.ecf.remoteservice.IRemoteServiceListener) IRemoteServiceEvent(org.eclipse.ecf.remoteservice.events.IRemoteServiceEvent) IRemoteServiceRegisteredEvent(org.eclipse.ecf.remoteservice.events.IRemoteServiceRegisteredEvent)

Aggregations

IRemoteServiceListener (org.eclipse.ecf.remoteservice.IRemoteServiceListener)8 IRemoteServiceEvent (org.eclipse.ecf.remoteservice.events.IRemoteServiceEvent)8 IRemoteServiceRegisteredEvent (org.eclipse.ecf.remoteservice.events.IRemoteServiceRegisteredEvent)8 IRemoteServiceContainerAdapter (org.eclipse.ecf.remoteservice.IRemoteServiceContainerAdapter)6 IRemoteServiceReference (org.eclipse.ecf.remoteservice.IRemoteServiceReference)6 IConcatService (org.eclipse.ecf.tests.remoteservice.IConcatService)6 IFuture (org.eclipse.equinox.concurrent.future.IFuture)6 IRemoteServiceClientContainerAdapter (org.eclipse.ecf.remoteservice.client.IRemoteServiceClientContainerAdapter)2