1 package org.smartcomps.twister.engine.priv.messaging.impl;
2
3 import org.smartcomps.twister.engine.priv.core.definition.*;
4 import org.smartcomps.twister.engine.priv.core.dynamic.ExecutionContext;
5 import org.smartcomps.twister.engine.priv.core.dynamic.PickEC;
6 import org.smartcomps.twister.engine.exception.EngineException;
7
8 import java.util.Collection;
9 import java.util.Map;
10 import java.util.Set;
11
12 /***
13 * This class is a wrapper around the MessageEvent of a Pick structured
14 * activity to use it just as using a Receive. This way our MessageController
15 * implementation just consider Receive activities and we don't have to worry
16 * about always differentiating the two cases : Receive and Pick MessageEvent.
17 * @see org.smartcomps.twister.engine.priv.messaging.MessageController
18 * @see org.smartcomps.twister.engine.priv.core.definition.Receive
19 * @see org.smartcomps.twister.engine.priv.core.definition.Pick
20 * @see org.smartcomps.twister.engine.priv.core.definition.MessageEvent
21 */
22 public class PickAsReceive implements Receive {
23
24 private Pick pick;
25 private int eventPos;
26
27 public PickAsReceive(Pick pick, int eventPos) {
28 this.pick = pick;
29 this.eventPos = eventPos;
30 }
31
32 public Pick getPick() {
33 return pick;
34 }
35
36 public int getEventPos() {
37 return eventPos;
38 }
39
40 public String getPartner() {
41 return getMessageEvent(eventPos).getPartnerLink();
42 }
43
44 public String getPortType() {
45 return getMessageEvent(eventPos).getPortType();
46 }
47
48 public String getOperation() {
49 return getMessageEvent(eventPos).getOperation();
50 }
51
52 public String getVariable() {
53 return getMessageEvent(eventPos).getVariable();
54 }
55
56 public boolean isCreateInstance() {
57 return pick.isCreateInstance();
58 }
59
60 public Collection getCorrelations() {
61 return getMessageEvent(eventPos).getCorrelations();
62 }
63
64 public String getName() {
65 return pick.getName();
66 }
67
68 public ExecutionContext execute(String correlationSetName, Map correlation) throws EngineException {
69 PickEC pickEC = (PickEC) pick.execute(correlationSetName, correlation);
70 return new PickECAsReceiveEC(pickEC, eventPos);
71 }
72
73 public StructuredActivity getContainer() {
74 return pick;
75 }
76
77 public TwisterProcess getProcess() {
78 return null;
79 }
80
81 public TwisterProcess fetchProcess() {
82 return pick.fetchProcess();
83 }
84
85 public void setPartner(String partner) {
86 // Useless for our purpose
87 throw new UnsupportedOperationException("This method shouldn't be used, this class is read only");
88 }
89 public void setPortType(String portType) {
90 // Useless for our purpose
91 throw new UnsupportedOperationException("This method shouldn't be used, this class is read only");
92 }
93 public void setOperation(String operation) {
94 // Useless for our purpose
95 throw new UnsupportedOperationException("This method shouldn't be used, this class is read only");
96 }
97 public void setVariable(String variable) {
98 // Useless for our purpose
99 throw new UnsupportedOperationException("This method shouldn't be used, this class is read only");
100 }
101 public void setCreateInstance(boolean createInstance) {
102 // Useless for our purpose
103 throw new UnsupportedOperationException("This method shouldn't be used, this class is read only");
104 }
105 public void addCorrelation(CorrelationRef correlationRef) {
106 // Useless for our purpose
107 throw new UnsupportedOperationException("This method shouldn't be used, this class is read only");
108 }
109 public void setName(String name) {
110 // Useless for our purpose
111 throw new UnsupportedOperationException("This method shouldn't be used, this class is read only");
112 }
113 public String getJoinCondition() {
114 // Useless for our purpose
115 throw new UnsupportedOperationException("This method shouldn't be used, this class is read only");
116 }
117 public void setJoinCondition(String expr) {
118 // Useless for our purpose
119 throw new UnsupportedOperationException("This method shouldn't be used, this class is read only");
120 }
121 public Set getSourceLinks() {
122 // Useless for our purpose
123 throw new UnsupportedOperationException("This method shouldn't be used, this class is read only");
124 }
125 public void setSourceLinks(Set sources) {
126 // Useless for our purpose
127 throw new UnsupportedOperationException("This method shouldn't be used, this class is read only");
128 }
129 public Set getTargetLinks() {
130 // Useless for our purpose
131 throw new UnsupportedOperationException("This method shouldn't be used, this class is read only");
132 }
133 public void setTargetLinks(Set targets) {
134 // Useless for our purpose
135 throw new UnsupportedOperationException("This method shouldn't be used, this class is read only");
136 }
137
138 private MessageEvent getMessageEvent(int pos) {
139 return (MessageEvent) pick.getMessageEvents().get(pos);
140 }
141 }
This page was automatically generated by Maven