Fork me on GitHub

Actions and Predicates

Actions and Predicates for the rule system are implemented as ActionProvider and PredicateProvider. There are some common build in Provider in the framework. So in most cases these must not be implemented by plugins. But if you need a special provider for a plugin specific action you can implement your own.

Please note that these APIs aren't fix yet and may change in the future without a notice.

ActionProvider

Let's create a simple action provider that answers the question of life the universe and everything.

Each concrete ActionProvider must be a subclass of ActionProvider. The ActionProvider must implement a parseAction-function that is called for every part of the action string of a rule by the framework. If the ActionHandler can handle the input then it should return a info object with a ActionHandler (see below) that can execute the corresponding action.

The returned ActionHandler must be a subclass of ActionHandler and must implement a executeAction-function that can be called by the framework.

The executeAction-function should execute the action if simulate is false. It should always return a promise that gets fulfilled with a description string, after the action was executed.

Finally you have to register your ActionProvider in the framework.

For a more complex example, you can take a look at the shell-execute Plugin.

PredicateProvider

PredicateProvider follow the same pattern as ActionProvider, but the function of a PredicateHandler are different. It follows an Example PredicateProvider that is true if the value of a numeric expression is 42.

The corresponding PredicateHandler:

and finally the registration: