Drools :: Core 6.0.0.Beta5

org.drools.core.reteoo
Class WindowNode

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

public class WindowNode
extends ObjectSource
implements ObjectSinkNode, RightTupleSink, MemoryFactory

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.core.reteoo.ObjectSource
declaredMask, inferredMask, sink, source
 
Fields inherited from class org.drools.core.common.BaseNode
associations, id, partitionId, partitionsEnabled, streamMode
 
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 pctx, 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, InternalWorkingMemory wm)
          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
 ObjectTypeNode.Id getRightInputOtnId()
           
 short getType()
           
 int hashCode()
          The hashCode return is simply the unique id of the node.
 void modifyObject(InternalFactHandle factHandle, ModifyPreviousTuples modifyPreviousTuples, PropagationContext context, InternalWorkingMemory wm)
           
 void modifyRightTuple(RightTuple rightTuple, PropagationContext context, InternalWorkingMemory workingMemory)
           
 void readExternal(ObjectInput in)
           
 void retractRightTuple(RightTuple rightTuple, PropagationContext pctx, InternalWorkingMemory wm)
           
 void setNextObjectSinkNode(ObjectSinkNode next)
          Sets the next node
 void setPreviousObjectSinkNode(ObjectSinkNode previous)
          Sets the previous node
 void setRightInputOtnId(ObjectTypeNode.Id rightInputOtnId)
           
 String toString()
           
 void updateSink(ObjectSink sink, PropagationContext context, InternalWorkingMemory wm)
           
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class org.drools.core.reteoo.ObjectSource
addObjectSink, doCollectAncestors, doRemove, getDeclaredMask, getObjectTypeNode, getParentObjectSource, getSinkPropagator, initDeclaredMask, isInUse, networkUpdated, removeObjectSink, resetInferredMask, updateMask
 
Methods inherited from class org.drools.core.common.BaseNode
addAssociation, attach, collectAncestors, getAssociations, getId, getPartitionId, isStreamMode, remove, 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
 

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
Specified by:
getType in interface RightTupleSink

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

assertObject

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

retractRightTuple

public void retractRightTuple(RightTuple rightTuple,
                              PropagationContext pctx,
                              InternalWorkingMemory wm)
Specified by:
retractRightTuple in interface RightTupleSink

modifyRightTuple

public void modifyRightTuple(RightTuple rightTuple,
                             PropagationContext context,
                             InternalWorkingMemory workingMemory)
Specified by:
modifyRightTuple in interface RightTupleSink

modifyObject

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

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 wm)
Specified by:
updateSink in class ObjectSource

createMemory

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

Specified by:
createMemory in interface MemoryFactory

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

getRightInputOtnId

public ObjectTypeNode.Id getRightInputOtnId()
Specified by:
getRightInputOtnId in interface RightTupleSink

setRightInputOtnId

public void setRightInputOtnId(ObjectTypeNode.Id rightInputOtnId)

Drools :: Core 6.0.0.Beta5

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