Search in sources :

Example 56 with IRemoteService

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

the class AbstractRemoteServiceAccessTest method testCallSyncFromProxy.

public void testCallSyncFromProxy() throws Exception {
    createServiceTrackerAndRegister();
    // Client - Get service references from service tracker
    final ServiceReference[] remoteReferences = st.getServiceReferences();
    assertReferencesValidAndFirstHasCorrectType(remoteReferences, classname);
    // Get proxy
    final TestServiceInterface1 proxy = (TestServiceInterface1) getContext().getService(remoteReferences[0]);
    assertProxyValid(proxy);
    // Get IRemoteService from proxy
    final IRemoteService remoteService = getRemoteServiceFromProxy(proxy);
    // Call remote service synchronously
    final Object result = remoteService.callSync(createRemoteCall());
    Trace.trace(Activator.PLUGIN_ID, "proxy.doStuff1 result=" + result);
    assertStringResultValid(result, TestServiceInterface1.TEST_SERVICE_STRING1);
}
Also used : IRemoteService(org.eclipse.ecf.remoteservice.IRemoteService) ServiceReference(org.osgi.framework.ServiceReference)

Example 57 with IRemoteService

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

the class AbstractRemoteServiceAccessTest method testCallSync.

public void testCallSync() throws Exception {
    createServiceTrackerAndRegister();
    // Client - Get service references from service tracker
    final ServiceReference[] remoteReferences = st.getServiceReferences();
    assertReferencesValidAndFirstHasCorrectType(remoteReferences, classname);
    final Object o = remoteReferences[0].getProperty(RemoteConstants.SERVICE_IMPORTED);
    assertNotNull(o);
    assertTrue(o instanceof IRemoteService);
    final IRemoteService rs = (IRemoteService) o;
    // Call synchronously
    final Object result = rs.callSync(createRemoteCall());
    Trace.trace(Activator.PLUGIN_ID, "callSync.doStuff1 result=" + result);
    assertStringResultValid(result, TestServiceInterface1.TEST_SERVICE_STRING1);
}
Also used : IRemoteService(org.eclipse.ecf.remoteservice.IRemoteService) ServiceReference(org.osgi.framework.ServiceReference)

Example 58 with IRemoteService

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

the class AbstractRemoteServiceAccessTest method testFireAsync.

public void testFireAsync() throws Exception {
    startTest("testFireAsync");
    createServiceTrackerAndRegister();
    // Client - Get service references from service tracker
    final ServiceReference[] remoteReferences = st.getServiceReferences();
    assertReferencesValid(remoteReferences);
    final Object o = remoteReferences[0].getProperty(SERVICE_IMPORTED);
    assertNotNull(o);
    assertTrue(o instanceof IRemoteService);
    final IRemoteService rs = (IRemoteService) o;
    // Call asynchronously
    rs.fireAsync(createRemoteCall());
    Thread.sleep(REGISTER_WAIT);
    endTest("testFireAsync");
}
Also used : IRemoteService(org.eclipse.ecf.remoteservice.IRemoteService) ServiceReference(org.osgi.framework.ServiceReference)

Example 59 with IRemoteService

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

the class AbstractRemoteServiceAccessTest method testCallFuture.

public void testCallFuture() throws Exception {
    startTest("testCallFuture");
    createServiceTrackerAndRegister();
    // Client - Get service references from service tracker
    final ServiceReference[] remoteReferences = st.getServiceReferences();
    assertReferencesValid(remoteReferences);
    final Object o = remoteReferences[0].getProperty(SERVICE_IMPORTED);
    assertNotNull(o);
    assertTrue(o instanceof IRemoteService);
    final IRemoteService rs = (IRemoteService) o;
    // Call asynchronously
    final IFuture futureResult = rs.callAsync(createRemoteCall());
    // now get result from futureResult
    final Object result = futureResult.get();
    Trace.trace(Activator.PLUGIN_ID, "callSync.doStuff1 result=" + result);
    assertStringResultValid(result, TestServiceInterface1.TEST_SERVICE_STRING1);
    endTest("testCallFuture");
}
Also used : IRemoteService(org.eclipse.ecf.remoteservice.IRemoteService) IFuture(org.eclipse.equinox.concurrent.future.IFuture) ServiceReference(org.osgi.framework.ServiceReference)

Example 60 with IRemoteService

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

the class AbstractRemoteServiceAccessTest method testCallSync.

public void testCallSync() throws Exception {
    startTest("testCallSync");
    createServiceTrackerAndRegister();
    // Client - Get service references from service tracker
    final ServiceReference[] remoteReferences = st.getServiceReferences();
    assertReferencesValidAndFirstHasCorrectType(remoteReferences, classname);
    final Object o = remoteReferences[0].getProperty(SERVICE_IMPORTED);
    assertNotNull(o);
    assertTrue(o instanceof IRemoteService);
    final IRemoteService rs = (IRemoteService) o;
    // Call synchronously
    final Object result = rs.callSync(createRemoteCall());
    Trace.trace(Activator.PLUGIN_ID, "callSync.doStuff1 result=" + result);
    assertStringResultValid(result, TestServiceInterface1.TEST_SERVICE_STRING1);
    endTest("testCallSync");
}
Also used : IRemoteService(org.eclipse.ecf.remoteservice.IRemoteService) ServiceReference(org.osgi.framework.ServiceReference)

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