Rule provider

Rule provider is implemented as BTT services, which provides the common interfaces to visit rule engines, including ILog and Java Code rule engine.
Rule provider services must implement the IBTTRuleProvider interface, and extend BTT Service class. checkRule method in IBTTRuleProvider connects to the rule engine, and check the policy. ILogRuleProviderService and JavaCodeRuleProviderService are both extended from IBTTRuleProvider. ILogRuleProviderService provides a default implementation to access local ILog Rule Engine. To access remote ILog or Java local rule engine, you need to extend JavaCodeRuleProviderService yourself The following codes give an example to use these services:
 IBTTRuleProvider ruleService= (IBTTRuleProvider) Service.readObject("testIlogJ2SEService");
		
		Loan loan = new miniloan.Loan(50000000, 240, 0.05);
		 Borrower borrower =new miniloan.Borrower("Joe", 600, 80000);
		 Map<String, Object> inputParameters=new HashMap<String, Object>();
		 
		 inputParameters.put("loan", loan);
		 inputParameters.put("borrower", borrower);

		 Map result =ruleService.checkRule(inputParameters);

To use the Rule Provider Service, you need to:

Configure the service

If you want to use a Rule Provider Service, you need to configure the service firstly.

Prepare the parameter

Rule Provider service accepts Map<String>as input, you need to prepare the parameters as key-value pair. The input should follow the definition of ILog or Java Code Rule Engine. Rule Provider service accepts Map<String> as output also.

Extending the Java code rule provider service

BTT provides an abstract service class--- JavaCodeRuleProviderService, and you can extend it for Remote ILog Service and Java Local Rule Service.
For Java Local Rule Service, you just need implement the abstract method checkRule() to do the rule judgment.
public class UserTransferRuleProviderExample extends JavaCodeRuleProviderService {

	public Map<String, Object> checkRule(Map<String, Object> params) {
		System.out.println("#######UserTransferRuleProviderExample checkRule for ruleID="+this.getRuleID());
		
		if(getRuleID().equalsIgnoreCase("checkLimit")){
			Double amount = (Double) params.get("amount");
			Double limit = (Double) params.get("limit");
			
			if(amount<=limit)
				params.put("approve", new Boolean(true));
			}
	    return null;
	}
}
For Remote ILog Service, you need to implement the invoker process to the remote ILog server in checkRule() method.
Note: When you connect to ILog server in J2EE module, you need to configure a resource-ref in Web project as following: