Situational trigger point

A situational trigger point is used when the rule or rules to be triggered depend on the business situation.

This example evaluates a customer's past purchasing history to place them into one of three levels: Gold, Silver, or Bronze. Their classification determines how much of a discount they receive.

To use a situational trigger point to handle this case, it is first necessary to define four rules:

All of the classified rules have the same name and are marked as applying to one of the three customer levels by specifying the level in its classification attribute. For example, the rule to determine the discount for a Gold level customer will contain the string "Gold" in its classification attribute.

The situational trigger point takes two rule names as input: the name of the classifier rule and the name of the classified rule. The situational trigger point then proceeds in two phases:

  1. Find the specified classifier rule and trigger it to generate a classification string.
  2. Find the rules that have the name specified for the classified rule and have a classification attribute equal to the classification string returned by the first phase.
These rules then are triggered to produce the final result, in this case the discount to offer.

The following shows an example of a situational trigger point used to handle the case described previously:

...
// create an instance of TriggerPoint for triggering the rule and specify that the 
// ReturnFirstCombiningStrategy is to be used to return only the first result if
// multiple rules are found.
TriggerPoint tp = new TriggerPoint();
tp.setCombiningStrategy(CombiningStrategy.RETURN_FIRST, TriggerPoint.ALL_RULES);

// define parameter list that's passed to the classifier rule
Object [ ] classifierPlist = new Object[1];

// define parameter list that's passed to the classified rule
Object [ ] classifiedPlist = new Object[1];

// information about the customer to be checked is stored in this object
Customer cust = ...;

// define name of classifier rule to be fired
String classifierRuleName = "com/acme/customerClassifiers/determineCustomerLevel";

// define name of classified rule to be fired
String classifiedRuleName = "com/acme/discountRules/determineDiscount";

// define result of rule firing
Object result = null;

// initialize parameter lists
classifierPlist[0] = cust;
classifiedPlist[0] = cust;

try {
	// fire the rules to get the discount to offer
	// Note: in this case the target object is not used and could be null.
	result = tp.triggerSituational(this, classifiedPlist, classifierPlist, classifiedRuleName, classifierRuleName);

	// put result into usable format.  A single result is returned since we specified to use
	// the ReturnFirstCombiningStrategy.  By default an array of results would be returned.
	Float discountToOffer = (Float) result;

	// make use of result
	...
}
catch(BusinessRuleBeansException e ) {

	// handle exception
	...

}

Related concepts
Trigger points



Searchable topic ID:   cbrb_trgsit
Last updated: Jun 21, 2007 8:07:48 PM CDT    WebSphere Business Integration Server Foundation, Version 5.0.2
http://publib.boulder.ibm.com/infocenter/wasinfo/index.jsp?topic=/com.ibm.wasee.doc/info/ee/brb/concepts/cbrb_trgsit.html

Library | Support | Terms of Use | Feedback