Package jadex.rules.eca
Class RuleSystem
- java.lang.Object
- 
- jadex.rules.eca.RuleSystem
 
- 
 public class RuleSystem extends java.lang.ObjectThe rule system is the main entry point. It contains the rulebase with all rules and knows about the observed objects.
- 
- 
Field SummaryFields Modifier and Type Field Description protected java.lang.ObjectcontextThe context for rule action execution.protected java.util.logging.LoggerloggerThe logger for rule warnings.protected PropertyChangeManagerpcmanThe PropertyChangeManager to add/remove handlers and manage eventsprotected booleanprocessallFlag to check if currently in processAllEvents (hack?).protected booleanqueueeventsThe execution mode (direct vs queue).protected IRulebaserulebaseThe rulebase.protected java.util.IdentityHashMap<java.lang.Object,Tuple2<java.lang.Object,IRule<?>[]>>rulesThe rules generated for an object.
 - 
Constructor SummaryConstructors 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 SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description IFuture<java.lang.Void>addEvent(IEvent event)Add an event.protected voidanalyzeMethod(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 annotationIRulebasegetRulebase()Get the rulebase.booleanisEventAvailable()Test if at least one event is available.booleanisQueueEvents()Get the queueevents.java.lang.ObjectobserveObject(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.voidsetQueueEvents(boolean queueevents)The queueevents to set.voidunobserveObject(java.lang.Object object, IResultCommand<IFuture<java.lang.Void>,PropertyChangeEvent> eventadder)Unobserve an object.
 
- 
- 
- 
Field Detail- 
rulebaseprotected IRulebase rulebase The rulebase.
 - 
rulesprotected java.util.IdentityHashMap<java.lang.Object,Tuple2<java.lang.Object,IRule<?>[]>> rules The rules generated for an object.
 - 
contextprotected java.lang.Object context The context for rule action execution.
 - 
loggerprotected java.util.logging.Logger logger The logger for rule warnings.
 - 
pcmanprotected PropertyChangeManager pcman The PropertyChangeManager to add/remove handlers and manage events
 - 
queueeventsprotected boolean queueevents The execution mode (direct vs queue).
 - 
processallprotected boolean processall Flag to check if currently in processAllEvents (hack?). Required to avoid nested processAllEvents() call in addEvent()
 
- 
 - 
Method Detail- 
getRulebasepublic IRulebase getRulebase() Get the rulebase.- Returns:
- The rule base.
 
 - 
processEventpublic 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.
 - 
processRulesprotected IFuture<java.lang.Void> processRules(IRule<?>[] rules, int i, IEvent event, IntermediateFuture<RuleEvent> res) Process a given rule set.
 - 
processAllEventspublic IFuture<java.lang.Void> processAllEvents() Process events until the event queue is empty or max events have been processed.
 - 
isEventAvailablepublic boolean isEventAvailable() Test if at least one event is available.
 - 
isQueueEventspublic boolean isQueueEvents() Get the queueevents.- Returns:
- The queueevents
 
 - 
setQueueEventspublic void setQueueEvents(boolean queueevents) The queueevents to set.- Parameters:
- queueevents- The queueevents to set
 
 - 
observeObjectpublic 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
 - 
unobserveObjectpublic void unobserveObject(java.lang.Object object, IResultCommand<IFuture<java.lang.Void>,PropertyChangeEvent> eventadder)Unobserve an object.
 - 
analyzeMethodprotected 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
 
- 
 
-