BEA Systems, Inc.

com.beasys.commerce.axiom.reasoning.rules.serviceProvider
Interface Context

All Known Implementing Classes:
JRulesContext

public interface Context

Specifies the behavior for a rules engine context.


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.
 

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.
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.
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.
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
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. Some rules engines allow the rule firing to be interrupted. If this context does not support 'halts' then it will throw an exception.
Throws:
java.lang.IllegalStateException - Thrown if called after "release" has been called
ServiceProviderException - Thrown if unable to halt (e.g. the context does not support 'halts')

initialize

public void initialize()
                throws java.lang.IllegalStateException,
                       ServiceProviderException
Initializes the 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.
Throws:
ServiceProviderException - thrown if an error occurs during the release

removeAllObjects

public void removeAllObjects()
                      throws java.lang.IllegalStateException,
                             ServiceProviderException
Removes all objects from the context's working memory.
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