Package java.util.concurrent

Examples of java.util.concurrent.FutureTask$Sync


    /**
     * Requests that this transports attempts to connect to the broker. Occurs asynchronously from the caller initiation.
     */
    public Future<Boolean> requestConnectionToBroker() {
        FutureTask futureTask = new FutureTask(new Callable<Boolean>() {
            @Override
            public Boolean call() throws Exception {
                boolean ok = false;
                try {
                    getConnection();
View Full Code Here


        // is the return type a future
        final boolean isFuture = method.getReturnType() == Future.class;

        // create task to execute the proxy and gather the reply
        FutureTask task = new FutureTask<Object>(new Callable<Object>() {
            public Object call() throws Exception {
                // process the exchange
                LOG.trace("Proxied method call {} invoking producer: {}", method.getName(), producer);
                producer.process(exchange);

                Object answer = afterInvoke(method, exchange, pattern, isFuture);
                LOG.trace("Proxied method call {} returning: {}", method.getName(), answer);
                return answer;
            }
        });

        if (isFuture) {
            // submit task and return future
            if (LOG.isTraceEnabled()) {
                LOG.trace("Submitting task for exchange id {}", exchange.getExchangeId());
            }
            getExecutorService(exchange.getContext()).submit(task);
            return task;
        } else {
            // execute task now
            try {
                task.run();
                return task.get();
            } catch (ExecutionException e) {
                // we don't want the wrapped exception from JDK
                throw e.getCause();
            }
        }
View Full Code Here

            // failed to create a proxy for it.
            handler = originalHandler;
        }

        cft = new CallbackFutureTask(ic.getAsyncResponseListener(), handler, handlerCL);
        task = new FutureTask(cft);
        executor = ic.getExecutor();
       
        /*
         * TODO review.  We need to save the invocation context so we can set it on the
         * response (or fault) context so the FutureCallback has access to the handler list.
View Full Code Here

        ClassLoader cl = getContextClassLoader();
       
        AsyncInvocationWorker worker = new AsyncInvocationWorker(target,
                                                                 methodInputParams,
                                                                 cl, eic);
        FutureTask task = new FutureTask<AsyncInvocationWorker>(worker);
       
        ExecutorFactory ef = (ExecutorFactory) FactoryRegistry.getFactory(ExecutorFactory.class);
        Executor executor = ef.getExecutorInstance(ExecutorFactory.SERVER_EXECUTOR);
       
        // If the property has been set to disable thread switching, then we can
View Full Code Here

       
        EndpointInvocationContext eic = (EndpointInvocationContext) request.getInvocationContext();
        ClassLoader cl = getContextClassLoader();
       
        AsyncInvocationWorker worker = new AsyncInvocationWorker(target, methodInputParams, cl, eic);
        FutureTask task = new FutureTask<AsyncInvocationWorker>(worker);
       
        ExecutorFactory ef = (ExecutorFactory) FactoryRegistry.getFactory(ExecutorFactory.class);
        Executor executor = ef.getExecutorInstance(ExecutorFactory.SERVER_EXECUTOR);
        // If the property has been set to disable thread switching, then we can
        // do so by using a SingleThreadedExecutor instance to continue processing
View Full Code Here

       
        EndpointInvocationContext eic = (EndpointInvocationContext) request.getInvocationContext();
        ClassLoader cl = Thread.currentThread().getContextClassLoader();
       
        AsyncInvocationWorker worker = new AsyncInvocationWorker(m, params, cl, eic);
        FutureTask task = new FutureTask<AsyncInvocationWorker>(worker);
        executor.execute(task);
       
        return;
    }
View Full Code Here

       
        EndpointInvocationContext eic = (EndpointInvocationContext) request.getInvocationContext();
        ClassLoader cl = Thread.currentThread().getContextClassLoader();
       
        AsyncInvocationWorker worker = new AsyncInvocationWorker(m, params, cl, eic);
        FutureTask task = new FutureTask<AsyncInvocationWorker>(worker);
        executor.execute(task);
       
        return;
    }
View Full Code Here

            _oneInstance),

            _timeout);

         _futureResult = new FutureTask(_callable);
         return _futureResult;
        
      }
      catch (Exception e)
      {
View Full Code Here

   }

   public Object call() throws Exception
   {

      FutureTask result = new FutureTask(function);


      Thread thread = Executors.defaultThreadFactory().newThread(result);

      thread.start();

      try
      {

         startingTime = System.currentTimeMillis();

         Object obj = result.get(millis, TimeUnit.MILLISECONDS);

         endingTime = System.currentTimeMillis();

         return obj;
View Full Code Here

  /**
   * This method also exist in PlatformUtil in commons, but we can't use that here
   */
  static public void runAndWait(final Runnable runnable) {
    try {
      FutureTask future = new FutureTask(runnable, null);
      Platform.runLater(future);
      future.get();
    }
    catch (InterruptedException | ExecutionException e) {
      throw new RuntimeException(e);
    }
  }
View Full Code Here

TOP

Related Classes of java.util.concurrent.FutureTask$Sync

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.