com.ibm.websphere.brb.strategy
Class DefaultNonClassifierFindingStrategy

java.lang.Object
  |
  +--com.ibm.websphere.brb.strategy.DefaultNonClassifierFindingStrategy
All Implemented Interfaces:
FindingStrategy, java.io.Serializable

public class DefaultNonClassifierFindingStrategy
extends java.lang.Object
implements FindingStrategy, java.io.Serializable

The default FindingStrategy which is used to find non-classifier rules. No other types of rules are found by this FindingStrategy. Clients wishing to write their own finding strategies can use it as the basis for their implementation. The client programmer should subclass DefaultClassifierFindingStrategy to implement a custom strategy. Normally new behavior should be implemented by overriding one or more of the following methods: parseRuleIdInfo, find...RulesInCache, find...RulesInDatabase, and add...RulesToCache. The default findRules method should usually be adequate. Note that, since the finding strategy is stored as part of the TriggerPoint and the TriggerPoint may be passed on a remote method call to the rule when it is fired, any FindingStrategy implementation must implement the Serializable interface.

See Also:
Serialized Form

Fields inherited from interface com.ibm.websphere.brb.FindingStrategy
DEFAULT_CLASSIFIER, DEFAULT_NONCLASSIFIER
 
Constructor Summary
DefaultNonClassifierFindingStrategy()
           
 
Method Summary
 void addClassifiedRulesToCache(IRule[] rulesToAdd, java.lang.String folderName, java.lang.String ruleName, TriggerPoint tp, java.lang.String[] classifications, java.util.Date asOfDate)
          Add the specified classified rules to the cache.
 void addUnclassifiedRulesToCache(IRule[] rulesToAdd, java.lang.String folderName, java.lang.String ruleName, TriggerPoint tp, java.util.Date asOfDate)
          Add the specified unclassified rules to the cache.
 IRule[] findClassifiedRulesInCache(java.lang.String folderName, java.lang.String ruleName, TriggerPoint tp, java.lang.String[] classifications, java.util.Date asOfDate)
          Look in the cache for classified rules with the specified name in the specified folder that are in effect on the specified date.
 IRule[] findClassifiedRulesInDatabase(java.lang.String folderName, java.lang.String ruleName, TriggerPoint tp, java.lang.String[] classifications, java.util.Date date)
          Look in the database for classifed rules with the specified name in the specified folder that are in effect on the specified date.
 IRule[] findRules(TriggerPoint tp, java.lang.Object ruleIdInfo, java.lang.Object classificationInfo, java.util.Date asOfDate)
          This implementation of the findRules method searches for non-classifier rules matching the specified criteria.
 IRule[] findUnclassifiedRulesInCache(java.lang.String folderName, java.lang.String ruleName, TriggerPoint tp, java.util.Date asOfDate)
          Look in the cache for unclassified rules with the specified name in the specified folder that are in effect on the specified date.
 IRule[] findUnclassifiedRulesInDatabase(java.lang.String folderName, java.lang.String ruleName, TriggerPoint tp, java.util.Date date)
          Look in the database for unclassifed rules with the specified name in the specified folder that are in effect on the specified date.
 java.lang.String[] parseClassificationInfo(java.lang.Object classificationInfo)
          Uses the classification information object passed into the finding strategy to determine the classifications of the rules to be found.
 java.lang.String[] parseRuleIdInfo(java.lang.Object ruleIdInfo, java.lang.String baseFolderName)
          Uses the rule ID information object passed into the finding strategy to determine the fully-qualified names of the rules to be found.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultNonClassifierFindingStrategy

public DefaultNonClassifierFindingStrategy()
Method Detail

addClassifiedRulesToCache

public void addClassifiedRulesToCache(IRule[] rulesToAdd,
                                      java.lang.String folderName,
                                      java.lang.String ruleName,
                                      TriggerPoint tp,
                                      java.lang.String[] classifications,
                                      java.util.Date asOfDate)
                               throws BusinessRuleBeansException

Add the specified classified rules to the cache. The rules will be associated with the specified folder name, rule name, classifications, and asOfDate. This implementation simply calls a helper method to add the rules to the BRBeans-supplied cache. Users may add to or otherwise change this behavior by overriding this method. If this method is overridden, the findClassifiedRulesInCache method may also need to be overridden.

Parameters:
rulesToAdd - Array of rules to add to cache.
folderName - The rules will be associated with this folder name in the cache.
ruleName - The rules will be associated with this rule name in the cache.
tp - The TriggerPoint used to make this call.
classifications - The rules will be associated with these classifications in the cache.
asOfDate - The rules will be associated with this asOfDate in the cache. If null, then the current date and time is used.
Throws:
BusinessRuleBeansException - If any errors occur.

addUnclassifiedRulesToCache

public void addUnclassifiedRulesToCache(IRule[] rulesToAdd,
                                        java.lang.String folderName,
                                        java.lang.String ruleName,
                                        TriggerPoint tp,
                                        java.util.Date asOfDate)
                                 throws BusinessRuleBeansException

Add the specified unclassified rules to the cache. The rules will be associated with the specified folder name, rule name, and asOfDate. This implementation simply calls a helper method to add the rules to the BRBeans-supplied cache. Users may add to or otherwise change this behavior by overriding this method. If this method is overridden, the findUnclassifiedRulesInCache method may also need to be overridden.

Parameters:
rulesToAdd - Array of rules to add to cache.
folderName - The rules will be associated with this folder name in the cache.
ruleName - The rules will be associated with this rule name in the cache.
tp - The TriggerPoint used to make this call.
asOfDate - The rules will be associated with this asOfDate in the cache. If null, then the current date and time is used.
Throws:
BusinessRuleBeansException - If any errors occur.

findClassifiedRulesInCache

public IRule[] findClassifiedRulesInCache(java.lang.String folderName,
                                          java.lang.String ruleName,
                                          TriggerPoint tp,
                                          java.lang.String[] classifications,
                                          java.util.Date asOfDate)
                                   throws BusinessRuleBeansException

Look in the cache for classified rules with the specified name in the specified folder that are in effect on the specified date. The rule must also be marked as ready and it must be classified with one of the classifications specified. The specified asOfDate may be null which means to look for rules that are in effect at the current date and time.

Note that there are two "no rules found in cache" conditions that must be distinguished:

This implementation simply calls a helper method to find rules in the BRBeans-supplied cache. Users may add to or otherwise change this behavior by overriding this method. If this method is overridden, the addClassifiedRulesToCache method may also need to be overridden.

Parameters:
folderName - Search for rules in this folder.
ruleName - Search for rules with this name.
tp - The TriggerPoint used to make this call.
classifications - Search for rules with the specified classifications. Assumed to be non-null.
asOfDate - Rules found should be in effect on this date. If null, rules in effect at the current date and time should be found.
Returns:
An array containg all rules in the cache matching the search criteria. If an entry is in the cache indicating that there are no rules matching the search criteria, then a zero-length array is returned. If there is no entry in the cache for the search criteria, then null is returned.
Throws:
BusinessRuleBeansException - If any errors occur.

findClassifiedRulesInDatabase

public IRule[] findClassifiedRulesInDatabase(java.lang.String folderName,
                                             java.lang.String ruleName,
                                             TriggerPoint tp,
                                             java.lang.String[] classifications,
                                             java.util.Date date)
                                      throws BusinessRuleBeansException

Look in the database for classifed rules with the specified name in the specified folder that are in effect on the specified date. The rule must also be marked as ready and must be classified with one of the specified classifications.

This implementation simply calls a helper method to find rules in the database. Users may add to or otherwise change this behavior by overriding this method.

Parameters:
folderName - Search for rules in this folder.
ruleName - Search for rules with this name.
tp - The TriggerPoint used to make this call.
classifications - Search for rules with the specified classifications. Assumed to be non-null.
date - Search for rules that are effective on this date.
Returns:
An array containg all rules in the database matching the search criteria. If no rules are found matching the search criteria, then a zero-length array is returned.
Throws:
BusinessRuleBeansException - If any errors occur.

findRules

public IRule[] findRules(TriggerPoint tp,
                         java.lang.Object ruleIdInfo,
                         java.lang.Object classificationInfo,
                         java.util.Date asOfDate)
                  throws BusinessRuleBeansException
This implementation of the findRules method searches for non-classifier rules matching the specified criteria. Only non-classifier (i.e. the rule is either classified or it is neither classified nor a classifier) rules are found. This method controls the overall flow of events for the finding strategy. The events consist of the following steps:
  1. Parse the rule ID information object to produce a list of rule names to search for (parseRuleIdInfo method).
  2. Parse the classification information object to produce a list of classification Strings to search for (parseClassificationInfo method).
  3. If caching is enabled, try to find the rules in the cache (method findClassifiedRulesInCache or findUnclassifiedRulesInCache).
  4. If rules were not found in cache, try to find the rules in the database (method findClassifiedRulesInDatabase or findUnclassifiedRulesInDatabase).
  5. If caching is enabled, add whatever rules were found to the cache (method addClassifiedRulesToCache or addUnclassifiedRulesToCache).
An array of found rules is built up and returned after all rule names have been processed. Any unexpected errors will result in an BusinessRuleBeansException being thrown.

When implementing a custom finding strategy, if this method is overridden, care should be taken that the new implementation fulfills the method's contract. Normally the overall sequence of events defined in this implementation should be adequate and clients should override one or more of the methods listed above in the four steps to implement a custom finding strategy.

Specified by:
findRules in interface FindingStrategy
Following copied from interface: com.ibm.websphere.brb.FindingStrategy
Parameters:
tp - the trigger point which is used to make this call
ruleIdInfo - an object that can be used to identify the rules to be found; normally a fully-qualified name or an array of fully-qualified names
classificationInfo - an object that can be used to determine the classification of the rules to be found, or null for unclassified rules
asOfDate - rules returned should be in effect as of this date; null means use the current date and time
Returns:
An array of Rules which match the search criteria. If no rules are found, an array of length zero will be returned.
Throws:
BusinessRuleBeansException - if any exceptions occur

findUnclassifiedRulesInCache

public IRule[] findUnclassifiedRulesInCache(java.lang.String folderName,
                                            java.lang.String ruleName,
                                            TriggerPoint tp,
                                            java.util.Date asOfDate)
                                     throws BusinessRuleBeansException

Look in the cache for unclassified rules with the specified name in the specified folder that are in effect on the specified date. The rule must also be marked as ready an must not be a classifier. The specified asOfDate may be null. This means to look for rules that are in effect at the current date and time.

Note that there are two "no rules found in cache" conditions that must be distinguished:

This implementation simply calls a helper method to find rules in the BRBeans-supplied cache. Users may add to or otherwise change this behavior by overriding this method. If this method is overridden, the addUnclassifiedRulesToCache method may also need to be overridden.

Parameters:
folderName - Search for rules in this folder.
ruleName - Search for rules with this name.
tp - The TriggerPoint used to make this call.
asOfDate - Rules found should be in effect on this date. If null, rules in effect at the current date and time should be found.
Returns:
An array containg all rules in the cache matching the search criteria. If an entry is in the cache indicating that there are no rules matching the search criteria, then a zero-length array is returned. If there is no entry in the cache for the search criteria, then null is returned.
Throws:
BusinessRuleBeansException - If any errors occur.

findUnclassifiedRulesInDatabase

public IRule[] findUnclassifiedRulesInDatabase(java.lang.String folderName,
                                               java.lang.String ruleName,
                                               TriggerPoint tp,
                                               java.util.Date date)
                                        throws BusinessRuleBeansException

Look in the database for unclassifed rules with the specified name in the specified folder that are in effect on the specified date. The rule must also be marked as ready, must not be a classifier, and must not be classified.

This implementation simply calls a helper method to find rules in the database. Users may add to or otherwise change this behavior by overriding this method.

Parameters:
folderName - Search for rules in this folder.
ruleName - Search for rules with this name.
tp - The TriggerPoint used to make this call.
date - Search for rules that are effective on this date.
Returns:
An array containg all rules in the database matching the search criteria. If no rules are found matching the search criteria, then a zero-length array is returned.
Throws:
BusinessRuleBeansException - If any errors occur.

parseClassificationInfo

public java.lang.String[] parseClassificationInfo(java.lang.Object classificationInfo)
                                           throws BusinessRuleBeansException

Uses the classification information object passed into the finding strategy to determine the classifications of the rules to be found. Currently BRB will only pass a single String or an Object[] containing Strings as the classification information. If any other type is received by this method, an BusinessRuleBeansException will be thrown. Users can override this method in custom finding strategies to create an array of classifications using a different algorithm.

Parameters:
classificationInfo - Object containing information to be used to produce an array of classification Strings. Currrently BRBeans will only pass a single String or an Object[] containing Strings to the finding strategy. If this parameter is null, then only unclassified rules will be found.
Returns:
An array of one or more classification Strings. The rules to be found must be classified by one of these classifications. Returns null if there are no classifications.
Throws:
BusinessRuleBeansException - If any errors occur.

parseRuleIdInfo

public java.lang.String[] parseRuleIdInfo(java.lang.Object ruleIdInfo,
                                          java.lang.String baseFolderName)
                                   throws BusinessRuleBeansException

Uses the rule ID information object passed into the finding strategy to determine the fully-qualified names of the rules to be found. The ruleIdInfo parameter can be any object that can be used to determine the rule names. It is exactly the rule ID information object passed on the TriggerPoint call. For the BRBeans-supplied finding strategies, this is required to be either a single String (find rules with this fully-qualified name) or a String[] or an Object[] containing Strings (find rules that have any of the fully-qualified names in the array). Any other types will result in an BusinessRuleBeansException being thrown. Users can override this method in their own finding strategies to take any type of parameter, as long as it can be used to produce an array of fully-qualified rule names.

Parameters:
ruleIdInfo - Object containing information to be used to produce an array of fully-qualified rule names. BRBeans-supplied finding strategies require that this is either a String, a String[], or an Object[] containing Strings.
baseFolderName - The base folder name that rule names should be relative to. If null, then rule names must be fully-qualified.
Returns:
An array of fully-qualified names of rules to be found.
Throws:
BusinessRuleBeansException - If any errors occur.