Download A GENERALIZED APPROACH FOR EXTENDING THE ACTIVE

Transcript
60
‘EventNameUserName.java’ to distinguish the same event that has been defined by the
different users.
In our program, when we define a composite event, we’ll also define a rule.
Through the rule definition, we know when the event is detected and which action
function we should call.
We’ll give an example to show how we implement this.
1. Define a composite event ‘addDel’:
create trigger t_and event addDel = addStk ^ delStk RECENT
BEGIN ATOMIC
insert into temp values(‘Mark’, 4) ;
END
2. Create composite event and rule in LED.
EventHandle addDel = myAgent.createCompositeEvent(EventType.AND,
“event addDel”, addStk, delStk)
myAgent.createRule(“rule addDel”, addDel, “Led.true”,
“addDelzsong0.addDel”, 1, CouplingMode.DEFAULT,
Context.RECENT)
3. From the rule, we know when this composite event is detected, LED will execute
“zsong0addDel.call_addDel()” as the action.
We’ll create file ‘zsong0addDel.java’. In this file, there is a method called
‘call_addDel()’. This Java file is appended in appendix d.
Because this file is created when the ‘composite parser’ parses the composite
event, we need to compile this Java file in the run time. This is the same as we did for
creating events. The code for how to compile Java file dynamically is shown in Figure
6.4.