|
From: Richard A. <rac...@re...> - 2008-08-06 17:09:44
|
Hello
A question on the use of events in the SF workflow. Suppose I have a
configuration of components which looks like this:
c1 extends Parallel {
p1 extends ... {...}
}
c2 extends Parallel {
p2 extends ... {...}
p3 extends ... {...}
}
}
sfConfig extends c1 ;
Here are some of the things I would like to do with events:
(i) send an event from p1 to p3 only
(ii) send an event from p1 to all other leaf components {p2, p3}
(iii) send an event from p1 to all components {c1, c2, p2, p3}
I know I can send an event from a component using a sub-component
EventSend. I know I can handle an event using a subcomponent OnEvent.
For example, the following code allows me to send an event from p1 to p3
(I added in a delay before sending to that the OnEvent components have a
chance to start):
c1 extends Parallel {
p1 extends Sequence {
// set up a delay to allow event handler to initialise
delay extends DoNothing {
time 2000 ;
}
// send an event to p3
sender extends EventSend {
sendTo: fred LAZY ATTRIB c2:p3 ;
event "apache" ;
}
}
c2 extends Parallel {
p2 extends OnEvent {
singleEvent false ;
// event handlers
otherwise extends LAZY DoNothing {
time 1000 ;
message "hello from p2:otherwise" ;
}
}
p3 extends OnEvent {
singleEvent false ;
// event handlers
apache extends LAZY DoNothing {
time 1000 ;
message "hello from Apache" ;
}
otherwise extends LAZY DoNothing {
time 1000 ;
message "hello from p3:otherwise" ;
}
}
}
}
sfConfig extends c1 ;
One thing i'm not clear on is the use of registerWith. It appears that
even if I don't make use of registerWith in this example, the events
manage to reach their destinations (specified with sentTo). I also tried
to send an event to p2 and p3 by sending it to c2, but that didn't work.
Are there ways to make use of registerWith in order to implement the use
cases (ii) and (iii)?
Richard
|