Class RuleEngine
java.lang.Object
com.beassolution.rule.controller.RuleEngine
@Validated
@RestController("ruleengine")
@RequestMapping(name="ruleengine",
path="/rule-engine")
@CrossOrigin(origins="*",
methods={OPTIONS,GET,PUT,DELETE,POST,PATCH})
public class RuleEngine
extends Object
REST controller for rule engine operations.
This controller provides endpoints for rule evaluation and cache management in the Beas Rule Engine. It handles the execution of rules using MVEL expressions and manages the caching of compiled rules and variables.
Key operations include:
- Rule evaluation with parameters and payload
- Cache synchronization
- Since:
- 1.0
- Version:
- 1.0
- Author:
- Beas Solution Team
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity
<RuleEvaluateResponse> evaluate
(Map<String, Object> params, @Valid RuleEvaluateRequest requestPayload) Evaluates a rule with the provided parameters and payload.CompletableFuture
<org.springframework.http.ResponseEntity<org.springframework.http.HttpStatus>> sync()
Synchronizes all rule engine caches.
-
Constructor Details
-
RuleEngine
public RuleEngine()
-
-
Method Details
-
sync
@GetMapping("/sync") public CompletableFuture<org.springframework.http.ResponseEntity<org.springframework.http.HttpStatus>> sync()Synchronizes all rule engine caches.This endpoint triggers a synchronization of all caches including rules, functions, helpers, and variables. The operation is performed asynchronously to avoid blocking the request.
- Returns:
- CompletableFuture containing the HTTP status response
-
evaluate
@PostMapping("/evaluate") public org.springframework.http.ResponseEntity<RuleEvaluateResponse> evaluate(@RequestParam Map<String, Object> params, @RequestBody @Valid @Valid RuleEvaluateRequest requestPayload) Evaluates a rule with the provided parameters and payload.This endpoint executes a rule by name with the given parameters and payload. The rule is compiled and executed using MVEL, with all variables made available in the execution context.
- Parameters:
params
- Query parameters to include in the rule contextrequestPayload
- The rule evaluation request containing rule name and data- Returns:
- ResponseEntity containing the rule evaluation result
- Throws:
OperationException
- if the rule is not found
-