Ejemplo n.º 1
0
 /**
  * Execute a ruleset for the input.
  *
  * @param rt
  * @param ruleset
  * @param input
  * @throws Exception
  */
 public void execute(final RuleRuntime rt, final String ruleset, final Object[] input)
     throws Exception {
   final StatelessRuleSession srs =
       (StatelessRuleSession)
           rt.createRuleSession(ruleset, null, RuleRuntime.STATELESS_SESSION_TYPE);
   final List output = srs.executeRules(Arrays.asList(input));
   System.out.println(output);
 }
Ejemplo n.º 2
0
  /**
   * Do the test.
   *
   * @throws Exception
   */
  @Test
  public void testMultipleInstances() throws Exception {
    // create 2 different runtimes with different rulesets
    final RuleRuntime ruleRuntime1 =
        getServiceProvider("engine1", "multiple-engine1.drl").getRuleRuntime();
    final RuleRuntime ruleRuntime2 =
        getServiceProvider("engine2", "multiple-engine2.drl").getRuleRuntime();

    // there should be only 1
    System.out.println(ruleRuntime1.getRegistrations().size());
    assertTrue(ruleRuntime1.getRegistrations().size() == 1);

    // there should be only 1
    System.out.println(ruleRuntime2.getRegistrations().size());
    assertTrue(ruleRuntime2.getRegistrations().size() == 1);

    // execute them both for good measure...
    execute(ruleRuntime1, "Engine1", new Object[] {"value1"});
    execute(ruleRuntime2, "Engine2", new Object[] {"value2"});
  }