KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > bpel > xml > ReplyReader


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 JavaDoc;
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 /**
19  * @author Juan Cantú
20  * @version $Revision: 1.10 $ $Date: 2005/06/23 20:45:04 $
21  */

22 public class ReplyReader extends ActivityReader {
23
24   public Activity createActivity() {
25     return new Reply();
26   }
27   
28   public void readActivity(Activity activity, Element JavaDoc element) {
29     Reply reply = (Reply) activity;
30     reply.setReplier(readReplier(element, reply.getCompositeActivity()));
31   }
32   
33   public Replier readReplier(Element JavaDoc replyElem, CompositeActivity parent) {
34     Replier replier = new Replier();
35     //partner link
36
String JavaDoc 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     //port type
43
PortType portType = bpelReader.getPortType(replyElem, partnerLink.getMyRole());
44     //operation
45
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     //variable
52
VariableDefinition variable = bpelReader.getVariable(replyElem, BpelConstants.ATTR_VARIABLE,
53         parent, operation.getOutput().getMessage());
54     replier.setVariable( variable );
55     // message exchange: if the attribute is not specified then its value is taken to be empty
56
replier.setMessageExchange(replyElem.getAttribute(BpelConstants.ATTR_MESSAGE_EXCHANGE));
57     //correlations
58
Element JavaDoc 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