org.drools
Interface RuleBase

All Superinterfaces:
RuleBaseEventManager, java.io.Serializable
All Known Subinterfaces:
InternalRuleBase
All Known Implementing Classes:
AbstractRuleBase, ReteooRuleBase

public interface RuleBase
extends java.io.Serializable, RuleBaseEventManager

Active collection of Rules.

From a RuleBase many WorkingMemory rule sessions may be instantiated. Additionally, it may be inspected to determine which Package s it contains.

See Also:
WorkingMemory

Field Summary
static int RETEOO
           
 
Method Summary
 void addPackage(Package pkg)
           
 int getAdditionsSinceLock()
          Returns the number of additive operations applied since the last lock() was obtained
 Package getPackage(java.lang.String name)
           
 Package[] getPackages()
           
 int getRemovalsSinceLock()
          Returns the number of removal operations applied since the last lock() was obtained
 StatefulSession[] getStatefulSessions()
          Returns an array of all the referenced StatefulSessions
 void lock()
          This locks the current RuleBase and all there referenced StatefulSessions.
 StatefulSession newStatefulSession()
          Create a new WorkingMemory session for this RuleBase.
 StatefulSession newStatefulSession(boolean keepReference)
          Create a new WorkingMemory session for this RuleBase.
 StatefulSession newStatefulSession(java.io.InputStream stream)
          RuleBases handle the returning of a Serialized WorkingMemory pass as an InputStream.
 StatefulSession newStatefulSession(java.io.InputStream stream, boolean keepReference)
          RuleBases handle the returning of a Serialized WorkingMemory pass as an InputStream.
 StatelessSession newStatelessSession()
           
 void removeFunction(java.lang.String packageName, java.lang.String functionName)
          Removes a specific function in a specific package.
 void removePackage(java.lang.String packageName)
          Remove the package and all it's rules, functions etc
 void removeProcess(java.lang.String id)
          Removes a process by the process' id
 void removeRule(java.lang.String packageName, java.lang.String ruleName)
          Remove a specific Rule in a Package
 void unlock()
          Unlocks the RuleBase and all of the referenced StatefulSessions.
 
Methods inherited from interface org.drools.RuleBaseEventManager
addEventListener, getRuleBaseEventListeners, removeEventListener
 

Field Detail

RETEOO

static final int RETEOO
See Also:
Constant Field Values
Method Detail

newStatelessSession

StatelessSession newStatelessSession()

newStatefulSession

StatefulSession newStatefulSession()
Create a new WorkingMemory session for this RuleBase. By default the RuleBase retains a weak reference to returned WorkingMemory.

The created WorkingMemory uses the default conflict resolution strategy.

Returns:
A newly initialized WorkingMemory.
See Also:
WorkingMemory, org.drools.conflict.DefaultConflictResolver

newStatefulSession

StatefulSession newStatefulSession(boolean keepReference)
Create a new WorkingMemory session for this RuleBase. Optionally the RuleBase retains a weak reference to returned WorkingMemory.

The created WorkingMemory uses the default conflict resolution strategy.

Returns:
A newly initialized WorkingMemory.
See Also:
WorkingMemory, org.drools.conflict.DefaultConflictResolver

newStatefulSession

StatefulSession newStatefulSession(java.io.InputStream stream)
                                   throws java.io.IOException,
                                          java.lang.ClassNotFoundException
RuleBases handle the returning of a Serialized WorkingMemory pass as an InputStream. If the reference is a byte[] then wrap with new ByteArrayInputStream. By default the RuleBase retains a weak reference to returned WorkingMemory.

The created WorkingMemory uses the default conflict resolution strategy.

Returns:
A serialised initialized WorkingMemory.
Throws:
java.io.IOException
java.lang.ClassNotFoundException
See Also:
WorkingMemory, org.drools.conflict.DefaultConflictResolver

newStatefulSession

StatefulSession newStatefulSession(java.io.InputStream stream,
                                   boolean keepReference)
                                   throws java.io.IOException,
                                          java.lang.ClassNotFoundException
RuleBases handle the returning of a Serialized WorkingMemory pass as an InputStream. If the reference is a byte[] then wrap with new ByteArrayInputStream. Optionally the RuleBase retains a weak reference to returned WorkingMemory.

The created WorkingMemory uses the default conflict resolution strategy.

Returns:
A serialised initialized WorkingMemory.
Throws:
java.io.IOException
java.lang.ClassNotFoundException
See Also:
WorkingMemory, org.drools.conflict.DefaultConflictResolver

getPackages

Package[] getPackages()

getPackage

Package getPackage(java.lang.String name)

addPackage

void addPackage(Package pkg)
                throws java.lang.Exception
Throws:
java.lang.Exception

lock

void lock()
This locks the current RuleBase and all there referenced StatefulSessions. This should be used when there is a number of dynamic RuleBase changes you wish to make, but cannot have any normal WorkingMemory operations occuring inbetween.


unlock

void unlock()
Unlocks the RuleBase and all of the referenced StatefulSessions.


getAdditionsSinceLock

int getAdditionsSinceLock()
Returns the number of additive operations applied since the last lock() was obtained

Returns:

getRemovalsSinceLock

int getRemovalsSinceLock()
Returns the number of removal operations applied since the last lock() was obtained

Returns:

removePackage

void removePackage(java.lang.String packageName)
Remove the package and all it's rules, functions etc

Parameters:
packageName -

removeRule

void removeRule(java.lang.String packageName,
                java.lang.String ruleName)
Remove a specific Rule in a Package

Parameters:
packageName -
ruleName -

removeFunction

void removeFunction(java.lang.String packageName,
                    java.lang.String functionName)
Removes a specific function in a specific package.

Parameters:
packageName -
functionName -

removeProcess

void removeProcess(java.lang.String id)
Removes a process by the process' id

Parameters:
id -

getStatefulSessions

StatefulSession[] getStatefulSessions()
Returns an array of all the referenced StatefulSessions

Returns: