Package edu.emory.mathcs.backport.java.util.concurrent

Examples of edu.emory.mathcs.backport.java.util.concurrent.ExecutorService


                                   wasBestEffort);
        }

        if (!this.pollingMode) {

            final ExecutorService useExecutor = waiter.getExecutorService();
            if (useExecutor == null) {
                throw new IllegalStateException("no executor service?");
            }

            final FutureTask[] tasks =
                    createSubscribeTasks(stateSubscribes, termSubscribes);
            for (int i = 0; i < tasks.length; i++) {
                useExecutor.submit(tasks[i]);
            }

            for (int i = 0; i < tasks.length; i++) {
                try {
                    tasks[i].get();
                } catch (Exception e) {
                    final Throwable cause = e.getCause();
                    final String err;
                    if (cause == null) {
                        err = CommonUtil.genericExceptionMessageWrapper(e);
                    } else {
                        if (cause instanceof BaseFaultType) {
                            err = CommonStrings.
                                    faultStringOrCommonCause(
                                            (BaseFaultType)cause);
                        } else {
                            err = CommonUtil.
                                    genericExceptionMessageWrapper(cause);
                        }
                    }
                    throw new ExecutionProblem(err, e);
                }
            }
        }

        if (this.pr.enabled() && this.pr.useThis()) {

            final int code =
                    PrCodes.CREATE__SUBSCRIPTION_CREATING_PRINT_WAITING;
            final String msg = "\nWaiting for updates.\n";
            this.pr.infoln(code, msg);
            //if (this.pollingMode) {
            //    this.pr.info(code, msg);
            //} else {
            //}
        }

        // queryIfListening is unecessary in poll mode
        // (that's why it's called "if listening")
        // could go away when factory supports subscriptions @ creation
        if (queryIfListening && !this.pollingMode) {

            final ExecutorService useExecutor = waiter.getExecutorService();
            if (useExecutor == null) {
                throw new IllegalStateException("no executor service?");
            }
            if (portTypes == null) {
                throw new IllegalStateException("no portTypes?");
            }

            if (!(this.listenMaster instanceof StateChangeConduit)) {
                throw new IllegalStateException("can't do state conduit trick");
            }

            final StateChangeConduit stateConduit =
                    (StateChangeConduit)this.listenMaster;

            if (!(this.listenMaster instanceof TerminationConduit)) {
                throw new IllegalStateException("can't do termination conduit trick");
            }

            final TerminationConduit termConduit =
                    (TerminationConduit)this.listenMaster;

            // Launch one explicit query per workspace, sends state changes and
            // terminations to the same conduit that the WS listener does.  This
            // works since the listen master's implementation is keyed off the
            // EPR and since the waiting latch doesn't care what originally sets
            // off the events its waiting for.  This is a modest invasion into
            // implementation knowledge, but it's very convenient.

            final FutureTask[] queryTasks = new FutureTask[workspaces.length];
            for (int i = 0; i < workspaces.length; i++) {
                final RPQueryCurrentState action =
                        new RPQueryCurrentState(portTypes[i], this.pr);

                action.setStateConduit(stateConduit, workspaces[i].getEpr());
                action.setTerminationConduit(termConduit,
                                             workspaces[i].getEpr());
                queryTasks[i] = new FutureTask(action);
            }

            for (int i = 0; i < queryTasks.length; i++) {
                useExecutor.submit(queryTasks[i]);
            }
        }

        return waiter;
    }
View Full Code Here


     *
     * @throws AxisFault
     */
    public void start() throws AxisFault {
        // create thread pool of workers
        ExecutorService workerPool = new ThreadPoolExecutor(
                1,
                WORKERS_MAX_THREADS, WORKER_KEEP_ALIVE, TIME_UNIT,
                new LinkedBlockingQueue(),
                new org.apache.axis2.util.threadpool.DefaultThreadFactory(
                        new ThreadGroup("JMS Worker thread group"),
View Full Code Here

            }

            try
            {
                taskQueueExecutor.stop();
                ExecutorService service = getExecutorServiceForTTQE( taskQueueExecutor );
                if ( service != null )
                {
                    service.shutdown();
                }
            }
            catch ( StoppingException e )
            {
                log.error( "Unable to stop task queue executor.", e );
View Full Code Here

        }
    }

    private ExecutorService getExecutorServiceForTTQE( ThreadedTaskQueueExecutor ttqe )
    {
        ExecutorService service = null;
        try
        {
            Field executorServiceField = ttqe.getClass().getDeclaredField( "executorService" );
            executorServiceField.setAccessible( true );
            service = (ExecutorService) executorServiceField.get( ttqe );
View Full Code Here

        }
        else
        {
            ThreadFactory _threadFactory = new DefaultThreadFactory(name);

            final ExecutorService _executor;
           
            if (mayDie)
            {
                _executor = Executors.newCachedThreadPool(_threadFactory);
            }
View Full Code Here

        topicConnection.setClientID(durableSubscriptionName);
      }
      catch (Exception e)
      {
                // Try to set the clientID in a seperate thread.
                ExecutorService clientIdSetter = Executors.newSingleThreadExecutor();
                ClientIdSetterCallable cisc = new ClientIdSetterCallable(topicFactory, durableSubscriptionName);               
                Future future = clientIdSetter.submit(cisc);               
                try
                {
                    topicConnection = (TopicConnection)future.get();
                }
                catch (InterruptedException ie)
View Full Code Here

        }
        else
        {
            ThreadFactory _threadFactory = new DefaultThreadFactory(name);

            final ExecutorService _executor;
           
            if (mayDie)
            {
                _executor = Executors.newCachedThreadPool(_threadFactory);
            }
View Full Code Here

     *
     * @throws AxisFault
     */
    public void start() throws AxisFault {
        // create thread pool of workers
        ExecutorService workerPool = new ThreadPoolExecutor(
                1,
                WORKERS_MAX_THREADS, WORKER_KEEP_ALIVE, TIME_UNIT,
                new LinkedBlockingQueue(),
                new org.apache.axis2.util.threadpool.DefaultThreadFactory(
                        new ThreadGroup("JMS Worker thread group"),
View Full Code Here

TOP

Related Classes of edu.emory.mathcs.backport.java.util.concurrent.ExecutorService

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.