i3.dragos.core.services.rules
Class RuleEngine

java.lang.Object
  extended by i3.dragos.core.AbstractService
      extended by i3.dragos.core.services.rules.RuleEngine
All Implemented Interfaces:
Service

public final class RuleEngine
extends AbstractService

The RuleEngine service is responsible for managing rules and executing them when an event is triggered.

Author:
Boris Boehlen <boehlen@cs.rwth-aachen.de>, Thorsten Hermes <thermes@i3.informatik.rwth-aachen.de>

Nested Class Summary
 
Nested classes/interfaces inherited from interface i3.dragos.core.Service
Service.Result, Service.State
 
Constructor Summary
RuleEngine()
          Constructs a new rule engine.
 
Method Summary
 void addRule(Rule rule, RuleCouplingMode mode, DataSourceURL ds)
          Registers a Rule.
static RuleEngine getInstance()
          Returns the rule engine registered by the service manager.
 java.lang.String getName()
          Returns the name of the service.
 Service.Result initialize()
          Initializes the services.
 void removeRule(Rule rule, RuleCouplingMode mode, DataSourceURL ds)
          Unregisters a Rule.
 Service.Result uninitialize()
          Uninitializes the services and releases all resources used by the service.
 
Methods inherited from class i3.dragos.core.AbstractService
getState, resume, start, stop, suspend
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RuleEngine

public RuleEngine()
Constructs a new rule engine.

Method Detail

getInstance

public static RuleEngine getInstance()
Returns the rule engine registered by the service manager.

Returns:
the rule engine registered by the service manager.

getName

public java.lang.String getName()
Returns the name of the service.

Returns:
the name of the service.

initialize

public Service.Result initialize()
Initializes the services.

Specified by:
initialize in interface Service
Overrides:
initialize in class AbstractService
Returns:
OK if the initialization was successful, FAILED if it was not and INVALID if the configuration was incorrect.

uninitialize

public Service.Result uninitialize()
Uninitializes the services and releases all resources used by the service.

Specified by:
uninitialize in interface Service
Overrides:
uninitialize in class AbstractService
Returns:
OK if the uninitialization was successful, FAILED if it was not and INVALID if the configuration was incorrect.

addRule

public void addRule(Rule rule,
                    RuleCouplingMode mode,
                    DataSourceURL ds)
Registers a Rule. If a DataSourceURL is specified, the Rule will only receive events for transactions running on that data source; null indicates that the rule's trigger condition will be verified for all events.

A Rule can register multiple times, which means that he will receive each event more than once. A separate list of rules is maintained for each category, where category means a specific RuleCouplingMode/DataSourceURL pair (where the DataSourceURL may be null). When unregistering, you have to specify the same parameter values you used when registering, otherwise RuleEngine will look in the wrong category and not find the correct rule entry (or none at all).

Parameters:
rule - The DataListener (must not be null).
mode - The RuleCouplingMode (must not be null).
ds - The DataSourceURL (may be null).

removeRule

public void removeRule(Rule rule,
                       RuleCouplingMode mode,
                       DataSourceURL ds)
Unregisters a Rule.

Parameters:
rule - The DataListener (must not be null).
mode - The RuleCouplingMode (must not be null).
ds - The DataSourceURL (may be null).
See Also:
addRule(Rule, RuleCouplingMode, DataSourceURL)


Copyright © 2002-2008 RWTH Aachen, Department of Computer Science 3 (Software Engineering). All Rights Reserved.