Simple trigger point

A simple trigger point is used to trigger a rule or rules specified by name. This type of trigger point is used by invoking the trigger method on an instance of the TriggerPoint class. All rules with the specified name are triggered and the results are combined using the CombiningStrategy specified on the TriggerPoint object. This type of trigger point only finds rules that are not marked as classifiers.

The following shows an example of using a simple trigger point to trigger a rule named isSeniorCitizen (in the com/acme/ageRules folder), which determines whether a person is classified as a senior citizen based on the passed in age:

 ...
// 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 rule
Object [ ] plist = new Object[1];

// define age of person to be tested
Integer age = new Integer(64);

// define name of rule to be fired
String ruleName = "com/acme/ageRules/isSeniorCitizen";

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

// initialize parameter list
plist[0] = age;

try {

	// fire "com/acme/ageRules/isSeniorCitizen" rule passing parameter list containing age.  
	// Note: in this case the target object is not used and could be null.
	result = tp.trigger(this, plist, ruleName);

	// 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.
	boolean seniorCitizen = ((Boolean)result).booleanValue();

	// make use of result
	if( seniorCitizen ) {
		...
	}

}
catch(BusinessRuleBeansException e ) {

	// handle exception
	...

}

Related concepts
Trigger points



Searchable topic ID:   cbrb_trgsimp
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_trgsimp.html

Library | Support | Terms of Use | Feedback