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