1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.axis.message.addressing;
17
18 import java.io.Serializable;
19
20 import javax.xml.namespace.QName;
21
22 import org.apache.axis.description.ElementDesc;
23 import org.apache.axis.description.TypeDesc;
24 import org.apache.axis.encoding.AnyContentType;
25 import org.apache.axis.encoding.Deserializer;
26 import org.apache.axis.encoding.Serializer;
27 import org.apache.axis.encoding.ser.BeanDeserializer;
28 import org.apache.axis.encoding.ser.BeanSerializer;
29 import org.apache.axis.message.MessageElement;
30 import org.apache.axis.types.URI;
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71 public class EndpointReferenceType implements AnyContentType, Serializable {
72
73
74
75 private static final long serialVersionUID = 16342863069452848L;
76
77
78
79
80 private static final TypeDesc TYPE_DESC = new TypeDesc(EndpointReferenceType.class,
81 true);
82
83 static {
84 String ns = Constants.NS_URI_ADDRESSING_DEFAULT;
85 TYPE_DESC.setXmlType(new QName(ns, "EndpointReferenceType"));
86
87 ElementDesc elemField = new ElementDesc();
88 elemField.setFieldName("address");
89 elemField.setXmlName(new QName(ns, "Address"));
90 elemField.setXmlType(new QName(ns, "Address"));
91 TYPE_DESC.addFieldDesc(elemField);
92 elemField = new ElementDesc();
93 elemField.setFieldName("properties");
94 elemField.setXmlName(new QName(ns, "ReferenceProperties"));
95 elemField.setXmlType(new QName(ns, "ReferencePropertiesType"));
96 elemField.setMinOccurs(0);
97 TYPE_DESC.addFieldDesc(elemField);
98 elemField = new ElementDesc();
99 elemField.setFieldName("parameters");
100 elemField.setXmlName(new QName(ns, "ReferenceParameters"));
101 elemField.setXmlType(new QName(ns, "ReferenceParametersType"));
102 elemField.setMinOccurs(0);
103 TYPE_DESC.addFieldDesc(elemField);
104 elemField = new ElementDesc();
105 elemField.setFieldName("portType");
106 elemField.setXmlName(new QName(ns, "PortType"));
107 elemField.setXmlType(new QName(ns, "PortType"));
108 elemField.setMinOccurs(0);
109 TYPE_DESC.addFieldDesc(elemField);
110 elemField = new ElementDesc();
111 elemField.setFieldName("serviceName");
112 elemField.setXmlName(new QName(ns, "ServiceName"));
113 elemField.setXmlType(new QName(ns, "ServiceNameType"));
114 elemField.setMinOccurs(0);
115 TYPE_DESC.addFieldDesc(elemField);
116 elemField = new ElementDesc();
117 elemField.setFieldName("metadata");
118 elemField.setXmlName(new QName(ns, "Metadata"));
119 elemField.setXmlType(new QName(ns, "MetadataType"));
120 elemField.setMinOccurs(0);
121 TYPE_DESC.addFieldDesc(elemField);
122 }
123
124
125
126
127
128
129
130
131
132 public static Deserializer getDeserializer(String mType, Class<?> jType, QName xType) {
133 return new BeanDeserializer(jType, xType, TYPE_DESC);
134 }
135
136
137
138
139
140
141
142
143
144 public static Serializer getSerializer(String mType, Class<?> jType, QName xType) {
145 return new BeanSerializer(jType, xType, TYPE_DESC);
146 }
147
148
149
150
151
152
153 public static TypeDesc getTypeDesc() {
154 return TYPE_DESC;
155 }
156
157
158
159
160 private Address address;
161
162
163
164
165 private PortType portType;
166
167
168
169
170 private ServiceNameType serviceName;
171
172
173
174
175 private ReferencePropertiesType properties;
176
177
178
179
180 private ReferenceParametersType parameters;
181
182
183
184
185 protected MetaDataType metaData;
186
187
188
189
190 private MessageElement[] any;
191
192
193
194
195 public EndpointReferenceType() {
196 }
197
198
199
200
201
202
203 public EndpointReferenceType(Address address) {
204 this.address = address;
205 }
206
207
208
209
210
211
212 public EndpointReferenceType(EndpointReferenceType endpoint) {
213 this(endpoint, false);
214 }
215
216
217
218
219
220
221
222 public EndpointReferenceType(EndpointReferenceType endpoint, boolean deepCopy) {
223 if (deepCopy) {
224 this.deepCopy(endpoint);
225 } else {
226 this.shallowCopy(endpoint);
227 }
228 }
229
230
231
232
233
234
235 public EndpointReferenceType(URI addr) {
236 this.address = new Address(addr);
237 }
238
239
240
241
242
243
244
245
246 private MessageElement[] copy(MessageElement[] elems, boolean deep) {
247 if (elems == null || elems.length == 0) {
248 return new MessageElement[0];
249 } else if (deep) {
250 MessageElement[] copy = new MessageElement[elems.length];
251 for (int i = 0; i < elems.length; i++) {
252 MessageElement elem = elems[i];
253 try {
254 copy[i] = new MessageElement(elem.getAsDOM());
255 } catch (Exception e) {
256
257 copy[i] = elem;
258 }
259 }
260 return copy;
261 } else {
262 MessageElement[] copy = new MessageElement[elems.length];
263 System.arraycopy(elems, 0, copy, 0, elems.length);
264 return copy;
265 }
266 }
267
268
269
270
271
272
273 private void deepCopy(EndpointReferenceType endpoint) {
274 AttributedURI addr = endpoint.getAddress();
275 if (addr != null) {
276 this.setAddress(new Address(addr));
277 }
278 AttributedQName port = endpoint.getPortType();
279 if (port != null) {
280 this.setPortType(new PortType(port));
281 }
282 ServiceNameType sName = endpoint.getServiceName();
283 if (sName != null) {
284 this.setServiceName(new ServiceNameType(sName));
285 }
286 ReferencePropertiesType props = endpoint.getProperties();
287 if (props != null) {
288 this.setProperties(new ReferencePropertiesType(props, true));
289 }
290 ReferenceParametersType params = endpoint.getParameters();
291 if (params != null) {
292 this.setParameters(params);
293 }
294 MetaDataType metadata = endpoint.getMetadata();
295 if (metadata != null) {
296 this.setMetadata(metadata);
297 }
298
299
300 MessageElement[] elems = endpoint.get_any();
301 this.set_any(copy(elems, true));
302 }
303
304
305
306
307
308 public MessageElement[] get_any() {
309
310 return (this.any == null) ? null : this.any.clone();
311 }
312
313
314
315
316
317
318 public AttributedURI getAddress() {
319 return this.address;
320 }
321
322
323
324
325
326
327 public MetaDataType getMetadata() {
328 return this.metaData;
329 }
330
331
332
333
334
335
336 public ReferenceParametersType getParameters() {
337 if (this.parameters == null) {
338 this.parameters = new ReferenceParametersType();
339 }
340 return this.parameters;
341 }
342
343
344
345
346
347
348 public AttributedQName getPortType() {
349 return this.portType;
350 }
351
352
353
354
355
356
357 public ReferencePropertiesType getProperties() {
358 if (this.properties == null) {
359 this.properties = new ReferencePropertiesType();
360 }
361 return this.properties;
362 }
363
364
365
366
367
368
369 public ServiceNameType getServiceName() {
370 return this.serviceName;
371 }
372
373
374
375
376
377 public void set_any(MessageElement[] any) {
378
379 this.any = (any == null) ? null : any.clone();
380 }
381
382
383
384
385
386
387 public void setAddress(AttributedURI addr) {
388 if (addr instanceof Address) {
389 this.address = (Address)addr;
390 } else {
391 this.address = (addr == null) ? null : new Address(addr);
392 }
393 }
394
395
396
397
398
399
400 public void setMetadata(MetaDataType metaData) {
401 this.metaData = metaData;
402 }
403
404
405
406
407
408
409 public void setParameters(ReferenceParametersType parameters) {
410 this.parameters = parameters;
411 }
412
413
414
415
416
417
418 public void setPortType(AttributedQName portType) {
419 if (portType instanceof PortType) {
420 this.portType = (PortType)portType;
421 } else {
422 this.portType = (portType == null) ? null : new PortType(portType);
423 }
424 }
425
426
427
428
429
430
431 public void setProperties(ReferencePropertiesType properties) {
432 this.properties = properties;
433 }
434
435
436
437
438
439
440 public void setServiceName(ServiceNameType serviceName) {
441 this.serviceName = serviceName;
442 }
443
444
445
446
447
448
449 private void shallowCopy(EndpointReferenceType endpoint) {
450 this.setAddress(endpoint.getAddress());
451 this.setPortType(endpoint.getPortType());
452 this.setServiceName(endpoint.getServiceName());
453 ReferencePropertiesType props = endpoint.getProperties();
454 if (props != null) {
455 this.setProperties(new ReferencePropertiesType(props, false));
456 }
457 ReferenceParametersType params = endpoint.getParameters();
458 if (params != null) {
459 this.setParameters(new ReferenceParametersType(params, false));
460 }
461 MetaDataType metadata = endpoint.getMetadata();
462 if (metadata != null) {
463 this.setMetadata(new MetaDataType(metadata, false));
464 }
465
466
467 MessageElement[] elems = endpoint.get_any();
468 this.set_any(elems);
469 }
470
471
472
473
474 @Override
475 public String toString() {
476 StringBuffer buf = new StringBuffer();
477 if (this.address != null) {
478 buf.append("Address: ").append(this.address);
479 buf.append("\n");
480 }
481 if (this.portType != null) {
482 buf.append("Port Type: ").append(this.portType);
483 buf.append("\n");
484 }
485 if (this.serviceName != null) {
486 buf.append("Service Name: ").append(this.serviceName);
487 buf.append("\n");
488 if (this.serviceName.getPort() != null) {
489 buf.append("Port Name: ").append(this.serviceName.getPort());
490 buf.append("\n");
491 }
492 }
493 if (this.properties != null) {
494 buf.append(this.properties);
495 buf.append("\n");
496 }
497 if (this.parameters != null) {
498 buf.append(this.parameters);
499 buf.append("\n");
500 }
501 if (this.metaData != null) {
502 buf.append(this.metaData);
503 buf.append("\n");
504 }
505
506 if (this.any != null) {
507 for (int i = 0; i < this.any.length; i++) {
508 buf.append("Extensibility Element[").append(i).append("]:\n");
509 try {
510 buf.append(this.any[i].getAsString());
511 } catch (Exception e) {
512 buf.append("<error converting: ").append(e.getMessage()).append(">");
513 }
514 buf.append("\n");
515 }
516 }
517 return buf.toString();
518 }
519 }