Search in sources :

Example 6 with IRemoteCallEvent

use of org.eclipse.ecf.remoteservice.events.IRemoteCallEvent in project ecf by eclipse.

the class Activator method createRemoteCallListener.

private IRemoteCallListener createRemoteCallListener() {
    return new IRemoteCallListener() {

        public void handleEvent(IRemoteCallEvent event) {
            if (event instanceof IRemoteCallCompleteEvent) {
                IRemoteCallCompleteEvent cce = (IRemoteCallCompleteEvent) event;
                if (!cce.hadException()) {
                    System.out.println("Remote call completed successfully!");
                    SyndFeed feed = (SyndFeed) cce.getResponse();
                    printFeedContent(feed);
                } else {
                    System.out.println("Remote call completed with exception: " + cce.getException());
                }
            }
        }
    };
}
Also used : SyndFeed(com.sun.syndication.feed.synd.SyndFeed) IRemoteCallEvent(org.eclipse.ecf.remoteservice.events.IRemoteCallEvent) IRemoteCallListener(org.eclipse.ecf.remoteservice.IRemoteCallListener) IRemoteCallCompleteEvent(org.eclipse.ecf.remoteservice.events.IRemoteCallCompleteEvent)

Example 7 with IRemoteCallEvent

use of org.eclipse.ecf.remoteservice.events.IRemoteCallEvent in project ecf by eclipse.

the class AbstractRemoteServiceAccessTest method testCallAsync.

public void testCallAsync() throws Exception {
    startTest("testCallAsync");
    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.callAsync(createRemoteCall(), new IRemoteCallListener() {

        public void handleEvent(final IRemoteCallEvent event) {
            if (event instanceof IRemoteCallCompleteEvent) {
                final Object result = ((IRemoteCallCompleteEvent) event).getResponse();
                Trace.trace(Activator.PLUGIN_ID, "callSync.doStuff1 result=" + result);
                assertStringResultValid(result, TestServiceInterface1.TEST_SERVICE_STRING1);
                syncNotify();
            }
        }
    });
    syncWaitForNotify(REGISTER_WAIT);
    endTest("testCallAsync");
}
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) ServiceReference(org.osgi.framework.ServiceReference)

Aggregations

IRemoteCallListener (org.eclipse.ecf.remoteservice.IRemoteCallListener)7 IRemoteCallCompleteEvent (org.eclipse.ecf.remoteservice.events.IRemoteCallCompleteEvent)7 IRemoteCallEvent (org.eclipse.ecf.remoteservice.events.IRemoteCallEvent)7 IRemoteService (org.eclipse.ecf.remoteservice.IRemoteService)6 ServiceReference (org.osgi.framework.ServiceReference)2 SyndFeed (com.sun.syndication.feed.synd.SyndFeed)1 JSONObject (org.json.JSONObject)1