KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > bpel > service > exe > StartListener


1 package org.jbpm.bpel.service.exe;
2
3 import java.util.Collections JavaDoc;
4 import java.util.Map JavaDoc;
5
6 import javax.jms.Destination JavaDoc;
7 import javax.jms.JMSException JavaDoc;
8 import javax.jms.ObjectMessage JavaDoc;
9
10 import org.w3c.dom.Element JavaDoc;
11
12 import org.jbpm.graph.exe.ProcessInstance;
13 import org.jbpm.graph.exe.Token;
14
15 import org.jbpm.bpel.def.BpelDefinition;
16 import org.jbpm.bpel.service.def.Receiver;
17
18 /**
19  * @author Alejandro Guízar
20  * @version $Revision: 1.6 $ $Date: 2005/05/31 00:49:53 $
21  */

22 public class StartListener extends RequestListener {
23   
24   public StartListener(Receiver receiver) {
25     super(receiver);
26   }
27   
28   /** {@inheritDoc} */
29   public void deliverRequest(ObjectMessage JavaDoc request) throws JMSException JavaDoc {
30     // create process instance
31
Receiver receiver = getReceiver();
32     BpelDefinition process = receiver.getInboundMessageActivity().getBpelDefinition();
33     ProcessInstance instance = process.createProcessInstance();
34     // read start message in the root token
35
Token token = instance.getRootToken();
36     // register outstanding request
37
Destination JavaDoc replyTo = request.getJMSReplyTo();
38     if (replyTo != null) {
39       receiver.registerRequest(new OutstandingRequest(replyTo, request.getJMSMessageID()), token);
40     }
41     // get message contents
42
Element JavaDoc messageElem = (Element JavaDoc) request.getObject();
43     /* request.acknowledge(); */
44     receiver.readMessage(messageElem, token);
45     // start the process
46
process.triggerProcessInstance(instance, receiver);
47   }
48   
49   protected Map JavaDoc getReceptionProperties() {
50     return Collections.EMPTY_MAP;
51   }
52 }
Popular Tags