org.drools.reteoo
Class WindowNode

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

public class WindowNode
extends ObjectSource
implements ObjectSinkNode, NodeMemory

WindowNodes are nodes in the Rete network used to manage windows. They support multiple types of windows, like sliding windows, tumbling windows, etc. This class must act as a lock-gate for all working memory actions on it and propagated down the network in this branch, as there can be concurrent threads propagating events and expiring events working on this node at the same time. It requires it to be thread safe.

See Also:
Serialized Form

Nested Class Summary
static class WindowNode.WindowMemory
           
 
Field Summary
 
Fields inherited from class org.drools.reteoo.ObjectSource
declaredMask, inferredMask, sink, source
 
Fields inherited from class org.drools.common.BaseNode
associations, id, partitionId, partitionsEnabled
 
Constructor Summary
WindowNode()
           
WindowNode(int id, List<AlphaNodeFieldConstraint> constraints, List<Behavior> behaviors, ObjectSource objectSource, BuildContext context)
          Construct a WindowNode with a unique id using the provided list of AlphaNodeFieldConstraint and the given ObjectSource.
 
Method Summary
 void assertObject(InternalFactHandle factHandle, PropagationContext context, InternalWorkingMemory workingMemory)
           
 void attach(BuildContext context)
          Attaches the node into the network.
 void byPassModifyToBetaNode(InternalFactHandle factHandle, ModifyPreviousTuples modifyPreviousTuples, PropagationContext context, InternalWorkingMemory workingMemory)
           
 long calculateDeclaredMask(List<String> settableProperties)
           
 Memory createMemory(RuleBaseConfiguration config)
          Creates the WindowNode's memory.
 boolean equals(Object object)
           
 Behavior[] getBehaviors()
          Returns the list of behaviors for this window node
 List<AlphaNodeFieldConstraint> getConstraints()
          Returns the FieldConstraints
 EntryPoint getEntryPoint()
           
 ObjectSinkNode getNextObjectSinkNode()
          Returns the next node
 ObjectSinkNode getPreviousObjectSinkNode()
          Returns the previous node
 short getType()
           
 int hashCode()
          The hashCode return is simply the unique id of the node.
 void modifyObject(InternalFactHandle factHandle, ModifyPreviousTuples modifyPreviousTuples, PropagationContext context, InternalWorkingMemory workingMemory)
           
 void readExternal(ObjectInput in)
           
 void retractObject(InternalFactHandle factHandle, PropagationContext context, InternalWorkingMemory workingMemory)
          Retract the FactHandle from the WindowNode.
 void setNextObjectSinkNode(ObjectSinkNode next)
          Sets the next node
 void setPreviousObjectSinkNode(ObjectSinkNode previous)
          Sets the previous node
 String toString()
           
 void updateSink(ObjectSink sink, PropagationContext context, InternalWorkingMemory workingMemory)
           
 void updateSinkOnAttach(BuildContext context, PropagationContext propagationContext, InternalWorkingMemory workingMemory)
           
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class org.drools.reteoo.ObjectSource
addObjectSink, doCollectAncestors, doRemove, getDeclaredMask, getObjectTypeNode, getParentObjectSource, getSinkPropagator, initDeclaredMask, isInUse, needsMaskUpdate, networkUpdated, removeObjectSink, resetInferredMask, updateMask
 
Methods inherited from class org.drools.common.BaseNode
addAssociation, attach, collectAncestors, getAssociations, getId, getPartitionId, remove, removeAssociation, setPartitionId, updateSinkOnAttach
 
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
 
Methods inherited from interface org.drools.common.NodeMemory
getId
 

Constructor Detail

WindowNode

public WindowNode()

WindowNode

public WindowNode(int id,
                  List<AlphaNodeFieldConstraint> constraints,
                  List<Behavior> behaviors,
                  ObjectSource objectSource,
                  BuildContext context)
Construct a WindowNode with a unique id using the provided list of AlphaNodeFieldConstraint and the given ObjectSource.

Parameters:
id - Node's ID
constraints - Node's constraints
behaviors - list of behaviors for this window node
objectSource - Node's object source
Method Detail

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

getConstraints

public List<AlphaNodeFieldConstraint> getConstraints()
Returns the FieldConstraints

Returns:
FieldConstraints

getBehaviors

public Behavior[] getBehaviors()
Returns the list of behaviors for this window node

Returns:

attach

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

Specified by:
attach in class BaseNode

updateSinkOnAttach

public void updateSinkOnAttach(BuildContext context,
                               PropagationContext propagationContext,
                               InternalWorkingMemory workingMemory)
Specified by:
updateSinkOnAttach in class BaseNode

assertObject

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

modifyObject

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

retractObject

public void retractObject(InternalFactHandle factHandle,
                          PropagationContext context,
                          InternalWorkingMemory workingMemory)
Retract the FactHandle from the WindowNode. This method is for the node benefit only as the node itself will not propagate retracts down the network, relying on the standard Rete retract algorithm implemented by the ObjectTypeNode to do it.

Parameters:
factHandle - The fact handle.
context - The propagation context
workingMemory - The working memory session.

byPassModifyToBetaNode

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

updateSink

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

createMemory

public Memory createMemory(RuleBaseConfiguration config)
Creates the WindowNode's memory.

Specified by:
createMemory in interface NodeMemory

toString

public String toString()
Overrides:
toString in class BaseNode

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

getNextObjectSinkNode

public ObjectSinkNode getNextObjectSinkNode()
Returns the next node

Specified by:
getNextObjectSinkNode in interface ObjectSinkNode
Returns:
The next ObjectSinkNode

setNextObjectSinkNode

public void setNextObjectSinkNode(ObjectSinkNode next)
Sets the next node

Specified by:
setNextObjectSinkNode in interface ObjectSinkNode
Parameters:
next - The next ObjectSinkNode

getPreviousObjectSinkNode

public ObjectSinkNode getPreviousObjectSinkNode()
Returns the previous node

Specified by:
getPreviousObjectSinkNode in interface ObjectSinkNode
Returns:
The previous ObjectSinkNode

setPreviousObjectSinkNode

public void setPreviousObjectSinkNode(ObjectSinkNode previous)
Sets the previous node

Specified by:
setPreviousObjectSinkNode in interface ObjectSinkNode
Parameters:
previous - The previous ObjectSinkNode

getEntryPoint

public EntryPoint getEntryPoint()

calculateDeclaredMask

public long calculateDeclaredMask(List<String> settableProperties)
Specified by:
calculateDeclaredMask in class ObjectSource


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