Apama 10.15.0 | Developing Apama Applications | EPL Reference | Events and Event Listeners | Event definitions | Event actions
 
Event actions
An event action is a subprogram or function that is associated with the event definition. It can be invoked or called from any monitor or from another action in the same event. Like monitor actions, the caller must supply actual parameters of the same type and number as the event action's formal parameters and if the action returns a value, then the return value must be consumed by the caller.
Like monitor actions, event actions can optionally be prefixed with annotations. See Annotations.
Unlike monitor actions (see Monitor actions), events do not have the special actions onload(), onunload(), and ondie().
Event action example:
action myEventAction(string s, location l) returns float {
...
return 10.0;
}
See Defining actions for further information.
It is also possible to define static actions which apply only to the event type (and not to specific instances of an event). For example:
event E {
static action someStaticAction(){
print "I am a static action on event type E";
}
}
See Defining static actions for further information.
Event action formal parameters
The formal parameters are a comma-separated list of parameter definitions, enclosed in parentheses. A parameter definition consists of a type name and an identifier. The identifier is the name of a parameter variable which will be bound to a copy of the value of an expression specified by the caller (that is, the value passed by the caller) when the action is invoked. The number and type of actual parameter values passed by a caller must match those listed in the action's formal parameters.
The scope of a parameter variable is the statement or block that forms the action body. Parameter variables are very similar to an action's local variables.
Event action return value
An event action return value specifies the return value type.
If the event action definition includes a returns clause, then the action returns a value of the specified type. All control paths within the action body must lead to a return statement before the end of the action body.
Event action body
The block construct forms the event action body. All variable references within an event action body must be one of the following:
*A field of the event
*A formal parameter of the action
*A local variable defined in the action body