1 package org.smartcomps.twister.deployer.priv;
2
3 import org.dom4j.Attribute;
4 import org.dom4j.Element;
5 import org.smartcomps.twister.common.persistence.DBSessionException;
6 import org.smartcomps.twister.common.util.StringUtil;
7 import org.smartcomps.twister.deployer.exception.DeploymentException;
8 import org.smartcomps.twister.engine.priv.core.definition.*;
9
10 import java.util.Iterator;
11
12 /***
13 *
14 * <reply partnerLink="ncname" portType="qname" operation="ncname"
15 * variable="ncname"? faultName="qname"?
16 * standard-attributes>
17 * standard-elements
18 * <correlations>?
19 * <correlation set="ncname" initiate="yes|no"?>+
20 * </correlations>
21 * </reply>
22 */
23
24 public class ReplyDeployer extends ActivityDeployer {
25
26 protected Class getActivityClass() {
27 return Reply.class;
28 }
29
30 protected void processSpecificAttributes(Element element, Activity activity) throws DeploymentException {
31 Reply reply = (Reply) activity;
32 Attribute partnerLink = element.attribute("partnerLink");
33 if (partnerLink != null) {
34 log.debug("partnerLink=" + partnerLink);
35 reply.setPartner(partnerLink.getValue());
36 }
37
38 Attribute portType = element.attribute("portType");
39 if (portType != null) {
40 log.debug("portType=" + portType);
41 reply.setPortType(portType.getValue());
42 }
43
44 Attribute operation = element.attribute("operation");
45 if (operation != null) {
46 log.debug("operation=" + operation);
47 reply.setOperation(operation.getValue());
48 }
49
50 Attribute variable = element.attribute("variable");
51 if (variable != null) {
52 log.debug("variable=" + variable);
53 reply.setVariable(variable.getValue());
54 }
55
56 Attribute faultName = element.attribute("faultName");
57 if (faultName != null) {
58 log.debug("faultName=" + faultName);
59 reply.setFaultName(faultName.getValue());
60 }
61
62 }
63
64 protected void processSpecificElements(Element element, Activity activity) throws DeploymentException {
65 Element correlationsElement = element.element("correlations");
66 try {
67 processCorrelations(correlationsElement, (Reply) activity);
68 } catch (DBSessionException e) {
69 throw new DeploymentException(e);
70 }
71 }
72
73 private void processCorrelations(Element correlationsElement, Reply reply) throws DBSessionException {
74 log.debug(correlationsElement);
75 Iterator correlations = correlationsElement.elementIterator("correlation");
76 while (correlations.hasNext()) {
77 Element correlation = (Element) correlations.next();
78 Attribute setAtt = correlation.attribute("set");
79 String set = setAtt != null ? setAtt.getValue() : "";
80 Attribute initiateAtt = correlation.attribute("initiate");
81 boolean initiate = initiateAtt != null ? (initiateAtt.getValue().equals("yes") ? true : false) : false;
82 Attribute patternAtt = correlation.attribute("pattern");
83 int pattern = patternAtt != null ? getCorrelationPattern(patternAtt.getValue()) : CorrelationRef.NONE;
84 // todo
85 // CorrelationRef correlationRef = ActivityFactory.addCorrelationRef(receive, set, initiate, pattern);
86 // log.debug(correlationRef);
87 }
88 }
89 }
This page was automatically generated by Maven