Examples of IHelloAsync


Examples of org.eclipse.ecf.examples.remoteservices.hello.IHelloAsync

      System.out.println();

      // If the proxy is also an instance of IHelloAsync then use
      // this asynchronous interface to invoke methods asynchronously
      if (proxy instanceof IHelloAsync) {
        IHelloAsync helloA = (IHelloAsync) proxy;
        // Create callback for use in IHelloAsync
        IAsyncCallback<String> callback = new IAsyncCallback<String>() {
          public void onSuccess(String result) {
            System.out.println("COMPLETED remote call with callback SUCCESS with result="+result);
            System.out.println();
          }
          public void onFailure(Throwable t) {
            System.out.println("COMPLETED remote call with callback FAILED with exception="+t);
            System.out.println();
          }
        };
       
        // Call asynchronously with callback
        System.out.println("STARTING async remote call via callback...");
        helloA.helloAsync(CONSUMER_NAME + " via async proxy with listener", callback);
        System.out.println("LOCAL async invocation complete");
        System.out.println();
       
        // Call asynchronously with future
        System.out.println("STARTING async remote call via future...");
        IFuture future = helloA.helloAsync(CONSUMER_NAME + " via async proxy with future");
        System.out.println("LOCAL async future invocation complete");
        System.out.println();
        try {
          while (!future.isDone()) {
            // do some other stuff
            System.out.println("LOCAL future not yet done...so we're doing other stuff while waiting for future to be done");
            Thread.sleep(200);
          }
          // Now it's done, so this will not block
          Object result = future.get();
          System.out.println("COMPLETED remote call with future SUCCEEDED with result="+result);
          System.out.println();
        } catch (OperationCanceledException e) {
          System.out.println("COMPLETED remote call with callback CANCELLED with exception="+e);
          System.out.println();
          e.printStackTrace();
        } catch (InterruptedException e) {
          System.out.println("COMPLETED remote call with callback INTERRUPTED with exception="+e);
          System.out.println();
          e.printStackTrace();
        }
       
        // Call other helloMessage method
        // Call asynchronously with callback
        System.out.println("STARTING async remote call via callback...");
        helloA.helloMessageAsync(new HelloMessage(CONSUMER_NAME + " via async proxy with listener","howdy"), callback);
        System.out.println("LOCAL async invocation complete");
        System.out.println();
       
        // Call asynchronously with future
        System.out.println("STARTING async remote call via future...");
        future = helloA.helloMessageAsync(new HelloMessage(CONSUMER_NAME + " via async proxy with future","howdy"));
        System.out.println("LOCAL async future invocation complete");
        System.out.println();
        try {
          while (!future.isDone()) {
            // do some other stuff
View Full Code Here

Examples of org.eclipse.ecf.examples.remoteservices.hello.IHelloAsync

    System.out.println();
   
    // If the proxy is also an instance of IHelloAsync then use
    // this asynchronous interface to invoke methods asynchronously
    if (proxy instanceof IHelloAsync) {
      IHelloAsync helloA = (IHelloAsync) proxy;
      // Create callback for use in IHelloAsync
      IAsyncCallback callback = new IAsyncCallback<String>() {
        public void onSuccess(String result) {
          System.out.println("COMPLETED remote call with callback SUCCESS with result="+result);
          System.out.println();
        }
        public void onFailure(Throwable t) {
          System.out.println("COMPLETED remote call with callback FAILED with exception="+t);
          System.out.println();
        }
      };
     
      // Call asynchronously with callback
      System.out.println("STARTING async remote call via callback...");
      helloA.helloAsync(CONSUMER_NAME + " via async proxy with listener", callback);
      System.out.println("LOCAL async invocation complete");
      System.out.println();
     
      // Call asynchronously with future
      System.out.println("STARTING async remote call via future...");
      Future<String> future = helloA.helloAsync(CONSUMER_NAME + " via async proxy with future");
      System.out.println("LOCAL async future invocation complete");
      System.out.println();
      try {
        while (!future.isDone()) {
          // do some other stuff
View Full Code Here

Examples of org.eclipse.ecf.examples.remoteservices.hello.IHelloAsync

    System.out.println();

    // If the proxy is also an instance of IHelloAsync then use
    // this asynchronous interface to invoke methods asynchronously
    if (proxy instanceof IHelloAsync) {
      IHelloAsync helloA = (IHelloAsync) proxy;
      // Create callback for use in IHelloAsync
      IAsyncCallback callback = new IAsyncCallback<String>() {
        public void onSuccess(String result) {
          System.out.println("COMPLETED remote call with callback SUCCESS with result="+result);
          System.out.println();
        }
        public void onFailure(Throwable t) {
          System.out.println("COMPLETED remote call with callback FAILED with exception="+t);
          System.out.println();
        }
      };
     
      // Call asynchronously with callback
      System.out.println("STARTING async remote call via callback...");
      helloA.helloAsync(CONSUMER_NAME + " via async proxy with listener", callback);
      System.out.println("LOCAL async invocation complete");
      System.out.println();
     
      // Call asynchronously with future
      System.out.println("STARTING async remote call via future...");
      Future<String> future = helloA.helloAsync(CONSUMER_NAME + " via async proxy with future");
      System.out.println("LOCAL async future invocation complete");
      System.out.println();
      try {
        while (!future.isDone()) {
          // do some other stuff
          System.out.println("LOCAL future not yet done...so we're doing other stuff while waiting for future to be done");
          Thread.sleep(200);
        }
        // Now it's done, so this will not block
        String result = future.get();
        System.out.println("COMPLETED remote call with future SUCCEEDED with result="+result);
        System.out.println();
      } catch (OperationCanceledException e) {
        System.out.println("COMPLETED remote call with callback CANCELLED with exception="+e);
        System.out.println();
        e.printStackTrace();
      } catch (InterruptedException e) {
        System.out.println("COMPLETED remote call with callback INTERRUPTED with exception="+e);
        System.out.println();
        e.printStackTrace();
      } catch (ExecutionException e) {
        System.out.println("COMPLETED remote call with callback INTERRUPTED with exception="+e);
        System.out.println();
        e.printStackTrace();
      }
     
      // Call other helloMessage method
      // Call asynchronously with callback
      System.out.println("STARTING async remote call via callback...");
      helloA.helloMessageAsync(new HelloMessage(CONSUMER_NAME + " via async proxy with listener","howdy"), callback);
      System.out.println("LOCAL async invocation complete");
      System.out.println();
     
      // Call asynchronously with future
      System.out.println("STARTING async remote call via future...");
      future = helloA.helloMessageAsync(new HelloMessage(CONSUMER_NAME + " via async proxy with future","howdy"));
      System.out.println("LOCAL async future invocation complete");
      System.out.println();
      try {
        while (!future.isDone()) {
          // do some other stuff
View Full Code Here

Examples of org.eclipse.ecf.examples.remoteservices.hello.IHelloAsync

      System.out.println();

      // If the proxy is also an instance of IHelloAsync then use
      // this asynchronous interface to invoke methods asynchronously
      if (proxy instanceof IHelloAsync) {
        IHelloAsync helloA = (IHelloAsync) proxy;
        // Create callback for use in IHelloAsync
        IAsyncCallback<String> callback = new IAsyncCallback<String>() {
          public void onSuccess(String result) {
            System.out.println("COMPLETED remote call with callback SUCCESS with result="+result);
            System.out.println();
          }
          public void onFailure(Throwable t) {
            System.out.println("COMPLETED remote call with callback FAILED with exception="+t);
            System.out.println();
          }
        };
       
        // Call asynchronously with callback
        System.out.println("STARTING async remote call via callback...");
        helloA.helloAsync(CONSUMER_NAME + " via async proxy with listener", callback);
        System.out.println("LOCAL async invocation complete");
        System.out.println();
       
        // Call asynchronously with future
        System.out.println("STARTING async remote call via future...");
        Future<String> future = helloA.helloAsync(CONSUMER_NAME + " via async proxy with future");
        System.out.println("LOCAL async future invocation complete");
        System.out.println();
        try {
          while (!future.isDone()) {
            // do some other stuff
            System.out.println("LOCAL future not yet done...so we're doing other stuff while waiting for future to be done");
            Thread.sleep(200);
          }
          // Now it's done, so this will not block
          String result = future.get();
          System.out.println("COMPLETED remote call with future SUCCEEDED with result="+result);
          System.out.println();
        } catch (OperationCanceledException e) {
          System.out.println("COMPLETED remote call with callback CANCELLED with exception="+e);
          System.out.println();
          e.printStackTrace();
        } catch (InterruptedException e) {
          System.out.println("COMPLETED remote call with callback INTERRUPTED with exception="+e);
          System.out.println();
          e.printStackTrace();
        } catch (ExecutionException e) {
          System.out.println("COMPLETED remote call with callback INTERRUPTED with exception="+e);
          System.out.println();
          e.printStackTrace();
        }
       
        // Call other helloMessage method
        // Call asynchronously with callback
        System.out.println("STARTING async remote call via callback...");
        helloA.helloMessageAsync(new HelloMessage(CONSUMER_NAME + " via async proxy with listener","howdy"), callback);
        System.out.println("LOCAL async invocation complete");
        System.out.println();
       
        // Call asynchronously with future
        System.out.println("STARTING async remote call via future...");
        future = helloA.helloMessageAsync(new HelloMessage(CONSUMER_NAME + " via async proxy with future","howdy"));
        System.out.println("LOCAL async future invocation complete");
        System.out.println();
        try {
          while (!future.isDone()) {
            // do some other stuff
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.