org.drools.reteoo
Class Rete

java.lang.Object
  extended by org.drools.common.BaseNode
      extended by org.drools.reteoo.ObjectSource
          extended by org.drools.reteoo.Rete
All Implemented Interfaces:
Externalizable, Serializable, NetworkNode, ObjectSink, Sink

public class Rete
extends ObjectSource
implements Externalizable, ObjectSink

The Rete-OO network. The Rete class is the root Object. All objects are asserted into the Rete node where it propagates to all matching ObjectTypeNodes. The first time an instance of a Class type is asserted it does a full iteration of all ObjectTyppeNodes looking for matches, any matches are then cached in a HashMap which is used for future assertions. While Rete extends ObjectSource nad implements ObjectSink it nulls the methods attach(), remove() and updateNewNode() as this is the root node they are no applicable

See Also:
ObjectTypeNode, Serialized Form

Field Summary
 
Fields inherited from class org.drools.reteoo.ObjectSource
sink, source
 
Fields inherited from class org.drools.common.BaseNode
associations, id, partitionId, partitionsEnabled
 
Constructor Summary
Rete()
           
Rete(InternalRuleBase ruleBase)
           
 
Method Summary
 void addObjectSink(ObjectSink objectSink)
          Adds the ObjectSink so that it may receive Objects propagated from this ObjectSource.
 void assertObject(InternalFactHandle factHandle, PropagationContext context, InternalWorkingMemory workingMemory)
          This is the entry point into the network for all asserted Facts.
 void attach()
          Attaches the node into the network.
 void attach(InternalWorkingMemory[] workingMemories)
           
protected  void doRemove(RuleRemovalContext context, ReteooBuilder builder, BaseNode node, InternalWorkingMemory[] workingMemories)
          Removes the node from teh network.
 boolean equals(Object object)
           
 EntryPointNode getEntryPointNode(EntryPoint entryPoint)
           
 Map<EntryPoint,EntryPointNode> getEntryPointNodes()
           
 List<ObjectTypeNode> getObjectTypeNodes()
           
 Map<ObjectType,ObjectTypeNode> getObjectTypeNodes(EntryPoint entryPoint)
           
 InternalRuleBase getRuleBase()
           
 int hashCode()
          The hashCode return is simply the unique id of the node.
 boolean isObjectMemoryEnabled()
           
 void modifyObject(InternalFactHandle factHandle, ModifyPreviousTuples modifyPreviousTuples, PropagationContext context, InternalWorkingMemory workingMemory)
           
 void networkUpdated()
          A method that is called for all nodes whose network below them changed, after the change is complete, providing them with an oportunity for state update
 void readExternal(ObjectInput in)
           
protected  void removeObjectSink(ObjectSink objectSink)
          Removes the ObjectSink
 void retractObject(InternalFactHandle handle, PropagationContext context, InternalWorkingMemory workingMemory)
          Retract a fact object from this RuleBase and the specified WorkingMemory.
 void setObjectMemoryEnabled(boolean objectMemoryEnabled)
           
 void updateSink(ObjectSink sink, PropagationContext context, InternalWorkingMemory workingMemory)
           
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class org.drools.reteoo.ObjectSource
getParentObjectSource, getSinkPropagator, isInUse
 
Methods inherited from class org.drools.common.BaseNode
addAssociation, getAssociations, getId, getPartitionId, remove, removeAssociation, setPartitionId, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.drools.common.NetworkNode
getId, getPartitionId
 

Constructor Detail

Rete

public Rete()

Rete

public Rete(InternalRuleBase ruleBase)
Method Detail

assertObject

public void assertObject(InternalFactHandle factHandle,
                         PropagationContext context,
                         InternalWorkingMemory workingMemory)
This is the entry point into the network for all asserted Facts. Iterates a cache of matching ObjectTypdeNodes asserting the Fact. If the cache does not exist it first iteraes and builds the cache.

Specified by:
assertObject in interface ObjectSink
Parameters:
factHandle - The FactHandle of the fact to assert
context - The PropagationContext of the WorkingMemory action
workingMemory - The working memory session.

retractObject

public void retractObject(InternalFactHandle handle,
                          PropagationContext context,
                          InternalWorkingMemory workingMemory)
Retract a fact object from this RuleBase and the specified WorkingMemory.

Parameters:
handle - The handle of the fact to retract.
workingMemory - The working memory session.

modifyObject

public void modifyObject(InternalFactHandle factHandle,
                         ModifyPreviousTuples modifyPreviousTuples,
                         PropagationContext context,
                         InternalWorkingMemory workingMemory)
Specified by:
modifyObject in interface ObjectSink

addObjectSink

public void addObjectSink(ObjectSink objectSink)
Adds the ObjectSink so that it may receive Objects propagated from this ObjectSource.

Overrides:
addObjectSink in class ObjectSource
Parameters:
objectSink - The ObjectSink to receive propagated Objects. Rete only accepts ObjectTypeNodes as parameters to this method, though.

removeObjectSink

protected void removeObjectSink(ObjectSink objectSink)
Description copied from class: ObjectSource
Removes the ObjectSink

Overrides:
removeObjectSink in class ObjectSource
Parameters:
objectSink - The ObjectSink to remove

attach

public void attach()
Description copied from class: BaseNode
Attaches the node into the network. Usually to the parent ObjectSource or TupleSource

Specified by:
attach in class BaseNode

attach

public void attach(InternalWorkingMemory[] workingMemories)
Specified by:
attach in class BaseNode

networkUpdated

public void networkUpdated()
Description copied from class: BaseNode
A method that is called for all nodes whose network below them changed, after the change is complete, providing them with an oportunity for state update

Overrides:
networkUpdated in class ObjectSource

doRemove

protected void doRemove(RuleRemovalContext context,
                        ReteooBuilder builder,
                        BaseNode node,
                        InternalWorkingMemory[] workingMemories)
Description copied from class: BaseNode
Removes the node from teh network. Usually from the parent ObjectSource or TupleSource

Overrides:
doRemove in class ObjectSource

getEntryPointNode

public EntryPointNode getEntryPointNode(EntryPoint entryPoint)

getObjectTypeNodes

public List<ObjectTypeNode> getObjectTypeNodes()

getObjectTypeNodes

public Map<ObjectType,ObjectTypeNode> getObjectTypeNodes(EntryPoint entryPoint)

getRuleBase

public InternalRuleBase getRuleBase()

hashCode

public int hashCode()
Description copied from class: BaseNode
The hashCode return is simply the unique id of the node. It is expected that base classes will also implement equals(Object object).

Overrides:
hashCode in class BaseNode

equals

public boolean equals(Object object)
Overrides:
equals in class Object

updateSink

public void updateSink(ObjectSink sink,
                       PropagationContext context,
                       InternalWorkingMemory workingMemory)
Specified by:
updateSink in class ObjectSource

isObjectMemoryEnabled

public boolean isObjectMemoryEnabled()

setObjectMemoryEnabled

public void setObjectMemoryEnabled(boolean objectMemoryEnabled)

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Overrides:
writeExternal in class ObjectSource
Throws:
IOException

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Specified by:
readExternal in interface Externalizable
Overrides:
readExternal in class ObjectSource
Throws:
IOException
ClassNotFoundException

getEntryPointNodes

public Map<EntryPoint,EntryPointNode> getEntryPointNodes()


Copyright © 2001-2012 JBoss by Red Hat. All Rights Reserved.