站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > JBoss RULES 4.0.0.11754MR2 API 英文版文档

ObjectTypeNode (Drools 4.0.0.11754MR2 API) - JBoss RULES 4.0.0.11754MR2 API 英文版文档


org.drools.reteoo
Class ObjectTypeNode

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

public class ObjectTypeNode
extends ObjectSource
implements ObjectSink, Serializable, NodeMemory

ObjectTypeNodes are responsible for filtering and propagating the matching fact assertions propagated from the Rete node using ObjectType interface.

The assert and retract methods do not attempt to filter as this is the role of the Rete node which builds up a cache of matching ObjectTypdeNodess for each asserted object, using the matches(Object object) method. Incorrect propagation in these methods is not checked and will result in ClassCastExpcections later on in the network.

Filters Objects coming from the Rete using a ObjectType semantic module.

Author:
Mark Proctor, Bob McWhirter
See Also:
ObjectType, Rete, Serialized Form

Field Summary
protected  boolean skipOnModify
           
 
Fields inherited from class org.drools.reteoo.ObjectSource
objectSource, sink
 
Fields inherited from class org.drools.common.BaseNode
hasMemory, id, sharedCount
 
Constructor Summary
ObjectTypeNode(int id, ObjectType objectType, Rete rete, int alphaNodeHashingThreshold)
          Construct given a semantic ObjectType and the provided unique id.
 
Method Summary
protected  void addObjectSink(ObjectSink objectSink)
          Adds the ObjectSink so that it may receive FactHandleImpl propagated from this ObjectSource.
 void addShare()
          Rete needs to know that this ObjectTypeNode has had new nodes attached to it one one of its ancestors
 void assertObject(InternalFactHandle handle, PropagationContext context, InternalWorkingMemory workingMemory)
          Propagate the FactHandleimpl through the Rete network.
 void attach()
          Rete needs to know that this ObjectTypeNode has been added
 void attach(InternalWorkingMemory[] workingMemories)
           
 Object createMemory(RuleBaseConfiguration config)
          Creates memory for the node using PrimitiveLongMap as its optimised for storage and reteivals of Longs.
 boolean equals(Object object)
           
 ObjectType getObjectType()
          Retrieve the semantic ObjectType differentiator.
 int hashCode()
          Uses he hashCode() of the underlying ObjectType implementation.
 boolean matches(Object object)
          Tests the provided object to see if this ObjectTypeNode can receive the object for assertion and retraction propagations.
 void remove(BaseNode node, InternalWorkingMemory[] workingMemories)
          Removes the node from teh network.
protected  void removeObjectSink(ObjectSink objectSink)
          Removes the ObjectSink
 void retractObject(InternalFactHandle handle, PropagationContext context, InternalWorkingMemory workingMemory)
          Retract the FactHandleimpl from the Rete network.
 String toString()
           
 void updateSink(ObjectSink sink, PropagationContext context, InternalWorkingMemory workingMemory)
           
 
Methods inherited from class org.drools.reteoo.ObjectSource
getSinkPropagator
 
Methods inherited from class org.drools.common.BaseNode
getId, getSharedCount, hasMemory, isInUse, isShared, removeShare, setHasMemory
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.drools.common.NodeMemory
getId
 

Field Detail

skipOnModify

protected boolean skipOnModify
Constructor Detail

ObjectTypeNode

public ObjectTypeNode(int id,
                      ObjectType objectType,
                      Rete rete,
                      int alphaNodeHashingThreshold)
Construct given a semantic ObjectType and the provided unique id. All ObjectTypdeNode have node memory.

Parameters:
id - The unique id for the node.
objectType - The semantic object-type differentiator.
Method Detail

getObjectType

public ObjectType getObjectType()
Retrieve the semantic ObjectType differentiator.

Returns:
The semantic ObjectType differentiator.

matches

public boolean matches(Object object)
Tests the provided object to see if this ObjectTypeNode can receive the object for assertion and retraction propagations.

Parameters:
object -
Returns:
boolean value indicating whether the ObjectTypeNode can receive the object.

assertObject

public void assertObject(InternalFactHandle handle,
                         PropagationContext context,
                         InternalWorkingMemory workingMemory)
Propagate the FactHandleimpl through the Rete network. All FactHandleImpl should be remembered in the node memory, so that later runtime rule attachmnents can have the matched facts propagated to them.

Specified by:
assertObject in interface ObjectSink
Parameters:
handle - The fact handle.
object - The object to assert.
workingMemory - The working memory session.

retractObject

public void retractObject(InternalFactHandle handle,
                          PropagationContext context,
                          InternalWorkingMemory workingMemory)
Retract the FactHandleimpl from the Rete network. Also remove the FactHandleImpl from the node memory.

Specified by:
retractObject in interface ObjectSink
Parameters:
handle - The fact handle.
object - The object to assert.
workingMemory - The working memory session.

updateSink

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

attach

public void attach()
Rete needs to know that this ObjectTypeNode has been added

Specified by:
attach in class BaseNode

attach

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

remove

public void remove(BaseNode node,
                   InternalWorkingMemory[] workingMemories)
Description copied from class: BaseNode
Removes the node from teh network. Usually from the parent ObjectSource or TupleSource

Specified by:
remove in class BaseNode

addShare

public void addShare()
Rete needs to know that this ObjectTypeNode has had new nodes attached to it one one of its ancestors

Overrides:
addShare in class BaseNode

createMemory

public Object createMemory(RuleBaseConfiguration config)
Creates memory for the node using PrimitiveLongMap as its optimised for storage and reteivals of Longs. However PrimitiveLongMap is not ideal for spase data. So it should be monitored incase its more optimal to switch back to a standard HashMap.

Specified by:
createMemory in interface NodeMemory

toString

public String toString()
Overrides:
toString in class BaseNode

hashCode

public int hashCode()
Uses he hashCode() of the underlying ObjectType implementation.

Overrides:
hashCode in class BaseNode

equals

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

addObjectSink

protected void addObjectSink(ObjectSink objectSink)
Description copied from class: ObjectSource
Adds the ObjectSink so that it may receive FactHandleImpl propagated from this ObjectSource.

Overrides:
addObjectSink in class ObjectSource
Parameters:
objectSink - The ObjectSink to receive propagated FactHandleImpl.

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


Copyright © 2001-2007 JBoss Inc.. All Rights Reserved.