Class RuleSystem

java.lang.Object
jadex.rules.eca.RuleSystem

public class RuleSystem extends Object
The rule system is the main entry point. It contains the rulebase with all rules and knows about the observed objects.
  • Field Details

    • rulebase

      protected IRulebase rulebase
      The rulebase.
    • rules

      protected IdentityHashMap<Object,jadex.common.Tuple2<Object,IRule<?>[]>> rules
      The rules generated for an object.
    • context

      protected Object context
      The context for rule action execution.
    • 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()
  • Constructor Details

    • RuleSystem

      public RuleSystem(Object context)
      Create a new rule system.
    • RuleSystem

      public RuleSystem(Object context, boolean queueevents)
      Create a new rule system.
  • Method Details

    • getRulebase

      public IRulebase getRulebase()
      Get the rulebase.
      Returns:
      The rule base.
    • processEvent

      public jadex.future.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 jadex.future.IFuture<Void> processRules(IRule<?>[] rules, int i, IEvent event, jadex.future.IntermediateFuture<RuleEvent> res)
      Process a given rule set.
    • processAllEvents

      public jadex.future.IFuture<Void> processAllEvents()
      Process events until the event queue is empty or max events have been processed.
    • addEvent

      public jadex.future.IFuture<Void> addEvent(IEvent event)
      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