Package org.drools.core.rule
Class SlidingTimeWindow
- java.lang.Object
-
- org.drools.core.rule.SlidingTimeWindow
-
- All Implemented Interfaces:
java.io.Externalizable
,java.io.Serializable
,java.lang.Cloneable
,org.drools.base.rule.Behavior
,org.drools.base.rule.RuleComponent
,BehaviorRuntime
public class SlidingTimeWindow extends java.lang.Object implements java.io.Externalizable, BehaviorRuntime
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SlidingTimeWindow.BehaviorExpireWMAction
static class
SlidingTimeWindow.BehaviorJob
static class
SlidingTimeWindow.BehaviorJobContext
static class
SlidingTimeWindow.SlidingTimeWindowContext
-
Constructor Summary
Constructors Constructor Description SlidingTimeWindow()
SlidingTimeWindow(long size)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
assertFact(java.lang.Object context, org.kie.api.runtime.rule.FactHandle fact, PropagationContext pctx, ReteEvaluator reteEvaluator)
Makes the behavior aware of the new fact entering behavior's scopeBehaviorContext
createContext()
Creates the context object associated with this behavior.void
expireFacts(java.lang.Object context, PropagationContext pctx, ReteEvaluator reteEvaluator)
A callback method that allows behaviors to expire factslong
getExpirationOffset()
Some behaviors might change the expiration offset for the associated fact type.long
getSize()
org.drools.base.rule.Behavior.BehaviorType
getType()
Returns the type of the behaviorprotected boolean
isExpired(long currentTime, DefaultEventHandle handle)
void
readExternal(java.io.ObjectInput in)
void
retractFact(java.lang.Object context, org.kie.api.runtime.rule.FactHandle fact, PropagationContext pctx, ReteEvaluator reteEvaluator)
Removes a right tuple from the behavior's scopevoid
setSize(long size)
void
setWindowNode(WindowNode windowNode)
java.lang.String
toString()
protected void
updateNextExpiration(InternalFactHandle fact, ReteEvaluator reteEvaluator, BehaviorContext context, int nodeId)
void
writeExternal(java.io.ObjectOutput out)
-
-
-
Method Detail
-
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
- Specified by:
readExternal
in interfacejava.io.Externalizable
- Throws:
java.io.IOException
java.lang.ClassNotFoundException
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
- Specified by:
writeExternal
in interfacejava.io.Externalizable
- Throws:
java.io.IOException
-
getType
public org.drools.base.rule.Behavior.BehaviorType getType()
Description copied from interface:BehaviorRuntime
Returns the type of the behavior- Specified by:
getType
in interfaceorg.drools.base.rule.Behavior
- Specified by:
getType
in interfaceBehaviorRuntime
-
setWindowNode
public void setWindowNode(WindowNode windowNode)
-
getSize
public long getSize()
- Returns:
- the size
-
setSize
public void setSize(long size)
- Parameters:
size
- the size to set
-
createContext
public BehaviorContext createContext()
Description copied from interface:BehaviorRuntime
Creates the context object associated with this behavior. The object is given as a parameter in all behavior call backs.- Specified by:
createContext
in interfaceBehaviorRuntime
-
assertFact
public boolean assertFact(java.lang.Object context, org.kie.api.runtime.rule.FactHandle fact, PropagationContext pctx, ReteEvaluator reteEvaluator)
Description copied from interface:BehaviorRuntime
Makes the behavior aware of the new fact entering behavior's scope- Specified by:
assertFact
in interfaceBehaviorRuntime
- Parameters:
context
- The behavior context objectfact
- The new fact entering behavior's scope- Returns:
- true if the propagation should continue, false otherwise. I.e., the behaviour has veto power over the fact propagation, and prevents the propagation to continue if returns false on this method.
-
retractFact
public void retractFact(java.lang.Object context, org.kie.api.runtime.rule.FactHandle fact, PropagationContext pctx, ReteEvaluator reteEvaluator)
Description copied from interface:BehaviorRuntime
Removes a right tuple from the behavior's scope- Specified by:
retractFact
in interfaceBehaviorRuntime
- Parameters:
context
- The behavior context objectfact
- The fact leaving the behavior's scope
-
expireFacts
public void expireFacts(java.lang.Object context, PropagationContext pctx, ReteEvaluator reteEvaluator)
Description copied from interface:BehaviorRuntime
A callback method that allows behaviors to expire facts- Specified by:
expireFacts
in interfaceBehaviorRuntime
-
isExpired
protected boolean isExpired(long currentTime, DefaultEventHandle handle)
-
updateNextExpiration
protected void updateNextExpiration(InternalFactHandle fact, ReteEvaluator reteEvaluator, BehaviorContext context, int nodeId)
-
getExpirationOffset
public long getExpirationOffset()
Description copied from interface:BehaviorRuntime
Some behaviors might change the expiration offset for the associated fact type. Example: time sliding windows. For these behaviors, this method must return the expiration offset associated to them.- Specified by:
getExpirationOffset
in interfaceorg.drools.base.rule.Behavior
- Specified by:
getExpirationOffset
in interfaceBehaviorRuntime
- Returns:
- the expiration offset for this behavior or -1 if they don't have a time based expiration offset.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-