1 package org.jbpm.bpel.service.exe; 2 3 import java.util.Map ; 4 5 import javax.jms.Destination ; 6 import javax.jms.JMSException ; 7 import javax.jms.ObjectMessage ; 8 9 import org.w3c.dom.Element ; 10 11 import org.jbpm.context.exe.ContextInstance; 12 import org.jbpm.graph.exe.Token; 13 14 import org.jbpm.bpel.service.def.Receiver; 15 import org.jbpm.bpel.service.def.InboundMessageActivity; 16 17 21 public class NonStartListener extends RequestListener { 22 23 private Token token; 24 25 public static final String RECEIVER_NAME = "_$receiver_"; 26 27 NonStartListener() { 28 } 29 30 NonStartListener(Receiver receiver, Token token) { 31 super(receiver); 32 this.token = token; 33 } 34 35 public Token getToken() { 36 return token; 37 } 38 39 public void setToken(Token token) { 40 this.token = token; 41 } 42 43 public void deliverRequest(ObjectMessage request) throws JMSException { 44 Receiver receiver = getReceiver(); 46 Destination replyTo = request.getJMSReplyTo(); 47 if (replyTo != null) { 48 receiver.registerRequest(new OutstandingRequest(replyTo, request.getJMSMessageID()), token); 49 } 50 Element messageElem = (Element ) request.getObject(); 52 54 InboundMessageActivity activity = (InboundMessageActivity) receiver.getInboundMessageActivity(); 56 activity.messageReceived(receiver, messageElem, token); 57 } 58 59 protected Map getReceptionProperties() { 60 return getReceiver().getCorrelations().getReceptionProperties(token); 61 } 62 63 public static NonStartListener create(Receiver receiver, Token token) { 64 NonStartListener instance = new NonStartListener(receiver, token); 65 ContextInstance context = token.getProcessInstance().getContextInstance(); 66 context.createVariable(RECEIVER_NAME + receiver.getId(), instance, token); 67 return instance; 68 } 69 70 public static NonStartListener get(Receiver receiver, Token token) { 71 ContextInstance context = token.getProcessInstance().getContextInstance(); 72 NonStartListener instance = ((NonStartListener) context.getVariable(RECEIVER_NAME + receiver.getId(), token)); 73 return instance; 74 } 75 } 76 | Popular Tags |