Drools :: Core 6.1.0.Beta1

org.drools.core.reteoo
Class ObjectTypeNode

java.lang.Object
  extended by org.drools.core.common.BaseNode
      extended by org.drools.core.reteoo.ObjectSource
          extended by org.drools.core.reteoo.ObjectTypeNode
All Implemented Interfaces:
Externalizable, Serializable, MemoryFactory, NetworkNode, ObjectSink, Sink
Direct Known Subclasses:
ReteObjectTypeNode, TraitObjectTypeNode, TraitProxyObjectTypeNode

public class ObjectTypeNode
extends ObjectSource
implements ObjectSink, Externalizable, MemoryFactory

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

Nested Class Summary
static class ObjectTypeNode.ExpireJob
           
static class ObjectTypeNode.ExpireJobContext
           
static class ObjectTypeNode.ExpireJobContextTimerInputMarshaller
           
static class ObjectTypeNode.ExpireJobContextTimerOutputMarshaller
           
static class ObjectTypeNode.Id
           
static class ObjectTypeNode.ObjectTypeNodeMemory
           
 
Field Summary
protected  CompiledNetwork compiledNetwork
           
static ObjectTypeNode.Id DEFAULT_ID
           
protected  boolean dirty
           
protected  org.drools.core.reteoo.ObjectTypeNode.IdGenerator idGenerator
           
static ObjectTypeNode.ExpireJob job
           
protected  ObjectType objectType
          The ObjectType semantic module.
 
Fields inherited from class org.drools.core.reteoo.ObjectSource
declaredMask, inferredMask, sink, source
 
Fields inherited from class org.drools.core.common.BaseNode
associations, id, partitionId, partitionsEnabled, streamMode
 
Constructor Summary
ObjectTypeNode()
           
ObjectTypeNode(int id, EntryPointNode source, ObjectType objectType, BuildContext context)
          Construct given a semantic ObjectType and the provided unique id.
 
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, InternalWorkingMemory wm)
          Creates memory for the node using PrimitiveLongMap as its optimised for storage and reteivals of Longs.
protected  void doRemove(RuleRemovalContext context, ReteooBuilder builder, 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
static void doRetractObject(InternalFactHandle factHandle, PropagationContext context, InternalWorkingMemory workingMemory)
           
 boolean equals(Object object)
           
 EntryPointId getEntryPoint()
           
 long getExpirationOffset()
           
 ObjectType getObjectType()
          Retrieve the semantic ObjectType differentiator.
 int getOtnIdCounter()
           
 short getType()
           
 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
 ObjectTypeNode.Id nextOtnId()
           
 void readExternal(ObjectInput in)
           
 void remove(RuleRemovalContext context, ReteooBuilder builder, 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
protected  void resetIdGenerator()
           
 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)
           
protected static void updateTupleSinkId(ObjectTypeNode otn, ObjectSource source)
           
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class org.drools.core.reteoo.ObjectSource
addObjectSink, getDeclaredMask, getObjectTypeNode, getParentObjectSource, getSinkPropagator, initDeclaredMask, isInUse, removeObjectSink, resetInferredMask, updateMask
 
Methods inherited from class org.drools.core.common.BaseNode
addAssociation, attach, getAssociations, getId, getPartitionId, isStreamMode, removeAssociation, setId, setPartitionId
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.drools.core.common.NetworkNode
getAssociations, getId, getPartitionId
 
Methods inherited from interface org.drools.core.common.MemoryFactory
getId
 

Field Detail

objectType

protected ObjectType objectType
The ObjectType semantic module.


job

public static final transient ObjectTypeNode.ExpireJob job

compiledNetwork

protected CompiledNetwork compiledNetwork

dirty

protected transient boolean dirty

idGenerator

protected transient org.drools.core.reteoo.ObjectTypeNode.IdGenerator idGenerator

DEFAULT_ID

public static ObjectTypeNode.Id DEFAULT_ID
Constructor Detail

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.
Method Detail

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

getType

public short getType()
Specified by:
getType in interface NetworkNode

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.
context - The propagation context.
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:
factHandle - The fact handle.
context - The propagation context.
workingMemory - The working memory session.

doRetractObject

public static void doRetractObject(InternalFactHandle factHandle,
                                   PropagationContext context,
                                   InternalWorkingMemory workingMemory)

resetIdGenerator

protected void resetIdGenerator()

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

updateTupleSinkId

protected static void updateTupleSinkId(ObjectTypeNode otn,
                                        ObjectSource source)

nextOtnId

public ObjectTypeNode.Id nextOtnId()

remove

public void remove(RuleRemovalContext context,
                   ReteooBuilder builder,
                   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

doRemove

protected void doRemove(RuleRemovalContext context,
                        ReteooBuilder builder,
                        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,
                           InternalWorkingMemory wm)
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 MemoryFactory

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 EntryPointId 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

Drools :: Core 6.1.0.Beta1

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