Package org.roolie

Examples of org.roolie.RulesEngine


    // Get the config file as an InputStream
    InputStream is = Main.class.getClassLoader().getResourceAsStream(
      "rooliebanking/roolie-config.xml");

    // Create RulesEngine instance
    RulesEngine rules = new RulesEngine(is);

    // Create some rule arguments (aka "Facts") to test for some users
    List<BankingRuleArgs> bankingRuleArgsList = createRuleArgsToTest();

    // See if rules pass for each BankingRuleArgs created.
    for (BankingRuleArgs ruleArgs : bankingRuleArgsList)
    {
      msg("\n* Evaluating 'userCanWithdrawFunds' rule for " + ruleArgs.getUser());
      boolean canWithdrawFunds =
        rules.passesRule("userCanWithdrawFunds", ruleArgs);

      msg("User can withdraw funds? " + canWithdrawFunds);
      if (canWithdrawFunds)
      {
        withdrawFunds(ruleArgs);
      }
      else
      {
        msg(ruleArgs.getUser() + " cannot withdraw $"
          + ruleArgs.getRequestedWithdrawlAmount());
      }

      msg("\n* Evaluating 'userCanDepositFunds' rule for " + ruleArgs.getUser());
      boolean canDepositFunds =
        rules.passesRule("userCanDepositFunds", ruleArgs);

      msg("User can deposit funds? " + canDepositFunds);
      if (canDepositFunds)
      {
        depositFunds(ruleArgs);
View Full Code Here

TOP

Related Classes of org.roolie.RulesEngine

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.