This sample demonstrates a service for specifying the charge rates for calls through the use of business rules.
...
- Windows, Linux or Solaris operating system should exist.
- WSO2 BRS should be installed. To install the BRS, refer Installing the Product. This also includes installing Apache Ant as one of the Installation Prerequisites.
- WSO2 BRS should be started as described in Running the Product.
Sample Configuration
Table of Contents | ||||
---|---|---|---|---|
|
Sample Rule Definition
...
Rules
Rule 1 : If a local calls was taken during daytime, then the call rate is two dollars per minute.
Rule 2 : If a local call was taken during night, then the call rate is one dollar per minute.
Rule 3 : If an international call was taken during daytime, then the call rate is six dollars per minute.
Rule 4 : If an international was taken during night, then the call rate is four dollars per minute.
Facts
There is one fact named A call has been taken (CallLog)
. a charge should be calculated for the call (CallCharge)
is the result of the rule execution.
Code Block | ||
---|---|---|
| ||
package samples.callcharging; import java.util.Calendar; /** * CallLog fact */ public class CallLog { private String type; private double period; public String getType() { return type; } public void setType(String type) { this.type = type; } public double getPeriod() { return period; } public void setPeriod(double period) { this.period = period; } public int now() { Calendar cal = Calendar.getInstance(); return cal.get(Calendar.HOUR_OF_DAY); } } package samples.callcharging; /** * CallCharge fact */ public class CallCharge { private double amount; public double getAmount() { return amount; } public void setAmount(double amount) { this.amount = amount; } } |
Rule Service Configuration (service.rsl)
An in-line rule set is used within the service.rsl file as follows.
...