Package org.drools.core.reteoo
Class ObjectTypeNode
- java.lang.Object
-
- org.drools.core.common.BaseNode
-
- org.drools.core.reteoo.ObjectSource
-
- org.drools.core.reteoo.ObjectTypeNode
-
- All Implemented Interfaces:
java.io.Serializable
,org.drools.base.common.NetworkNode
,ObjectSink
,Sink
- Direct Known Subclasses:
ReteObjectTypeNode
public class ObjectTypeNode extends ObjectSource implements ObjectSink
ObjectTypeNodes
are responsible for filtering and propagating the matching fact assertions propagated from the
Rete
node usingObjectType
interface. The assert and retract methods do not attempt to filter as this is the role of theRete
node which builds up a cache of matchingObjectTypdeNodes
s for each asserted object, using thematches(Object object)
method. Incorrect propagation in these methods is not checked and will result inClassCastExpcections
later on in the network. FiltersObjects
coming from theRete
using aObjectType
semantic module.- See Also:
Rete
, Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ObjectTypeNode.ExpireJob
static class
ObjectTypeNode.ExpireJobContext
static class
ObjectTypeNode.Id
-
Field Summary
Fields Modifier and Type Field Description static ObjectTypeNode.Id
DEFAULT_ID
protected org.drools.core.reteoo.ObjectTypeNode.IdGenerator
idGenerator
protected org.drools.base.base.ObjectType
objectType
TheObjectType
semantic module.-
Fields inherited from class org.drools.core.reteoo.ObjectSource
alphaNodeHashingThreshold, alphaNodeRangeIndexThreshold, declaredMask, inferredMask, sink, source
-
Fields inherited from class org.drools.core.common.BaseNode
associations, hashcode, id, memoryId, partitionId, partitionsEnabled
-
-
Constructor Summary
Constructors Constructor Description ObjectTypeNode()
ObjectTypeNode(int id, EntryPointNode source, org.drools.base.base.ObjectType objectType, BuildContext context)
Construct given a semanticObjectType
and the provided unique id.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
assertInitialFact(InternalFactHandle factHandle, PropagationContext context, ReteEvaluator reteEvaluator)
void
assertObject(InternalFactHandle factHandle, PropagationContext context, ReteEvaluator reteEvaluator)
Propagate theFactHandleimpl
through theRete
network.void
byPassModifyToBetaNode(InternalFactHandle factHandle, ModifyPreviousTuples modifyPreviousTuples, PropagationContext context, ReteEvaluator reteEvaluator)
org.drools.core.util.bitmask.BitMask
calculateDeclaredMask(org.drools.base.base.ObjectType modifiedType, java.util.List<java.lang.String> settableProperties)
protected void
checkDirty()
void
doAttach(BuildContext context)
Rete needs to know that this ObjectTypeNode has been addedprotected boolean
doRemove(RuleRemovalContext context, ReteooBuilder builder)
OTN needs to override remove to avoid releasing the node ID, since OTN are never removed from the rulebase in the current implementationstatic void
doRetractObject(InternalFactHandle factHandle, PropagationContext context, ReteEvaluator reteEvaluator)
boolean
equals(java.lang.Object object)
static void
expireLeftTuple(LeftTuple leftTuple)
static void
expireRightTuple(RightTuple rightTuple)
org.drools.base.rule.EntryPointId
getEntryPoint()
long
getExpirationOffset()
java.util.Iterator<InternalFactHandle>
getFactHandlesIterator(InternalWorkingMemory workingMemory)
org.drools.base.base.ObjectType
getObjectType()
Retrieve the semanticObjectType
differentiator.int
getOtnIdCounter()
org.drools.base.common.RuleBasePartitionId
getPartitionId()
Returns the partition ID for which this node belongs toshort
getType()
boolean
isAssignableFrom(org.drools.base.base.ObjectType objectType)
void
mergeExpirationOffset(ObjectTypeNode other)
void
modifyObject(InternalFactHandle factHandle, ModifyPreviousTuples modifyPreviousTuples, PropagationContext context, ReteEvaluator reteEvaluator)
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 opportunity for state updateObjectTypeNode.Id
nextOtnId()
void
propagateAssert(InternalFactHandle factHandle, PropagationContext context, ReteEvaluator reteEvaluator)
boolean
remove(RuleRemovalContext context, ReteooBuilder builder)
OTN needs to override remove to avoid releasing the node ID, since OTN are never removed from the rulebase in the current implementationprotected void
resetIdGenerator()
static void
retractLeftTuples(InternalFactHandle factHandle, PropagationContext context, ReteEvaluator reteEvaluator)
static void
retractLeftTuples(InternalFactHandle factHandle, PropagationContext context, ReteEvaluator reteEvaluator, int partition)
void
retractObject(InternalFactHandle factHandle, PropagationContext context, ReteEvaluator reteEvaluator)
Retract theFactHandleimpl
from theRete
network.void
retractObject(InternalFactHandle factHandle, PropagationContext context, ReteEvaluator reteEvaluator, int partition)
static void
retractRightTuples(InternalFactHandle factHandle, PropagationContext context, ReteEvaluator reteEvaluator)
static void
retractRightTuples(InternalFactHandle factHandle, PropagationContext context, ReteEvaluator reteEvaluator, int partition)
void
setExpirationOffset(long expirationOffset)
java.lang.String
toString()
void
updateSink(ObjectSink sink, PropagationContext context, InternalWorkingMemory workingMemory)
protected static void
updateTupleSinkId(ObjectTypeNode otn, ObjectSource source)
-
Methods inherited from class org.drools.core.reteoo.ObjectSource
addObjectSink, getDeclaredMask, getObjectSinkPropagator, getObjectTypeNode, getParentObjectSource, getRuleBase, initDeclaredMask, isInUse, removeObjectSink, resetInferredMask, setObjectSinkPropagator, setParentObjectSource, setPartitionId, setPartitionIdWithSinks, setSourcePartitionId, updateMask
-
Methods inherited from class org.drools.core.common.BaseNode
addAssociatedTerminal, addAssociation, addAssociation, attach, getAssociatedRules, getAssociatedTerminalsSize, getAssociationsSize, getId, getMemoryId, getSinks, hasAssociatedTerminal, hashCode, initMemoryId, isAssociatedWith, isStreamMode, removeAssociatedTerminal, removeAssociation, setId, setPartitionsEnabled, setStreamMode
-
-
-
-
Field Detail
-
objectType
protected org.drools.base.base.ObjectType objectType
TheObjectType
semantic module.
-
idGenerator
protected transient org.drools.core.reteoo.ObjectTypeNode.IdGenerator idGenerator
-
DEFAULT_ID
public static final ObjectTypeNode.Id DEFAULT_ID
-
-
Constructor Detail
-
ObjectTypeNode
public ObjectTypeNode()
-
ObjectTypeNode
public ObjectTypeNode(int id, EntryPointNode source, org.drools.base.base.ObjectType objectType, BuildContext context)
Construct given a semanticObjectType
and the provided unique id. AllObjectTypdeNode
have node memory.- Parameters:
id
- The unique id for the node.objectType
- The semantic object-type differentiator.
-
-
Method Detail
-
getOtnIdCounter
public int getOtnIdCounter()
-
getType
public short getType()
- Specified by:
getType
in interfaceorg.drools.base.common.NetworkNode
-
getObjectType
public org.drools.base.base.ObjectType getObjectType()
Retrieve the semanticObjectType
differentiator.- Returns:
- The semantic
ObjectType
differentiator.
-
getPartitionId
public org.drools.base.common.RuleBasePartitionId getPartitionId()
Returns the partition ID for which this node belongs to- Specified by:
getPartitionId
in interfaceorg.drools.base.common.NetworkNode
- Overrides:
getPartitionId
in classBaseNode
-
calculateDeclaredMask
public org.drools.core.util.bitmask.BitMask calculateDeclaredMask(org.drools.base.base.ObjectType modifiedType, java.util.List<java.lang.String> settableProperties)
- Specified by:
calculateDeclaredMask
in classObjectSource
-
isAssignableFrom
public boolean isAssignableFrom(org.drools.base.base.ObjectType objectType)
-
assertInitialFact
public void assertInitialFact(InternalFactHandle factHandle, PropagationContext context, ReteEvaluator reteEvaluator)
-
checkDirty
protected void checkDirty()
-
assertObject
public void assertObject(InternalFactHandle factHandle, PropagationContext context, ReteEvaluator reteEvaluator)
Propagate theFactHandleimpl
through theRete
network. AllFactHandleImpl
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 interfaceObjectSink
- Parameters:
factHandle
- The fact handle.context
- The propagation context.reteEvaluator
- The working memory session.
-
propagateAssert
public void propagateAssert(InternalFactHandle factHandle, PropagationContext context, ReteEvaluator reteEvaluator)
-
retractObject
public void retractObject(InternalFactHandle factHandle, PropagationContext context, ReteEvaluator reteEvaluator)
Retract theFactHandleimpl
from theRete
network. Also remove theFactHandleImpl
from the node memory.- Parameters:
factHandle
- The fact handle.context
- The propagation context.reteEvaluator
- The working memory session.
-
retractObject
public void retractObject(InternalFactHandle factHandle, PropagationContext context, ReteEvaluator reteEvaluator, int partition)
-
doRetractObject
public static void doRetractObject(InternalFactHandle factHandle, PropagationContext context, ReteEvaluator reteEvaluator)
-
expireLeftTuple
public static void expireLeftTuple(LeftTuple leftTuple)
-
expireRightTuple
public static void expireRightTuple(RightTuple rightTuple)
-
retractLeftTuples
public static void retractLeftTuples(InternalFactHandle factHandle, PropagationContext context, ReteEvaluator reteEvaluator)
-
retractLeftTuples
public static void retractLeftTuples(InternalFactHandle factHandle, PropagationContext context, ReteEvaluator reteEvaluator, int partition)
-
retractRightTuples
public static void retractRightTuples(InternalFactHandle factHandle, PropagationContext context, ReteEvaluator reteEvaluator)
-
retractRightTuples
public static void retractRightTuples(InternalFactHandle factHandle, PropagationContext context, ReteEvaluator reteEvaluator, int partition)
-
resetIdGenerator
protected void resetIdGenerator()
-
modifyObject
public void modifyObject(InternalFactHandle factHandle, ModifyPreviousTuples modifyPreviousTuples, PropagationContext context, ReteEvaluator reteEvaluator)
- Specified by:
modifyObject
in interfaceObjectSink
-
updateSink
public void updateSink(ObjectSink sink, PropagationContext context, InternalWorkingMemory workingMemory)
- Specified by:
updateSink
in classObjectSource
-
getFactHandlesIterator
public java.util.Iterator<InternalFactHandle> getFactHandlesIterator(InternalWorkingMemory workingMemory)
-
doAttach
public void doAttach(BuildContext context)
Rete needs to know that this ObjectTypeNode has been added
-
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 opportunity for state update- Overrides:
networkUpdated
in classObjectSource
-
updateTupleSinkId
protected static void updateTupleSinkId(ObjectTypeNode otn, ObjectSource source)
-
nextOtnId
public ObjectTypeNode.Id nextOtnId()
-
remove
public boolean remove(RuleRemovalContext context, ReteooBuilder builder)
OTN needs to override remove to avoid releasing the node ID, since OTN are never removed from the rulebase in the current implementation
-
doRemove
protected boolean doRemove(RuleRemovalContext context, ReteooBuilder builder)
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 classObjectSource
-
equals
public boolean equals(java.lang.Object object)
- Overrides:
equals
in classjava.lang.Object
-
getEntryPoint
public org.drools.base.rule.EntryPointId getEntryPoint()
- Returns:
- the entryPoint
-
getExpirationOffset
public long getExpirationOffset()
-
setExpirationOffset
public void setExpirationOffset(long expirationOffset)
-
mergeExpirationOffset
public void mergeExpirationOffset(ObjectTypeNode other)
-
byPassModifyToBetaNode
public void byPassModifyToBetaNode(InternalFactHandle factHandle, ModifyPreviousTuples modifyPreviousTuples, PropagationContext context, ReteEvaluator reteEvaluator)
- Specified by:
byPassModifyToBetaNode
in interfaceObjectSink
-
-