Example usage for org.apache.commons.chain Chain execute

List of usage examples for org.apache.commons.chain Chain execute

Introduction

In this page you can find the example usage for org.apache.commons.chain Chain execute.

Prototype

boolean execute(Context context) throws Exception;

Source Link

Document

Execute the processing represented by this Chain according to the following algorithm.

  • If there are no configured Command s in the Chain , return false.
  • Call the execute() method of each Command configured on this chain, in the order they were added via calls to the addCommand() method, until the end of the configured Command s is encountered, or until one of the executed Command s returns true or throws an exception.
  • Walk backwards through the Command s whose execute() methods, starting with the last one that was executed.

    Usage

    From source file:ttf.analysis.processor.ChainProcessor.java

    @Override
    public void process(Article article) throws Exception {
        log.info("Start: " + article);
    
        Chain chain = new ChainBase(commands);
        AnalysisContext context = contextFactory.build();
        context.setIncomingArticle(article);
        chain.execute(context);
    }