1 package org.jbpm.bpel.xml; 2 3 import javax.wsdl.Operation; 4 import javax.wsdl.OperationType; 5 import javax.wsdl.PortType; 6 7 import org.w3c.dom.Element ; 8 9 import org.jbpm.bpel.data.def.VariableDefinition; 10 import org.jbpm.bpel.def.Activity; 11 import org.jbpm.bpel.def.CompositeActivity; 12 import org.jbpm.bpel.def.Reply; 13 import org.jbpm.bpel.service.def.PartnerLinkDefinition; 14 import org.jbpm.bpel.service.def.Replier; 15 import org.jbpm.bpel.xml.util.NodeUtil; 16 import org.jbpm.jpdl.xml.Problem; 17 18 22 public class ReplyReader extends ActivityReader { 23 24 public Activity createActivity() { 25 return new Reply(); 26 } 27 28 public void readActivity(Activity activity, Element element) { 29 Reply reply = (Reply) activity; 30 reply.setReplier(readReplier(element, reply.getCompositeActivity())); 31 } 32 33 public Replier readReplier(Element replyElem, CompositeActivity parent) { 34 Replier replier = new Replier(); 35 String pLinkName = replyElem.getAttribute( BpelConstants.ATTR_PARTNER_LINK ); 37 PartnerLinkDefinition partnerLink = parent.findPartnerLink(pLinkName); 38 if(partnerLink == null) { 39 throw new BpelException("partner link not found", replyElem); 40 } 41 replier.setPartnerLink( partnerLink ); 42 PortType portType = bpelReader.getPortType(replyElem, partnerLink.getMyRole()); 44 Operation operation = bpelReader.getOperation(replyElem, portType); 46 if (operation.getStyle() != OperationType.REQUEST_RESPONSE) { 47 bpelReader.getProblemHandler().add( 48 new LocalizedProblem( Problem.LEVEL_ERROR, "cannot reply an one-way operation", replyElem) ); 49 } 50 replier.setOperation( operation ); 51 VariableDefinition variable = bpelReader.getVariable(replyElem, BpelConstants.ATTR_VARIABLE, 53 parent, operation.getOutput().getMessage()); 54 replier.setVariable( variable ); 55 replier.setMessageExchange(replyElem.getAttribute(BpelConstants.ATTR_MESSAGE_EXCHANGE)); 57 Element correlationsElement = NodeUtil.getElement(replyElem, BpelConstants.NS_BPWS, BpelConstants.ELEM_CORRELATIONS ); 59 if(correlationsElement != null) { 60 replier.setCorrelations(bpelReader.readCorrelations(correlationsElement, parent, variable)); 61 } 62 63 return replier; 64 } 65 } 66 | Popular Tags |