你好,欢迎来到电脑编程技巧与维护杂志社! 杂志社简介广告服务读者反馈编程社区  
合订本订阅
 
 
您的位置:技术专栏 / Linux开发
使用WEBLOGIC PORTAL规则引擎中实现动态业务逻辑(8)
 
 让我们仔细分析一下流程JPD。下面有用于调用规则引擎的Control Send节点的代码。正如我们可以看到的,该节点使用一个Rules Executor控件来评估规则集,该控件返回一个迭代器。通过其属性(没有给出),控件将过滤结果,仅返回Beans.Action类的对象。通过这些对象,代码将提取动作命令并执行所请求的动作。正如前面所提到的,如果动作是聚集该交易,则流程将使用更新后的块作为输入,对规则引擎开始第二次调用。通过执行适当的动作,对结果进行第二次迭代循环。
public void rulesExecutorControlEvaluateRuleSet()
    throws Exception
{
    // Execute the Rules using facts as the input 
    //#START: CODE GENERATED - PROTECTED SECTION - you can safely
      // Add code above this comment in this method. #//
    // Input transform
    // Return method call
    this.results =
        rulesExecutorControl.evaluateRuleSet(this.facts);
    // Output transform
    // Output assignments
    //#END  : CODE GENERATED - PROTECTED SECTION - you can safely 
      // Add code below this comment in this method. #//

    /* Iterate over the results of rules execution. This assumes that
       results are filtered to return only items of the Beans.Action class.  
       The command property from the Action is expected to be either the
       string "create," in which case a Block trade can be executed from
       the single discrete Trade, or it is expected to be a list of
       attributes describing the Block that this Trade should be 
       incorporated into.
     */
    while (results.hasNext())
    {
        String action = 
            ((Action)results.next()).getCommand();
        if (action.equals("create"))
            (new Block(trade)).execute();  // single-trade       
        else
        {
            // Aggregate trade into an intermediate Block
            trade.aggregate(blockStorage, action);
                
          /* Call the rules engine a second time, this time using
             the resulting Block as the only input.  This is to
             determine if the resulting Block now meets the criteria 
             to execute the order. Again, results are assumed to be
             filtered by the control to return only the Actions.
            */
            Block block = trade.getBlock();
            Object blockFacts[] = new Object[1];
            blockFacts[0] = block;
            Iterator blockResults = 
                blockRulesCntl.evaluateRuleSet(blockFacts);
            while (blockResults.hasNext())
            {
              action = 
                ((Action)blockResults.next()).getCommand();
              if (action.equals("create"))
                  block.execute();
            }
        }
    }
}
(编辑:aniston)
  推荐精品文章

·2024年12月目录 
·2024年11月目录 
·2024年10月目录 
·2024年9月目录 
·2024年8月目录 
·2024年7月目录 
·2024年6月目录 
·2024年5月目录 
·2024年4月目录 
·2024年3月目录 
·2024年2月目录 
·2024年1月目录
·2023年12月目录
·2023年11月目录

  联系方式
TEL:010-82561037
Fax: 010-82561614
QQ: 100164630
Mail:gaojian@comprg.com.cn

  友情链接
 
Copyright 2001-2010, www.comprg.com.cn, All Rights Reserved
京ICP备14022230号-1,电话/传真:010-82561037 82561614 ,Mail:gaojian@comprg.com.cn
地址:北京市海淀区远大路20号宝蓝大厦E座704,邮编:100089