Copyright © Cloud Software Group, Inc. All Rights Reserved
Copyright © Cloud Software Group, Inc. All Rights Reserved


Appendix A Common Configuration Object API Methods : Microagent and Method Invocation used in ConsequenceAction

Microagent and Method Invocation used in ConsequenceAction
A ConsequenceAction in a rulebase executes an action when the condition of the test is satisfied. The action taken is in the form of method invocation. The following are common actions performed by a ConsequenceAction of a rulebase:
Since a ConsequenceAction invokes a method invocation on a specific microagent, any known method invocation with ACTION or INFO type can be specified. However, caution must be taken on methods that may potentially take a long time to execute.
When constructing a ConsequenceAction object, two arguments are needed: the name of a microagent and the method invocation that will be performed on that microagent. Hence, before constructing a ConsequenceAction, first construct a MethodInvocation. A MethodInvocation requires a method name. Depending on the method, it may also take arguments. For a complete list of built-in microagents and their open methods, please refer to the TIBCO Hawk Microagent Reference.
The follow methods show how the common ConsequenceActions can be created. Note that the sendAlertMessage method is a proprietary method of the RulebaseEngine microagent and is not listed in the TIBCO Hawk Microagent Reference.
 
/**
* Create an alert action.
*/
ConsequenceAction createAlertAction(String state, String alert)
throws RBEConfigObjectException
{
DataElement[] args = new DataElement[1];
if ( state.equals("High") )
args[0] = new DataElement("message",
new COM.TIBCO.hawk.config.rbengine.rulebase.util.AlertHigh(alert));
else if ( state.equals("Medium") )
args[0] = new DataElement("message",
new COM.TIBCO.hawk.config.rbengine.rulebase.util.AlertMedium(alert));
else if ( state.equals("Low") )
args[0] = new DataElement("message",
new COM.TIBCO.hawk.config.rbengine.rulebase.util.AlertLow(alert));
MethodInvocation mi = new MethodInvocation( "sendAlertMessage", args);
return new ConsequenceAction("COM.TIBCO.hawk.microagent.RuleBaseEngine", mi);
}
 
 
/**
* Create an email action
*/
ConsequenceAction createEmailAction(String to, String from, String cc, String subject, String server, String content) throws RBEConfigObjectException
{
DataElement[] args = new DataElement[6];
args[0] = new DataElement("To", to);
args[1] = new DataElement("From", from);
args[2] = new DataElement("CC",cc);
args[3] = new DataElement("Subject", subject);
args[4] = new DataElement("Mail Server", server);
args[5] = new DataElement("Content", content);
MethodInvocation mi = new MethodInvocation( "sendMail", args);
return new ConsequenceAction("COM.TIBCO.hawk.microagent.RuleBaseEngine", mi);
}
 
 
/**
* Create a custom execute action.
*/
ConsequenceAction createCustomAction(String cmdStr)
throws RBEConfigObjectException
{
DataElement[] args = new DataElement[1];
args[0] = new DataElement("command", cmdStr);
MethodInvocation mi = new MethodInvocation( "execute", args);
return new ConsequenceAction("COM.TIBCO.hawk.microagent.Custom", mi);
}

Copyright © Cloud Software Group, Inc. All Rights Reserved
Copyright © Cloud Software Group, Inc. All Rights Reserved