Package jadex.rules.eca
Class RuleSystem
java.lang.Object
jadex.rules.eca.RuleSystem
The rule system is the main entry point. It contains the rulebase
with all rules and knows about the observed objects.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Object
The context for rule action execution.protected PropertyChangeManager
The PropertyChangeManager to add/remove handlers and manage eventsprotected boolean
Flag to check if currently in processAllEvents (hack?).protected boolean
The execution mode (direct vs queue).protected IRulebase
The rulebase.protected IdentityHashMap
<Object, jadex.common.Tuple2<Object, IRule<?>[]>> The rules generated for an object. -
Constructor Summary
ConstructorsConstructorDescriptionRuleSystem
(Object context) Create a new rule system.RuleSystem
(Object context, boolean queueevents) Create a new rule system. -
Method Summary
Modifier and TypeMethodDescriptionjadex.future.IFuture
<Void> Add an event.protected void
analyzeMethod
(Method method, Object object, Map<Method, jadex.common.IResultCommand<?, ?>> eventcreators, Map<String, Rule<?>> rules) Inspects a method for - condition annotation - action annotationGet the rulebase.boolean
Test if at least one event is available.boolean
Get the queueevents.observeObject
(Object object, boolean bean, boolean hasrules, jadex.common.IResultCommand<jadex.future.IFuture<Void>, PropertyChangeEvent> eventadder) Monitor an object to the rule engine.jadex.future.IFuture
<Void> Process events until the event queue is empty or max events have been processed.jadex.future.IIntermediateFuture
<RuleEvent> Process the next event by - finding rules that are sensible to the event type - evaluate the conditions of these conditions - fire actions of triggered rules.protected jadex.future.IFuture
<Void> processRules
(IRule<?>[] rules, int i, IEvent event, jadex.future.IntermediateFuture<RuleEvent> res) Process a given rule set.void
setQueueEvents
(boolean queueevents) The queueevents to set.void
unobserveObject
(Object object, jadex.common.IResultCommand<jadex.future.IFuture<Void>, PropertyChangeEvent> eventadder) Unobserve an object.
-
Field Details
-
rulebase
The rulebase. -
rules
The rules generated for an object. -
context
The context for rule action execution. -
pcman
The PropertyChangeManager to add/remove handlers and manage events -
queueevents
protected boolean queueeventsThe execution mode (direct vs queue). -
processall
protected boolean processallFlag to check if currently in processAllEvents (hack?). Required to avoid nested processAllEvents() call in addEvent()
-
-
Constructor Details
-
RuleSystem
Create a new rule system. -
RuleSystem
Create a new rule system.
-
-
Method Details
-
getRulebase
Get the rulebase.- Returns:
- The rule base.
-
processEvent
Process the next event by - finding rules that are sensible to the event type - evaluate the conditions of these conditions - fire actions of triggered rules. -
processRules
protected jadex.future.IFuture<Void> processRules(IRule<?>[] rules, int i, IEvent event, jadex.future.IntermediateFuture<RuleEvent> res) Process a given rule set. -
processAllEvents
Process events until the event queue is empty or max events have been processed. -
addEvent
Add an event. -
isEventAvailable
public boolean isEventAvailable()Test if at least one event is available. -
isQueueEvents
public boolean isQueueEvents()Get the queueevents.- Returns:
- The queueevents
-
setQueueEvents
public void setQueueEvents(boolean queueevents) The queueevents to set.- Parameters:
queueevents
- The queueevents to set
-
observeObject
public Object observeObject(Object object, boolean bean, boolean hasrules, jadex.common.IResultCommand<jadex.future.IFuture<Void>, PropertyChangeEvent> eventadder) Monitor an object to the rule engine. - Extracts conditions - Extracts actions - Creates rules from condition/action pairs and adds them to the rulebase. - Subscribes for events -
unobserveObject
public void unobserveObject(Object object, jadex.common.IResultCommand<jadex.future.IFuture<Void>, PropertyChangeEvent> eventadder) Unobserve an object. -
analyzeMethod
protected void analyzeMethod(Method method, Object object, Map<Method, jadex.common.IResultCommand<?, ?>> eventcreators, Map<String, Rule<?>> rules) Inspects a method for - condition annotation - action annotation
-