KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > bpel > messager > StartListenersActivator


1 package org.jbpm.bpel.messager;
2
3 import java.util.ArrayList JavaDoc;
4 import java.util.Iterator JavaDoc;
5 import java.util.List JavaDoc;
6
7 import org.jbpm.bpel.def.*;
8 import org.jbpm.bpel.service.def.Receiver;
9 import org.jbpm.bpel.service.exe.StartListener;
10
11 /**
12  * @author Alejandro Guízar
13  * @version $Revision: 1.1 $ $Date: 2005/05/30 18:12:12 $
14  */

15 class StartListenersActivator extends BpelVisitorSupport {
16   
17   private final MessagerSession msgSession;
18   private List JavaDoc startListeners = new ArrayList JavaDoc();
19   
20   public StartListenersActivator(MessagerSession msgSession) {
21     this.msgSession = msgSession;
22   }
23   
24   public List JavaDoc getStartListeners() {
25     return startListeners;
26   }
27   
28   public void visit(Receive receive) {
29     if (receive.isCreateInstance()) {
30       createListener(receive.getReceiver());
31     }
32   }
33   
34   public void visit(Pick pick) {
35     if (pick.isCreateInstance()) {
36       Iterator JavaDoc onMessageIt = pick.getOnMessages().iterator();
37       while (onMessageIt.hasNext()) {
38         createListener((Receiver) onMessageIt.next());
39       }
40     }
41   }
42   
43   public void visit(Sequence sequence) {
44     // visit only the first activity
45
((Activity) sequence.getNodes().get(0)).accept(this);
46   }
47   
48   private void createListener(Receiver receiver) {
49     //create and open a start listener
50
StartListener listener = new StartListener(receiver);
51     listener.receiveRequest(msgSession);
52     startListeners.add(listener);
53   }
54 }
55
Popular Tags