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.deployer.exception.DeploymentException;
7 import org.smartcomps.twister.engine.priv.core.definition.Activity;
8 import org.smartcomps.twister.engine.priv.core.definition.ActivityFactory;
9 import org.smartcomps.twister.engine.priv.core.definition.CorrelationRef;
10 import org.smartcomps.twister.engine.priv.core.definition.Invoke;
11
12 import java.util.Iterator;
13
14 /*
15 * <invoke partnerLink="ncname" portType="qname" operation="ncname"
16 * inputVariable="ncname"? outputVariable="ncname"?
17 * standard-attributes>
18 * standard-elements
19 * <correlations>?
20 * <correlation set="ncname" initiate="yes|no"?
21 * pattern="in|out|out-in"/>+
22 * </correlations>
23 * <catch faultName="qname" faultVariable="ncname"?>*
24 * activity
25 * </catch>
26 * <catchAll>?
27 * activity
28 * </catchAll>
29 * <compensationHandler>?
30 * activity
31 * </compensationHandler>
32 * </invoke>
33 *
34 */
35 public class InvokeDeployer extends ActivityDeployer {
36
37 protected Class getActivityClass() {
38 return Invoke.class;
39 }
40
41 protected void processSpecificElements(Element element, Activity activity) throws DeploymentException {
42 Element correlationsElement = element.element("correlations");
43 try {
44 if (correlationsElement != null) {
45 processCorrelations(correlationsElement, (Invoke) activity);
46 }
47 } catch (DBSessionException e) {
48 throw new DeploymentException(e);
49 }
50
51 Iterator catchElements = element.elementIterator("catch");
52 processCatchs(catchElements, (Invoke) activity);
53
54 Element catchAll = element.element("catchAll");
55 processCatchAll(catchAll, (Invoke) activity);
56
57 Element compensationHandler = element.element("compensationHandler");
58 processCompensationHandler(compensationHandler, (Invoke) activity);
59 }
60
61 protected void processSpecificAttributes(Element element, Activity activity) throws DeploymentException {
62 Invoke invoke = (Invoke) activity;
63 Attribute partnerLink = element.attribute("partnerLink");
64 if (partnerLink != null) {
65 log.debug("partnerLink=" + partnerLink);
66 invoke.setPartner(partnerLink.getValue());
67 }
68
69 Attribute portType = element.attribute("portType");
70 if (portType != null) {
71 log.debug("portType=" + portType);
72 invoke.setPortType(portType.getValue());
73 }
74
75 Attribute operation = element.attribute("operation");
76 if (operation != null) {
77 log.debug("operation=" + operation);
78 invoke.setOperation(operation.getValue());
79 }
80
81 Attribute inputVariable = element.attribute("inputVariable");
82 if (inputVariable != null) {
83 log.debug("inputVariable=" + inputVariable);
84 invoke.setInputVariable(inputVariable.getValue());
85 }
86
87 Attribute outputVariable = element.attribute("outputVariable");
88 if (outputVariable != null) {
89 log.debug("outputVariable=" + outputVariable);
90 invoke.setOutputVariable(outputVariable.getValue());
91 }
92 }
93
94 private void processCorrelations(Element correlationsElement, Invoke invoke) throws DBSessionException {
95 log.debug(correlationsElement);
96 Iterator correlations = correlationsElement.elementIterator("correlation");
97 while (correlations.hasNext()) {
98 Element correlation = (Element) correlations.next();
99 Attribute setAtt = correlation.attribute("set");
100 Attribute initiateAtt = correlation.attribute("initiate");
101 Attribute patternAtt = correlation.attribute("pattern");
102 String set = setAtt != null ? setAtt.getValue() : "";
103 boolean initiate = initiateAtt != null ? (initiateAtt.getValue().equals("yes") ? true : false) : false;
104 int pattern = patternAtt != null ? getCorrelationPattern(patternAtt.getValue()) : CorrelationRef.NONE;
105 CorrelationRef correlationRef = ActivityFactory.addCorrelationRef(invoke, set, initiate, pattern);
106 log.debug(correlationRef);
107 }
108 }
109
110 private void processCatchs(Iterator catchElements, Invoke invoke) {
111 while (catchElements.hasNext()) {
112 Element element = (Element) catchElements.next();
113 log.info("not yet managed element : " + element);
114 }
115 }
116
117 private void processCatchAll(Element catchAllElement, Invoke invoke) {
118 log.info("not yet managed element : " + catchAllElement);
119 }
120
121 private void processCompensationHandler(Element compensationHandlerElement, Invoke invoke) {
122 log.info("not yet managed element : " + compensationHandlerElement);
123 }
124 }
This page was automatically generated by Maven