Examples of RequestProcessor


Examples of org.jboss.dna.graph.request.processor.RequestProcessor

     *      org.jboss.dna.graph.request.Request)
     */
    public void execute( ExecutionContext context,
                         Request request ) throws RepositorySourceException {
        // create processor and delegate handling
        RequestProcessor proc = new JdbcRequestProcesor(getSourceName(), context, connection, rootNodeUuid);
        try {
            proc.process(request);
        } finally {
            proc.close();
        }
    }
View Full Code Here

Examples of org.jboss.dna.graph.request.processor.RequestProcessor

        // Prepare for trace-level logging ...
        if (stopwatch != null) stopwatch.start();

        boolean abort = false;
        RequestProcessor processorWithEvents = null;
        try {
            // ----------------------------------------------------------------------------------------------------
            // Step 1: Fork the submitted requests into source-specific requests...
            // ----------------------------------------------------------------------------------------------------
            // This forks a subtask for each source, as soon as the first source-specific request for a source
            // is generated. Each source's "execute(ExecutionContext,Request)" is called only once (a queue is
            // used so that the source can begin processing the requests before all the requests have been
            // computed and submitted to the subtask). Thus, it's possible (and likely) that this thread
            // and subtask threads are executed in parallel.
            final Queue<FederatedRequest> requests = awaitAllSubtasks ? new LinkedList<FederatedRequest>() : new LinkedBlockingQueue<FederatedRequest>();
            final ForkRequestProcessor fork = new ForkRequestProcessor(repository, context, nowInUtc, requests);
            if (synchronousStep1) {
                // Execute the forking process in this thread ...
                try {
                    fork.process(request);
                } finally {
                    fork.close();
                }
                requests.add(new NoMoreFederatedRequests());
                // At this point, all submitted requests have been processed/forked, so we can continue with
                // the join process, starting with the first submitted request. Note that the subtasks may
                // still be executing, but as the join process operates on a forked request, it will wait
                // until all forked requests have completed. Hopefully, in most situations, the subtasks
                // have enough of a lead that the join process never has to wait.
            } else {
                // Submit the forking process for execution in a separate thread ...
                repository.getExecutor().submit(new Runnable() {
                    public void run() {
                        try {
                            fork.process(request);
                        } finally {
                            fork.close();
                        }
                        requests.add(new NoMoreFederatedRequests());
                    }
                });

                // At this point, the forking process is being run by a thread owned by the Executor. We'll still
                // continue with the join process, starting with the first submitted request. Note that it is
                // likely that the subtasks are still running in threads owned by the Executor.
            }

            if (awaitAllSubtasks) {
                // Await until all subtasks have completed ...
                fork.await();
            }

            // ----------------------------------------------------------------------------------------------------
            // Step 2: Join the results of the source-specific (forked) requests back into the submitted requests
            // ----------------------------------------------------------------------------------------------------
            JoinRequestProcessor join = new JoinRequestProcessor(repository, context, observer, nowInUtc);
            try {
                if (awaitAllSubtasks) {
                    join.process(requests);
                } else {
                    join.process((BlockingQueue<FederatedRequest>)requests);
                }
            } catch (RuntimeException e) {
                abort = true;
                throw e;
            } finally {
                if (!awaitAllSubtasks) {
                    // We need to guarantee that the fork processor is closed and released all its resources before we close
                    // ...
                    fork.await();
                }
                join.close();
                processorWithEvents = join;
            }
            if (request instanceof CompositeRequest) {
                // The composite request will not have any errors set, since the fork/join approach puts the
                // contained requests into a separate CompositeRequest object for processing.
                // So, look at the requests for any errors
                ((CompositeRequest)request).checkForErrors();
            }
            if (request.hasError() && !request.isReadOnly()) {
                // There are changes and there is at least one failure ...
                abort = true;
            }
        } catch (InterruptedException e) {
            abort = true;
            request.setError(e);
        } catch (ExecutionException e) {
            abort = true;
            request.setError(e);
        } catch (CancellationException e) {
            abort = true;
            request.cancel();
            // do nothing else
        } catch (RuntimeException e) {
            abort = true;
            throw e;
        } finally {
            if (stopwatch != null) stopwatch.stop();
            if (abort) {
                // Rollback the transaction (if there is one) ...
            } else {
                // fire off any notifications to the observer ...
                assert processorWithEvents != null;
                processorWithEvents.notifyObserverOfChanges();
            }
        }
    }
View Full Code Here

Examples of org.jboss.dna.graph.request.processor.RequestProcessor

            sw.start();
        }
        // Do any commands update/write?
        RepositoryContext repositoryContext = this.source.getRepositoryContext();
        Observer observer = repositoryContext != null ? repositoryContext.getObserver() : null;
        RequestProcessor processor = new MapRequestProcessor(context, this.repository, observer, source.areUpdatesAllowed());

        boolean commit = true;
        MapRepositoryTransaction txn = repository.startTransaction(request.isReadOnly());
        try {
            // Obtain the lock and execute the commands ...
            processor.process(request);
            if (request.hasError() && !request.isReadOnly()) {
                // The changes failed, so we need to rollback so we have 'all-or-nothing' behavior
                commit = false;
            }
        } catch (Throwable error) {
            commit = false;
        } finally {
            try {
                processor.close();
            } finally {
                // Now commit or rollback ...
                try {
                    if (commit) {
                        txn.commit();
                    } else {
                        // Need to rollback the changes made to the repository ...
                        txn.rollback();
                    }
                } catch (Throwable commitOrRollbackError) {
                    if (commit && !request.hasError() && !request.isFrozen()) {
                        // Record the error on the request ...
                        request.setError(commitOrRollbackError);
                    }
                    commit = false; // couldn't do it
                }
                if (commit) {
                    // Now that we've closed our transaction, we can notify the observer of the committed changes ...
                    processor.notifyObserverOfChanges();
                }
            }
        }
        if (logger.isTraceEnabled()) {
            assert sw != null;
View Full Code Here

Examples of org.jboss.dna.graph.requests.processor.RequestProcessor

        if (!this.repository.isRunning()) {
            throw new RepositorySourceException(FederationI18n.repositoryHasBeenShutDown.text(this.repository.getName()));
        }
        if (request == null) return;

        RequestProcessor processor = this.repository.getProcessor(context, sourceName);
        assert processor != null;
        try {
            processor.process(request);
        } finally {
            processor.close();
        }
    }
View Full Code Here

Examples of org.openide.util.RequestProcessor

        private OracleConnection oc = null;
        private boolean interrupted = false;

        public TestConnection(final OConnectionClass ocs) {
            this.ocs = ocs;
            rp = new RequestProcessor(TestConnection.class.getName(), 1, true);

            task = rp.create(new Runnable() {

                public void run() {
                    try {
View Full Code Here

Examples of org.openide.util.RequestProcessor

                return true;
            }
        });

        public ConnectionTry() {
            rp = new RequestProcessor(ConnectionTry.class.getName(), 1, true);

            task = rp.create(new Runnable() {

                public void run() {
                    try {
View Full Code Here

Examples of org.openide.util.RequestProcessor

        private boolean interrupted = false;
        private OracleConnection conn = null;
        private Statement stmt = null;

        public CompileInThread(final BaseClass bc) {
            rp = new RequestProcessor(bc.toString(), 1);

            task = rp.create(new Runnable() {

                public void run() {
                    if (ou.getIsConnected()) {
View Full Code Here

Examples of org.openide.util.RequestProcessor

        private boolean interrupted = false;
        private OracleConnection conn = null;
        private Statement stmt = null;

        public CompileLocalFileInThread(final BaseClass bc) {
            rp = new RequestProcessor(bc.toString(), 1);

            task = rp.create(new Runnable() {

                public void run() {
                    File selFile = returnLocalFile();
View Full Code Here

Examples of org.openide.util.RequestProcessor

    @Override
    public void actionPerformed(ActionEvent ev) {
  // Start JSLintRunnable
  if (processor == null) {
            processor = new RequestProcessor("JSLintErrorCheck", 1, true);
        }
        processor.post(new JSLintRunnable(context, "-e"));
    }
View Full Code Here

Examples of org.openide.util.RequestProcessor

            final String url = EditorContextBridge.getContext().getCurrentURL ();
            final java.awt.IllegalComponentStateException[] exs = new java.awt.IllegalComponentStateException[]
                    { cex, fex, mex };
            synchronized (this) {
                if (postponedToggleRP == null) {
                    postponedToggleRP = new RequestProcessor("Postponed ToggleMethodFieldBreakpointAction", 1);
                }
            }
            postponedToggleRP.post(new Runnable() {
                public void run() {
                    // Re-try to submit the field or method breakpoint again
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.