1
2
3
4
5
6
7
8 package it.imolinfo.jbi4corba.jbi.endpoint;
9
10 import it.imolinfo.jbi4corba.exception.Jbi4CorbaException;
11 import it.imolinfo.jbi4corba.jbi.component.Jbi4CorbaSUManager;
12 import it.imolinfo.jbi4corba.jbi.processor.ExchangeProcessor;
13 import javax.jbi.messaging.MessageExchange.Role;
14
15 import java.io.File;
16 import java.io.Serializable;
17
18 import javax.jbi.servicedesc.ServiceEndpoint;
19 import javax.wsdl.Definition;
20 import javax.xml.namespace.QName;
21
22 import org.w3c.dom.Document;
23
24 import com.sun.jbi.eManager.provider.EndpointStatus;
25 import com.sun.jbi.eManager.provider.StatusProviderHelper;
26
27
28
29
30 public abstract class Jbi4CorbaEndpoint implements Serializable {
31
32
33
34 private static final long serialVersionUID = -365758605104761399L;
35
36
37 public static final int SHUTDOWN = 0;
38
39
40 public static final int STOPPED = 1;
41
42
43 public static final int RUNNING = 2;
44
45
46 private QName serviceName = null;
47
48
49 private String endpointName = null;
50
51
52 private Definition definition;
53
54
55 private int state;
56
57
58 private EndpointStatus endpointStatus = null;
59
60
61
62
63 private ServiceEndpoint serviceEndpoint = null;
64
65
66 private Document serviceDescription = null;
67
68
69
70 private String suName = null;
71
72
73 private Jbi4CorbaSUManager suManager = null;
74
75
76 private ExchangeProcessor exchangeProcessor = null;
77
78
79 private File endpointWSDL = null;
80
81
82
83
84
85 public Jbi4CorbaEndpoint() {
86 }
87
88
89
90
91
92
93
94
95 public Jbi4CorbaEndpoint(QName serviceName, String endpointName) {
96 this.serviceName = serviceName;
97 this.endpointName = endpointName;
98 }
99
100
101
102
103
104
105 public String getUniqueName() {
106 String serviceNamespaceURI = getServiceName().getNamespaceURI();
107 String _serviceName = getServiceName().getLocalPart();
108 String _endpointName = getEndpointName();
109 return getUniqueName(serviceNamespaceURI, _serviceName, _endpointName, getRole().equals(Role.PROVIDER)? true:false);
110 }
111
112 public static String getUniqueName(String aServiceNamespaceURI,
113 String aServiceName,
114 String aEndpointName,
115 boolean isInbound) {
116 String aEndpointType =
117 isInbound ? StatusProviderHelper.PROVISIONING_ID : StatusProviderHelper.CONSUMING_ID ;
118 return aServiceNamespaceURI + "," + aServiceName + "," + aEndpointName + "," + aEndpointType;
119 }
120
121
122
123
124
125
126 public QName getServiceName() {
127 return serviceName;
128 }
129
130
131
132
133
134
135 public String getEndpointName() {
136 return endpointName;
137 }
138
139
140
141
142
143
144 public Definition getDefinition() {
145 return definition;
146 }
147
148
149
150
151
152
153 public void setDefinition(Definition definition) {
154 this.definition = definition;
155 }
156
157
158
159
160
161
162 public int getState() {
163 return state;
164 }
165
166
167
168
169
170
171 public void setState(int state) {
172 this.state = state;
173 }
174
175
176
177
178
179
180 public EndpointStatus getEndpointStatus() {
181 return endpointStatus;
182 }
183
184
185
186
187
188
189 public void setEndpointStatus(EndpointStatus endpointStatus) {
190 this.endpointStatus = endpointStatus;
191 }
192
193
194
195
196
197
198 public ServiceEndpoint getServiceEndpoint() {
199 return serviceEndpoint;
200 }
201
202
203
204
205
206
207 public void setServiceEndpoint(ServiceEndpoint serviceEndpoint) {
208 this.serviceEndpoint = serviceEndpoint;
209 }
210
211
212
213
214
215
216 public Document getServiceDescription() {
217 return serviceDescription;
218 }
219
220
221
222
223
224
225 public void setServiceDescription(Document serviceDescription) {
226 this.serviceDescription = serviceDescription;
227 }
228
229
230
231
232
233
234 public String getSuName() {
235 return suName;
236 }
237
238
239
240
241
242
243 public void setSuName(String suName) {
244 this.suName = suName;
245 }
246
247
248
249
250
251
252 public Jbi4CorbaSUManager getSuManager() {
253 return suManager;
254 }
255
256
257
258
259
260
261
262 public void setSuManager(Jbi4CorbaSUManager suManager) {
263 this.suManager = suManager;
264 }
265
266
267
268
269
270
271 public ExchangeProcessor getExchangeProcessor() {
272 return exchangeProcessor;
273 }
274
275
276
277
278
279
280 public void setExchangeProcessor(ExchangeProcessor exchangeProcessor) {
281 this.exchangeProcessor = exchangeProcessor;
282 }
283
284
285
286
287
288
289 public File getEndpointWSDL() {
290 return endpointWSDL;
291 }
292
293
294
295
296
297
298 public void setEndpointWSDL(File endpointWSDL) {
299 this.endpointWSDL = endpointWSDL;
300 }
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318 @Override
319 public boolean equals(Object obj) {
320 if (obj instanceof Jbi4CorbaEndpoint) {
321 Jbi4CorbaEndpoint c = (Jbi4CorbaEndpoint) obj;
322 if ((this.serviceName.equals(c.serviceName)) &&
323 (this.endpointName.equals(c.endpointName)) &&
324 (this.getRole().equals(c.getRole()))) {
325 return true;
326 }
327 }
328 return false;
329 }
330
331
332
333
334
335
336
337
338 @Override
339 public int hashCode() {
340 return this.serviceName.hashCode() ^ this.endpointName.hashCode() ^ this.getRole().hashCode();
341 }
342 @Override
343 public String toString() {
344 return this.serviceName+ ":" + endpointName +"/" + (getRole().equals(Role.PROVIDER)?"PROVIDER":"CONSUMER");
345 }
346
347
348
349
350
351
352 public abstract void registerService() throws Jbi4CorbaException;
353
354
355
356
357
358
359 public abstract void unregisterService() throws Jbi4CorbaException;
360
361
362
363
364
365
366 public abstract void validate() throws Jbi4CorbaException;
367
368
369
370
371
372
373 public abstract void activate() throws Jbi4CorbaException;
374
375
376
377
378
379
380 public abstract void deactivate() throws Jbi4CorbaException;
381
382
383
384
385
386 public abstract Role getRole();
387
388
389 }