BEA Systems, Inc.

com.beasys.commerce.axiom.reasoning.rules.service
Class ContextWrapper

java.lang.Object
  |
  +--com.beasys.commerce.axiom.reasoning.rules.service.ContextWrapper

public class ContextWrapper
extends java.lang.Object

Implements a wrapper for vendor-specific contexts


Field Summary
protected  long creationTime
          The creation time
protected  long expirationAge
          The expiration Age
protected  int expirationPolicy
          The expiration policy
protected  long expirationUseCount
          The use count limit
static int EXPIRE_CONTEXT_AT_AGE
          The code for the "age-limit-reached" context expiration policy
static int EXPIRE_CONTEXT_AT_USE_COUNT
          The code for the "use-limit-reached" context expiration policy
static int EXPIRE_CONTEXT_NEVER
          The code for the "never" context expiration policy
protected  long useCount
          The use count
protected  com.beasys.commerce.axiom.reasoning.rules.serviceProvider.Context wrappedContext
          The wrapped context
 
Constructor Summary
ContextWrapper()
          Constructor
 
Method Summary
 void addObject(java.lang.Object object)
          Adds an object to the context's working memory.
 int fireAllRules()
          Fires all of the rules which are active for the context.
 int fireRules(int maxRules)
          Fires rules until there are no more to fire or until maxRules rules have been fired.
 boolean getExpired()
          Gets the expired property
 java.util.Set getObjects(java.lang.Class filter)
          Gets a filtered list of objects from the context
 long getUseCount()
          Gets the use count
 void halt()
          Halts firing of rules.
 void incrementUseCount()
          Increments the usage count
 void initialize()
          Initializes the context.
 void release()
          Release the context and any resources it might be using.
 void removeAllObjects()
          Removes all objects from the context's working memory.
 void resetUseCount()
          Resets the use count to zero
 void setCreationTime()
          Sets the creation time
 void setExpirationAge(long expirationAge)
          Sets the expiration age
 void setExpirationPolicy(int expirationPolicy)
          Sets the expiration policy
 void setExpirationUseCount(long expirationUseCount)
          Sets the expiration use count
 void setWrappedContext(com.beasys.commerce.axiom.reasoning.rules.serviceProvider.Context wrappedContext)
          Sets the wrapped context
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EXPIRE_CONTEXT_NEVER

public static final int EXPIRE_CONTEXT_NEVER
The code for the "never" context expiration policy

EXPIRE_CONTEXT_AT_AGE

public static final int EXPIRE_CONTEXT_AT_AGE
The code for the "age-limit-reached" context expiration policy

EXPIRE_CONTEXT_AT_USE_COUNT

public static final int EXPIRE_CONTEXT_AT_USE_COUNT
The code for the "use-limit-reached" context expiration policy

creationTime

protected long creationTime
The creation time

expirationAge

protected long expirationAge
The expiration Age

expirationPolicy

protected int expirationPolicy
The expiration policy

expirationUseCount

protected long expirationUseCount
The use count limit

useCount

protected long useCount
The use count

wrappedContext

protected com.beasys.commerce.axiom.reasoning.rules.serviceProvider.Context wrappedContext
The wrapped context
Constructor Detail

ContextWrapper

public ContextWrapper()
Constructor
Method Detail

addObject

public void addObject(java.lang.Object object)
               throws java.lang.IllegalArgumentException,
                      RulesServiceException
Adds an object to the context's working memory.
Parameters:
object - The object to be added.
Throws:
java.lang.IllegalArgumentException - Thrown if object is null
RulesServiceException - Thrown if unable to add the object

fireAllRules

public int fireAllRules()
                 throws RulesServiceException
Fires all of the rules which are active for the context.
Returns:
The number of rules actually fired (-1 if unknown).
Throws:
RulesServiceException - Thrown if unable to fire all of the rules.

fireRules

public int fireRules(int maxRules)
              throws java.lang.IllegalArgumentException,
                     RulesServiceException
Fires rules until there are no more to fire or until maxRules rules have been fired.
Parameters:
maxRules - The maximum number of rules to fire
Returns:
The number of rules fired (-1 if unknown).
Throws:
java.lang.IllegalArgumentException - Thrown if maxRules is negative
RulesServiceException - Thrown if unable to fire the rules

getExpired

public boolean getExpired()
Gets the expired property
Returns:
True if expired, false otherwise

getObjects

public java.util.Set getObjects(java.lang.Class filter)
                         throws java.lang.IllegalArgumentException,
                                RulesServiceException
Gets a filtered list of objects from the context
Parameters:
clsFilter - the list of Classes which describe what type of objects to return from the working memory.
Returns:
A set of objects which passed the filter
Throws:
java.lang.IllegalArgumentException - Thrown if filter is null
RulesServiceException - Thrown if unable to get objects

getUseCount

public long getUseCount()
Gets the use count
Returns:
The use count

halt

public void halt()
          throws RulesServiceException
Halts firing of rules. Some rules engines allow the rule firing to be interrupted. If this context does not support 'halts' then it will throw an exception.
Throws:
RulesServiceException - Thrown if unable to halt (e.g. the context does not support 'halts')

incrementUseCount

public void incrementUseCount()
Increments the usage count

initialize

public void initialize()
                throws RulesServiceException
Initializes the context.
Throws:
RulesServiceException - Thrown if unable to initialize.

release

public void release()
             throws RulesServiceException
Release the context and any resources it might be using.
Throws:
RulesServiceException - thrown if an error occurs during the release

removeAllObjects

public void removeAllObjects()
                      throws RulesServiceException
Removes all objects from the context's working memory.
Throws:
RulesServiceException - Thrown if unable to remove all objects

resetUseCount

public void resetUseCount()
Resets the use count to zero

setCreationTime

public void setCreationTime()
Sets the creation time

setExpirationAge

public void setExpirationAge(long expirationAge)
                      throws java.lang.IllegalArgumentException
Sets the expiration age
Parameters:
expirationAge - The expiration age
Throws:
java.lang.IllegalArgumentException - Thrown if expirationAge is negative

setExpirationPolicy

public void setExpirationPolicy(int expirationPolicy)
                         throws java.lang.IllegalArgumentException
Sets the expiration policy
Parameters:
expirationPolicy - The expiration policy
Throws:
java.lang.IllegalArgumentException - Thrown if expirationPolicy is invalid

setExpirationUseCount

public void setExpirationUseCount(long expirationUseCount)
                           throws java.lang.IllegalArgumentException
Sets the expiration use count
Parameters:
expirationUseCount - The expiration use count
Throws:
java.lang.IllegalArgumentException - Thrown if expirationUseCount is negative

setWrappedContext

public void setWrappedContext(com.beasys.commerce.axiom.reasoning.rules.serviceProvider.Context wrappedContext)
                       throws java.lang.IllegalArgumentException
Sets the wrapped context
Parameters:
wrappedContext - The wrapped context
Throws:
java.lang.IllegalArgumentException - Thrown if wrappedContext is null

BEA Systems, Inc.

Copyright © 2000 BEA Systems, Inc. All Rights Reserved