This example indicates how you can make external code (such as Java™ classes) and external objects accessible to expressions. An external object is an object that an application creates to communicate with expressions.
Before you can access external code from an expression, you must make that code accessible to expressions.
An import is a programming language-specific way to make external code accessible to expressions. The <import> element contains a special type of expression that specifies the external modules (such as Java classes) to import for use in other expressions within rules. An import can be defined at the level of the rule set or a rule block.
<import expressionLanguage="java"> import com.ibm.act.sample.StaticHelper; import com.ibm.act.test.Queue; </import>
Although the use of the full class name is not required in the import statement, you should specify the full name to prevent a long compilation time. For example, the Java class should be specified as com.ibm.act.sample.StaticHelper rather than com.ibm.act.sample.* or com.ibm.act.*.
<onDetection> <action expressionLanguage="java"> StaticHelper.pageAdministrator("Too many login attempts for " + act_event.getAttribute("userID")); </action> </onDetection>
<onDetection> <action expressionLanguage="java"> Queue myQueue = (Queue)act_lib.getExternalContext("OutputQueueOne"); myQueue.enqueue(act_event); </action> </onDetection>