Search in sources :

Example 1 with IRemoteService

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

the class RpcRemoteServiceAdapterTest method testGetRemoteService.

public void testGetRemoteService() {
    IRemoteServiceRegistration registration = createRpcRegistration(RpcConstants.TEST_ECHO_METHOD);
    IRemoteServiceReference reference = registration.getReference();
    assertNotNull(reference);
    IRemoteService remoteService = getRemoteServiceClientContainerAdapter().getRemoteService(reference);
    assertNotNull(remoteService);
}
Also used : IRemoteServiceReference(org.eclipse.ecf.remoteservice.IRemoteServiceReference) IRemoteServiceRegistration(org.eclipse.ecf.remoteservice.IRemoteServiceRegistration) IRemoteService(org.eclipse.ecf.remoteservice.IRemoteService)

Example 2 with IRemoteService

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

the class RpcRemoteServiceTest method testAsynCall.

public void testAsynCall() {
    IRemoteService rpcClientService = getRemoteServiceClientContainerAdapter(container).getRemoteService(registrationCalc.getReference());
    IFuture future = rpcClientService.callAsync(getCalcPlusCall());
    try {
        Object response = future.get();
        assertTrue(response instanceof Integer);
    } catch (OperationCanceledException e) {
        fail(e.getMessage());
    } catch (InterruptedException e) {
        fail(e.getMessage());
    }
}
Also used : OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) IRemoteService(org.eclipse.ecf.remoteservice.IRemoteService) IFuture(org.eclipse.equinox.concurrent.future.IFuture)

Example 3 with IRemoteService

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

the class RpcRemoteServiceTest method testCallViaProxy2.

public void testCallViaProxy2() {
    IRemoteService rpcClientService = getRemoteServiceClientContainerAdapter(container).getRemoteService(registrationEchoProxy.getReference());
    try {
        IEcho echo = (IEcho) rpcClientService.getProxy();
        assertNotNull(echo);
        Object result = echo.echo(ECHO_TEST_DATA);
        assertNotNull(result);
        assertEquals(result, ECHO_TEST_DATA);
    } catch (ECFException e) {
        e.printStackTrace();
        fail("Could not contact the service");
    }
}
Also used : ECFException(org.eclipse.ecf.core.util.ECFException) IEcho(org.eclipse.ecf.tests.remoteservice.rpc.common.IEcho) IRemoteService(org.eclipse.ecf.remoteservice.IRemoteService)

Example 4 with IRemoteService

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

the class RpcRemoteServiceTest method testCallViaProxy.

public void testCallViaProxy() {
    IRemoteService rpcClientService = getRemoteServiceClientContainerAdapter(container).getRemoteService(registrationEchoProxy.getReference());
    try {
        IEcho echo = (IEcho) rpcClientService.getProxy(Activator.class.getClassLoader(), new Class[] { IEcho.class });
        assertNotNull(echo);
        Object result = echo.echo(ECHO_TEST_DATA);
        assertNotNull(result);
        assertEquals(result, ECHO_TEST_DATA);
    } catch (ECFException e) {
        e.printStackTrace();
        fail("Could not contact the service");
    }
}
Also used : ECFException(org.eclipse.ecf.core.util.ECFException) IEcho(org.eclipse.ecf.tests.remoteservice.rpc.common.IEcho) IRemoteService(org.eclipse.ecf.remoteservice.IRemoteService)

Example 5 with IRemoteService

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

the class RpcRemoteServiceTest method testAsyncCallWithListener.

public void testAsyncCallWithListener() throws Exception {
    IRemoteService rpcClientService = getRemoteServiceClientContainerAdapter(container).getRemoteService(registrationCalc.getReference());
    rpcClientService.callAsync(getCalcPlusCall(), new IRemoteCallListener() {

        public void handleEvent(IRemoteCallEvent event) {
            if (event instanceof IRemoteCallCompleteEvent) {
                IRemoteCallCompleteEvent cce = (IRemoteCallCompleteEvent) event;
                Object response = cce.getResponse();
                assertTrue(response instanceof Integer);
                syncNotify();
            }
        }
    });
    syncWaitForNotify(10000);
}
Also used : IRemoteCallEvent(org.eclipse.ecf.remoteservice.events.IRemoteCallEvent) IRemoteService(org.eclipse.ecf.remoteservice.IRemoteService) IRemoteCallListener(org.eclipse.ecf.remoteservice.IRemoteCallListener) IRemoteCallCompleteEvent(org.eclipse.ecf.remoteservice.events.IRemoteCallCompleteEvent)

Aggregations

IRemoteService (org.eclipse.ecf.remoteservice.IRemoteService)64 ServiceReference (org.osgi.framework.ServiceReference)11 IFuture (org.eclipse.equinox.concurrent.future.IFuture)10 ECFException (org.eclipse.ecf.core.util.ECFException)9 IRemoteServiceContainerAdapter (org.eclipse.ecf.remoteservice.IRemoteServiceContainerAdapter)9 IRemoteServiceReference (org.eclipse.ecf.remoteservice.IRemoteServiceReference)8 IRemoteCallListener (org.eclipse.ecf.remoteservice.IRemoteCallListener)6 IRemoteCallCompleteEvent (org.eclipse.ecf.remoteservice.events.IRemoteCallCompleteEvent)6 IRemoteCallEvent (org.eclipse.ecf.remoteservice.events.IRemoteCallEvent)6 IConcatService (org.eclipse.ecf.tests.remoteservice.IConcatService)6 Dictionary (java.util.Dictionary)5 IRemoteServiceProxy (org.eclipse.ecf.remoteservice.IRemoteServiceProxy)5 JSONObject (org.json.JSONObject)5 Hashtable (java.util.Hashtable)4 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)4 RemoteServiceTracker (org.eclipse.ecf.remoteservice.util.tracker.RemoteServiceTracker)4 IRemoteServiceRegistration (org.eclipse.ecf.remoteservice.IRemoteServiceRegistration)3 ExecutionException (java.util.concurrent.ExecutionException)2 ExecutionException (org.eclipse.core.commands.ExecutionException)2 IContainerManager (org.eclipse.ecf.core.IContainerManager)2