Package org.jboss.dna.common.util

Examples of org.jboss.dna.common.util.Logger


    public Rule ruleFromString( String definition,
                                ExecutionContext context ) {
        CheckArg.isNotNull(context, "env");
        definition = definition != null ? definition.trim() : "";
        if (definition.length() == 0) return null;
        Logger logger = context.getLogger(getClass());
        for (Method method : parserMethods) {
            try {
                Rule rule = (Rule)method.invoke(null, definition, context);
                if (rule != null) {
                    if (logger.isTraceEnabled()) {
                        String msg = "Success parsing project rule definition \"{0}\" using {1}";
                        logger.trace(msg, definition, method);
                    }
                    return rule;
                } else if (logger.isTraceEnabled()) {
                    String msg = "Unable to parse project rule definition \"{0}\" using {1}";
                    logger.trace(msg, definition, method);
                }
            } catch (Throwable err) {
                String msg = "Error while parsing project rule definition \"{0}\" using {1}";
                logger.trace(err, msg, definition, method);
            }
        }
        return null;
    }
View Full Code Here


                                                                 projectionParser,
                                                                 getProjectionCommand.getPath(),
                                                                 getProjectionCommand.getPropertiesByName(),
                                                                 problems);
                        if (projection != null) {
                            Logger logger = context.getLogger(getClass());
                            if (logger.isTraceEnabled()) {
                                logger.trace("Adding projection to federated repository {0}: {1}",
                                             getRepositoryName(),
                                             projection);
                            }
                            sourceProjections.add(projection);
                        }
View Full Code Here

    public Rule ruleFromString( String definition,
                                ExecutionContext context ) {
        CheckArg.isNotNull(context, "env");
        definition = definition != null ? definition.trim() : "";
        if (definition.length() == 0) return null;
        Logger logger = context.getLogger(getClass());
        for (Method method : parserMethods) {
            try {
                Rule rule = (Rule)method.invoke(null, definition, context);
                if (rule != null) {
                    if (logger.isTraceEnabled()) {
                        String msg = "Success parsing project rule definition \"{0}\" using {1}";
                        logger.trace(msg, definition, method);
                    }
                    return rule;
                } else if (logger.isTraceEnabled()) {
                    String msg = "Unable to parse project rule definition \"{0}\" using {1}";
                    logger.trace(msg, definition, method);
                }
            } catch (Throwable err) {
                String msg = "Error while parsing project rule definition \"{0}\" using {1}";
                logger.trace(err, msg, definition, method);
            }
        }
        return null;
    }
View Full Code Here

     * @see org.jboss.dna.graph.connector.RepositoryConnection#execute(org.jboss.dna.graph.ExecutionContext,
     *      org.jboss.dna.graph.request.Request)
     */
    public void execute( ExecutionContext context,
                         Request request ) throws RepositorySourceException {
        Logger logger = context.getLogger(getClass());
        Stopwatch sw = null;
        if (logger.isTraceEnabled()) {
            sw = new Stopwatch();
            sw.start();
        }

        // Do any commands update/write?
        PathRequestProcessor processor = repository.createRequestProcessor(context, source);
        PathRepositoryTransaction txn = processor.getTransaction();

        boolean commit = true;
        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;
            sw.stop();
            logger.trace(getClass().getSimpleName() + ".execute(...) took " + sw.getTotalDuration());
        }
    }
View Full Code Here

     * @see org.jboss.dna.graph.connector.RepositoryConnection#execute(org.jboss.dna.graph.ExecutionContext,
     *      org.jboss.dna.graph.request.Request)
     */
    public void execute( ExecutionContext context,
                         Request request ) throws RepositorySourceException {
        Logger logger = context.getLogger(getClass());
        Stopwatch sw = null;
        if (logger.isTraceEnabled()) {
            sw = new Stopwatch();
            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;
            sw.stop();
            logger.trace("MapRepositoryConnection.execute(...) took " + sw.getTotalDuration());
        }
    }
View Full Code Here

     * @see org.jboss.dna.graph.connector.RepositoryConnection#execute(org.jboss.dna.graph.ExecutionContext,
     *      org.jboss.dna.graph.request.Request)
     */
    public void execute( ExecutionContext context,
                         Request request ) throws RepositorySourceException {
        Logger logger = context.getLogger(getClass());
        Stopwatch sw = null;
        if (logger.isTraceEnabled()) {
            sw = new Stopwatch();
            sw.start();
        }
        // Do any commands update/write?
        RequestProcessor processor = new MapRequestProcessor(context, this.repository, this.source.getRepositoryContext());

        Lock lock = request.isReadOnly() ? repository.getLock().readLock() : repository.getLock().writeLock();
        lock.lock();
        try {
            // Obtain the lock and execute the commands ...
            processor.process(request);
        } finally {
            try {
                processor.close();
            } finally {
                lock.unlock();
            }
        }
        if (logger.isTraceEnabled()) {
            assert sw != null;
            sw.stop();
            logger.trace("MapRepositoryConnection.execute(...) took " + sw.getTotalDuration());
        }
    }
View Full Code Here

     * @see #shutdown()
     */
    public void start() {
        if (getProblems().hasErrors()) {
            // First log the messages ...
            Logger log = Logger.getLogger(getClass());
            log.error(RepositoryI18n.errorsPreventStarting);
            for (Problem problem : getProblems()) {
                log.error(problem.getMessage(), problem.getParameters());
            }
            // Then throw an exception ...
            throw new IllegalStateException(RepositoryI18n.errorsPreventStarting.text());
        }
        repositoryService.getAdministrator().start();
View Full Code Here

     *
     * @param change the change describing the node to be processed.
     */
    protected void processChange( NetChange change ) {
        final ExecutionContext context = this.getExecutionContext();
        final Logger logger = context.getLogger(getClass());
        assert logger != null;

        try {
            final String repositorySourceName = change.getRepositorySourceName();
            final String repositoryWorkspaceName = change.getRepositoryWorkspaceName();

            // Figure out which sequencers accept this path,
            // and track which output nodes should be passed to each sequencer...
            final Path nodePath = change.getPath();
            final String nodePathStr = context.getValueFactories().getStringFactory().create(nodePath);
            Map<SequencerCall, Set<RepositoryNodePath>> sequencerCalls = new HashMap<SequencerCall, Set<RepositoryNodePath>>();
            List<Sequencer> allSequencers = this.sequencerLibrary.getInstances();
            List<Sequencer> sequencers = new ArrayList<Sequencer>(allSequencers.size());
            for (Sequencer sequencer : allSequencers) {
                final SequencerConfig config = sequencer.getConfiguration();
                for (SequencerPathExpression pathExpression : config.getPathExpressions()) {
                    for (Property property : change.getModifiedProperties()) {
                        Name propertyName = property.getName();
                        String propertyNameStr = context.getValueFactories().getStringFactory().create(propertyName);
                        String path = nodePathStr + "/@" + propertyNameStr;
                        SequencerPathExpression.Matcher matcher = pathExpression.matcher(path);
                        if (matcher.matches()) {
                            // String selectedPath = matcher.getSelectedPath();
                            RepositoryNodePath outputPath = RepositoryNodePath.parse(matcher.getOutputPath(),
                                                                                     repositorySourceName,
                                                                                     repositoryWorkspaceName);
                            SequencerCall call = new SequencerCall(sequencer, propertyNameStr);
                            // Record the output path ...
                            Set<RepositoryNodePath> outputPaths = sequencerCalls.get(call);
                            if (outputPaths == null) {
                                outputPaths = new HashSet<RepositoryNodePath>();
                                sequencerCalls.put(call, outputPaths);
                            }
                            outputPaths.add(outputPath);
                            sequencers.add(sequencer);
                            break;
                        }
                    }
                }
            }

            RepositorySource source = repositoryLibrary.getSource(repositorySourceName);
            Graph graph = Graph.create(source, context);
            Node node = null;
            if (!sequencers.isEmpty()) {

                // Find the changed node ...
                node = graph.getNodeAt(nodePath);

                // Figure out which sequencers should run ...
                sequencers = this.sequencerSelector.selectSequencers(sequencers, node, change);
            }
            if (sequencers.isEmpty()) {
                this.statistics.recordNodeSkipped();
                if (logger.isDebugEnabled()) {
                    logger.trace("Skipping '{0}': no sequencers matched this condition", change);
                }
            } else {
                // Run each of those sequencers ...
                for (Map.Entry<SequencerCall, Set<RepositoryNodePath>> entry : sequencerCalls.entrySet()) {

                    final SequencerCall sequencerCall = entry.getKey();
                    final Set<RepositoryNodePath> outputPaths = entry.getValue();
                    final Sequencer sequencer = sequencerCall.getSequencer();
                    final String sequencerName = sequencer.getConfiguration().getName();
                    final String propertyName = sequencerCall.getSequencedPropertyName();

                    // Get the paths to the nodes where the sequencer should write it's output ...
                    assert outputPaths != null && outputPaths.size() != 0;

                    // Create a new execution context for each sequencer
                    final SimpleProblems problems = new SimpleProblems();
                    SequencerContext sequencerContext = new SequencerContext(context, graph);
                    try {
                        sequencer.execute(node, propertyName, change, outputPaths, sequencerContext, problems);
                        sequencerContext.getDestination().submit();
                    } catch (SequencerException e) {
                        logger.error(e, RepositoryI18n.errorWhileSequencingNode, sequencerName, change);
                    }
                }
                this.statistics.recordNodeSequenced();
            }
        } catch (Throwable e) {
            logger.error(e, RepositoryI18n.errorFindingSequencersToRunAgainstNode, change);
        }
    }
View Full Code Here

TOP

Related Classes of org.jboss.dna.common.util.Logger

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.