BEA Systems, Inc.

com.beasys.commerce.axiom.reasoning.rules.jrules
Class JRulesContext

java.lang.Object
  |
  +--com.beasys.commerce.axiom.reasoning.rules.jrules.JRulesContext

public class JRulesContext
extends java.lang.Object
implements Context

Implements a JRules context.


Constructor Summary
JRulesContext(ilog.rules.IlrContext contextDelegate)
          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.
 java.util.Set getObjects(java.lang.Class filter)
          Gets a filtered list of objects from the context
 void halt()
          Halts firing of rules.
 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.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JRulesContext

public JRulesContext(ilog.rules.IlrContext contextDelegate)
              throws java.lang.IllegalArgumentException
Constructor
Parameters:
contextDelegate - The IlrContext to which this context will delegate
Throws:
java.lang.IllegalArgumentException - Thrown if contextDelegate is null
Method Detail

addObject

public void addObject(java.lang.Object object)
               throws java.lang.IllegalArgumentException,
                      java.lang.IllegalStateException,
                      ServiceProviderException
Adds an object to the context's working memory.
Specified by:
addObject in interface Context
Parameters:
object - The object to be added.
Throws:
java.lang.IllegalArgumentException - Thrown if object is null
java.lang.IllegalStateException - Thrown if called after "release" has been called
ServiceProviderException - Thrown if unable to add the object

fireAllRules

public int fireAllRules()
                 throws java.lang.IllegalStateException,
                        ServiceProviderException
Fires all of the rules which are active for the context.
Specified by:
fireAllRules in interface Context
Returns:
The number of rules actually fired (-1 if unknown).
Throws:
java.lang.IllegalStateException - Thrown if called after "release" has been called
ServiceProviderException - Thrown if unable to fire all of the rules.

fireRules

public int fireRules(int maxRules)
              throws java.lang.IllegalArgumentException,
                     java.lang.IllegalStateException,
                     ServiceProviderException
Fires rules until there are no more to fire or until maxRules rules have been fired.
Specified by:
fireRules in interface Context
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
java.lang.IllegalStateException - Thrown if called after "release" has been called
ServiceProviderException - Thrown if unable to fire the rules

getObjects

public java.util.Set getObjects(java.lang.Class filter)
                         throws java.lang.IllegalArgumentException,
                                java.lang.IllegalStateException,
                                ServiceProviderException
Gets a filtered list of objects from the context
Specified by:
getObjects in interface 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
java.lang.IllegalStateException - Thrown if called after "release" has been called
ServiceProviderException - Thrown if unable to get objects

halt

public void halt()
          throws java.lang.IllegalStateException,
                 ServiceProviderException
Halts firing of rules.
Specified by:
halt in interface Context
Throws:
java.lang.IllegalStateException - Thrown if called after "release" has been called
ServiceProviderException - Thrown always

initialize

public void initialize()
                throws java.lang.IllegalStateException,
                       ServiceProviderException
Initializes the context.
Specified by:
initialize in interface Context
Throws:
java.lang.IllegalStateException - Thrown if called after "release" has been called
ServiceProviderException - Thrown if unable to initialize.

release

public void release()
             throws ServiceProviderException
Release the context and any resources it might be using.
Specified by:
release in interface Context
Throws:
ServiceProviderException - thrown if an error occurs during the release TODO: 1. Restore call to contextDelegate.end()

removeAllObjects

public void removeAllObjects()
                      throws java.lang.IllegalStateException,
                             ServiceProviderException
Removes all objects from the context's working memory.
Specified by:
removeAllObjects in interface Context
Throws:
java.lang.IllegalStateException - Thrown if called after "release" has been called
ServiceProviderException - Thrown if unable to remove all objects

BEA Systems, Inc.

Copyright © 2000 BEA Systems, Inc. All Rights Reserved