org.drools.reteoo
Class ObjectTypeNode
java.lang.Object
org.drools.common.BaseNode
org.drools.reteoo.ObjectSource
org.drools.reteoo.ObjectTypeNode
- All Implemented Interfaces:
- Externalizable, Serializable, NetworkNode, NodeMemory, ObjectSink, Sink
public class ObjectTypeNode
- extends ObjectSource
- implements ObjectSink, Externalizable, 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.
- See Also:
Rete,
Serialized Form
|
Method Summary |
void |
assertObject(InternalFactHandle factHandle,
PropagationContext context,
InternalWorkingMemory workingMemory)
Propagate the FactHandleimpl through the Rete network. |
void |
attach(BuildContext context)
Rete needs to know that this ObjectTypeNode has been added |
void |
byPassModifyToBetaNode(InternalFactHandle factHandle,
ModifyPreviousTuples modifyPreviousTuples,
PropagationContext context,
InternalWorkingMemory workingMemory)
|
long |
calculateDeclaredMask(List<String> settableProperties)
|
Memory |
createMemory(RuleBaseConfiguration config)
Creates memory for the node using PrimitiveLongMap as its optimised for storage and reteivals of Longs. |
protected void |
doRemove(RuleRemovalContext context,
ReteooBuilder builder,
BaseNode node,
InternalWorkingMemory[] workingMemories)
OTN needs to override remove to avoid releasing the node ID, since OTN are
never removed from the rulebase in the current implementation |
boolean |
equals(Object object)
|
EntryPoint |
getEntryPoint()
|
long |
getExpirationOffset()
|
ObjectType |
getObjectType()
Retrieve the semantic ObjectType differentiator. |
int |
getOtnIdCounter()
|
int |
hashCode()
Uses he hashCode() of the underlying ObjectType implementation. |
boolean |
isAssignableFrom(ObjectType objectType)
|
boolean |
isObjectMemoryEnabled()
|
void |
modifyObject(InternalFactHandle factHandle,
ModifyPreviousTuples modifyPreviousTuples,
PropagationContext context,
InternalWorkingMemory workingMemory)
|
void |
networkUpdated(UpdateContext updateContext)
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 |
int |
nextOtnId()
|
void |
readExternal(ObjectInput in)
|
void |
remove(RuleRemovalContext context,
ReteooBuilder builder,
BaseNode node,
InternalWorkingMemory[] workingMemories)
OTN needs to override remove to avoid releasing the node ID, since OTN are
never removed from the rulebase in the current implementation |
void |
retractObject(InternalFactHandle factHandle,
PropagationContext context,
InternalWorkingMemory workingMemory)
Retract the FactHandleimpl from the Rete network. |
void |
setCompiledNetwork(CompiledNetwork compiledNetwork)
|
void |
setExpirationOffset(long expirationOffset)
|
void |
setObjectMemoryEnabled(boolean objectMemoryEnabled)
|
String |
toString()
|
void |
updateSink(ObjectSink sink,
PropagationContext context,
InternalWorkingMemory workingMemory)
|
void |
writeExternal(ObjectOutput out)
|
job
public static final transient ObjectTypeNode.ExpireJob job
ObjectTypeNode
public ObjectTypeNode()
ObjectTypeNode
public ObjectTypeNode(int id,
EntryPointNode source,
ObjectType objectType,
BuildContext context)
- 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.
getOtnIdCounter
public int getOtnIdCounter()
readExternal
public void readExternal(ObjectInput in)
throws IOException,
ClassNotFoundException
- Specified by:
readExternal in interface Externalizable- Overrides:
readExternal in class ObjectSource
- Throws:
IOException
ClassNotFoundException
writeExternal
public void writeExternal(ObjectOutput out)
throws IOException
- Specified by:
writeExternal in interface Externalizable- Overrides:
writeExternal in class ObjectSource
- Throws:
IOException
getObjectType
public ObjectType getObjectType()
- Retrieve the semantic
ObjectType differentiator.
- Returns:
- The semantic
ObjectType differentiator.
calculateDeclaredMask
public long calculateDeclaredMask(List<String> settableProperties)
- Specified by:
calculateDeclaredMask in class ObjectSource
isAssignableFrom
public boolean isAssignableFrom(ObjectType objectType)
setCompiledNetwork
public void setCompiledNetwork(CompiledNetwork compiledNetwork)
assertObject
public void assertObject(InternalFactHandle factHandle,
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:
factHandle - The fact handle.object - The object to assert.workingMemory - The working memory session.
retractObject
public void retractObject(InternalFactHandle factHandle,
PropagationContext context,
InternalWorkingMemory workingMemory)
- Retract the
FactHandleimpl from the Rete network. Also remove the
FactHandleImpl from the node memory.
- Parameters:
rightTuple - The fact handle.object - The object to assert.workingMemory - The working memory session.
modifyObject
public void modifyObject(InternalFactHandle factHandle,
ModifyPreviousTuples modifyPreviousTuples,
PropagationContext context,
InternalWorkingMemory workingMemory)
- Specified by:
modifyObject in interface ObjectSink
updateSink
public void updateSink(ObjectSink sink,
PropagationContext context,
InternalWorkingMemory workingMemory)
- Specified by:
updateSink in class ObjectSource
attach
public void attach(BuildContext context)
- Rete needs to know that this ObjectTypeNode has been added
- Specified by:
attach in class BaseNode
networkUpdated
public void networkUpdated(UpdateContext updateContext)
- 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
nextOtnId
public int nextOtnId()
remove
public void remove(RuleRemovalContext context,
ReteooBuilder builder,
BaseNode node,
InternalWorkingMemory[] workingMemories)
- OTN needs to override remove to avoid releasing the node ID, since OTN are
never removed from the rulebase in the current implementation
- Overrides:
remove in class BaseNode
- See Also:
BaseNode.remove(org.drools.reteoo.RuleRemovalContext, org.drools.reteoo.ReteooBuilder, org.drools.common.BaseNode, org.drools.common.InternalWorkingMemory[])
doRemove
protected void doRemove(RuleRemovalContext context,
ReteooBuilder builder,
BaseNode node,
InternalWorkingMemory[] workingMemories)
- OTN needs to override remove to avoid releasing the node ID, since OTN are
never removed from the rulebase in the current implementation
- Overrides:
doRemove in class ObjectSource
createMemory
public Memory 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
isObjectMemoryEnabled
public boolean isObjectMemoryEnabled()
setObjectMemoryEnabled
public void setObjectMemoryEnabled(boolean objectMemoryEnabled)
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
getEntryPoint
public EntryPoint getEntryPoint()
- Returns:
- the entryPoint
getExpirationOffset
public long getExpirationOffset()
setExpirationOffset
public void setExpirationOffset(long expirationOffset)
byPassModifyToBetaNode
public void byPassModifyToBetaNode(InternalFactHandle factHandle,
ModifyPreviousTuples modifyPreviousTuples,
PropagationContext context,
InternalWorkingMemory workingMemory)
- Specified by:
byPassModifyToBetaNode in interface ObjectSink
Copyright © 2001-2012 JBoss by Red Hat. All Rights Reserved.