Package jadex.rules.eca
Class RuleSystem
- java.lang.Object
-
- jadex.rules.eca.RuleSystem
-
public class RuleSystem extends java.lang.Object
The rule system is the main entry point. It contains the rulebase with all rules and knows about the observed objects.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.Object
context
The context for rule action execution.protected java.util.logging.Logger
logger
The logger for rule warnings.protected PropertyChangeManager
pcman
The PropertyChangeManager to add/remove handlers and manage eventsprotected boolean
processall
Flag to check if currently in processAllEvents (hack?).protected boolean
queueevents
The execution mode (direct vs queue).protected IRulebase
rulebase
The rulebase.protected java.util.IdentityHashMap<java.lang.Object,Tuple2<java.lang.Object,IRule<?>[]>>
rules
The rules generated for an object.
-
Constructor Summary
Constructors Constructor Description RuleSystem(java.lang.Object context)
Create a new rule system.RuleSystem(java.lang.Object context, java.util.logging.Logger logger, boolean queueevents)
Create a new rule system.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IFuture<java.lang.Void>
addEvent(IEvent event)
Add an event.protected void
analyzeMethod(java.lang.reflect.Method method, java.lang.Object object, java.util.Map<java.lang.reflect.Method,IResultCommand<?,?>> eventcreators, java.util.Map<java.lang.String,Rule<?>> rules)
Inspects a method for - condition annotation - action annotationIRulebase
getRulebase()
Get the rulebase.boolean
isEventAvailable()
Test if at least one event is available.boolean
isQueueEvents()
Get the queueevents.java.lang.Object
observeObject(java.lang.Object object, boolean bean, boolean hasrules, IResultCommand<IFuture<java.lang.Void>,PropertyChangeEvent> eventadder)
Monitor an object to the rule engine.IFuture<java.lang.Void>
processAllEvents()
Process events until the event queue is empty or max events have been processed.IIntermediateFuture<RuleEvent>
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.protected IFuture<java.lang.Void>
processRules(IRule<?>[] rules, int i, IEvent event, IntermediateFuture<RuleEvent> res)
Process a given rule set.void
setQueueEvents(boolean queueevents)
The queueevents to set.void
unobserveObject(java.lang.Object object, IResultCommand<IFuture<java.lang.Void>,PropertyChangeEvent> eventadder)
Unobserve an object.
-
-
-
Field Detail
-
rulebase
protected IRulebase rulebase
The rulebase.
-
rules
protected java.util.IdentityHashMap<java.lang.Object,Tuple2<java.lang.Object,IRule<?>[]>> rules
The rules generated for an object.
-
context
protected java.lang.Object context
The context for rule action execution.
-
logger
protected java.util.logging.Logger logger
The logger for rule warnings.
-
pcman
protected PropertyChangeManager pcman
The PropertyChangeManager to add/remove handlers and manage events
-
queueevents
protected boolean queueevents
The execution mode (direct vs queue).
-
processall
protected boolean processall
Flag to check if currently in processAllEvents (hack?). Required to avoid nested processAllEvents() call in addEvent()
-
-
Method Detail
-
getRulebase
public IRulebase getRulebase()
Get the rulebase.- Returns:
- The rule base.
-
processEvent
public IIntermediateFuture<RuleEvent> 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 IFuture<java.lang.Void> processRules(IRule<?>[] rules, int i, IEvent event, IntermediateFuture<RuleEvent> res)
Process a given rule set.
-
processAllEvents
public IFuture<java.lang.Void> processAllEvents()
Process events until the event queue is empty or max events have been processed.
-
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 java.lang.Object observeObject(java.lang.Object object, boolean bean, boolean hasrules, IResultCommand<IFuture<java.lang.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(java.lang.Object object, IResultCommand<IFuture<java.lang.Void>,PropertyChangeEvent> eventadder)
Unobserve an object.
-
analyzeMethod
protected void analyzeMethod(java.lang.reflect.Method method, java.lang.Object object, java.util.Map<java.lang.reflect.Method,IResultCommand<?,?>> eventcreators, java.util.Map<java.lang.String,Rule<?>> rules)
Inspects a method for - condition annotation - action annotation
-
-