Esempio n. 1
0
  public void testComposite() {
    RuleExecutorBuilder builder =
        (DefaultRuleExecutorBuilder) applicationContext.getBean("ruleExecutorBuilder");
    List<Rule> rules = CollectUtils.newArrayList();
    // Rule rule1 = (Rule) Model.newInstance(Rule.class);
    // rule1.setFactory(DefaultRuleExecutorBuilder.SPRING);
    // rule1.setServiceName("ruleExecutor1");

    Rule rule2 = new RuleBean();
    rule2.setFactory(DefaultRuleExecutorBuilder.BEAN);
    rule2.setServiceName("org.beangle.rule.impl.RuleExecutor2");

    // rules.add(rule1);
    rules.add(rule2);

    Context context = new SimpleContext();
    RuleExecutor exceutor = builder.build(rules, false);
    exceutor.execute(context);
  }
Esempio n. 2
0
  public void testEngine() {
    Context context = new SimpleContext();
    Engine engine = new SimpleEngine();
    RuleBase ruleBase = new TestRuleBase();
    // Rule rule1 = new BusinessRule();
    // rule1.setFactory(DefaultRuleExecutorBuilder.SPRING);
    // rule1.setServiceName("ruleExecutor1");

    Rule rule2 = new RuleBean();
    rule2.setFactory(DefaultRuleExecutorBuilder.BEAN);
    rule2.setServiceName("org.beangle.rule.impl.RuleExecutor2");

    // ruleBase.getRules().add(rule1);
    ruleBase.getRules().add(rule2);
    engine.setRuleExecutorBuilder(
        (RuleExecutorBuilder) applicationContext.getBean("ruleExecutorBuilder"));
    engine.setRuleBase(ruleBase);
    engine.setPatternMatcher(new FullPatternMatcher());
    engine.execute(context);
  }