Package org.eclipse.equinox.concurrent.future

Examples of org.eclipse.equinox.concurrent.future.IFuture


   * @throws OperationCanceledException
   * @throws ContainerConnectException
   */
  public void testGetAsyncServiceInfo() throws OperationCanceledException, InterruptedException, ContainerConnectException {
    registerService();
    final IFuture aFuture = discoveryLocator.getAsyncServiceInfo(serviceInfo.getServiceID());
    final Object object = aFuture.get();
    assertTrue(object instanceof IServiceInfo);
    final IServiceInfo info = (IServiceInfo) object;
    assertTrue("IServiceInfo should match, expected:\n\t" + serviceInfo + " but:\n\t" + info, comparator.compare(info, serviceInfo) == 0);
  }
View Full Code Here


   * @throws InterruptedException
   * @throws OperationCanceledException
   */
  public void testGetAsyncServices() throws ContainerConnectException, OperationCanceledException, InterruptedException {
    registerService();
    final IFuture aFuture = discoveryLocator.getAsyncServices();
    final Object object = aFuture.get();
    assertTrue(object instanceof IServiceInfo[]);
    final IServiceInfo[] services = (IServiceInfo[]) object;
    assertTrue("Found: " + services.length + Arrays.asList(services), services.length == eventsToExpect);
    for (int i = 0; i < services.length; i++) {
      IServiceInfo iServiceInfo = services[i];
View Full Code Here

   * @throws InterruptedException
   * @throws OperationCanceledException
   */
  public void testGetAsyncServicesIServiceTypeID() throws ContainerConnectException, OperationCanceledException, InterruptedException {
    registerService();
    final IFuture aFuture = discoveryLocator.getAsyncServices(serviceInfo.getServiceID().getServiceTypeID());
    final Object object = aFuture.get();
    assertTrue(object instanceof IServiceInfo[]);
    final IServiceInfo[] services = (IServiceInfo[]) object;
    assertTrue("Found: " + services.length + Arrays.asList(services), services.length == eventsToExpect);
    for (int i = 0; i < services.length; i++) {
      IServiceInfo iServiceInfo = services[i];
View Full Code Here

   * @throws InterruptedException
   * @throws OperationCanceledException
   */
  public void testGetAsyncServiceTypes() throws ContainerConnectException, OperationCanceledException, InterruptedException {
    registerService();
    final IFuture aFuture = discoveryLocator.getAsyncServiceTypes();
    final Object object = aFuture.get();
    assertTrue(object instanceof IServiceTypeID[]);
    final IServiceTypeID[] services = (IServiceTypeID[]) object;
    assertTrue("Found: " + services.length + Arrays.asList(services), services.length == 1); // just expect one event as the implementation filters dupes
    for (int i = 0; i < services.length; i++) {
      IServiceTypeID iServiceTypeId = services[i];
View Full Code Here

    }
  }

  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());
View Full Code Here

  public void testAsyncResult() throws Exception {
    final IRemoteService service = registerAndGetRemoteService();
    if (service == null)
      return;
    traceCallStart("callAsynchResult");
    final IFuture result = service.callAsync(createRemoteConcat(
        "ECF AsynchResults ", "are cool"));
    traceCallEnd("callAsynchResult", result);
    assertNotNull(result);
    Thread.sleep(SLEEPTIME);
  }
View Full Code Here

    final Object o = remoteReferences[0].getProperty(RemoteConstants.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);
  }
View Full Code Here

        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
            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();
View Full Code Here

    Assert.isNotNull(remoteService);
   
    // In this case, we will make an non-blocking call and immediately get a 'future'...which is
    // a placeholder for a result of the remote computation.  This will not block.
    System.out.println("STARTING async remote call via future...");
    IFuture future = RemoteServiceHelper.futureExec(remoteService, "hello",
        new Object[] { CONSUMER_NAME + " future" });
    System.out.println("LOCAL async future invocation complete");
    System.out.println();
    // Client can execute arbitrary code here...
    try {
      // This blocks until communication and computation have completed successfully
      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 (Exception e) {
      e.printStackTrace();
    }
View Full Code Here

    Assert.isNotNull(remoteService);
   
    // In this case, we will make an non-blocking call and immediately get a 'future'...which is
    // a placeholder for a result of the remote computation.  This will not block.
    System.out.println("STARTING async remote call via future...");
    IFuture future = RemoteServiceHelper.futureExec(remoteService, "hello",
        new Object[] { CONSUMER_NAME + " future" });
    System.out.println("LOCAL async future invocation complete");
    // Client can execute arbitrary code here...
    try {
      // This blocks until communication and computation have completed successfully
      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 (Exception e) {
      e.printStackTrace();
    }
View Full Code Here

TOP

Related Classes of org.eclipse.equinox.concurrent.future.IFuture

Copyright © 2018 www.massapicom. 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.