1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
|
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.tuscany.sca.binding.jms.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import org.apache.tuscany.sca.assembly.BindingRRB;
import org.apache.tuscany.sca.assembly.OperationSelector;
import org.apache.tuscany.sca.assembly.WireFormat;
import org.apache.tuscany.sca.policy.Intent;
import org.apache.tuscany.sca.policy.IntentAttachPointType;
import org.apache.tuscany.sca.policy.PolicySet;
import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
/**
* Models a binding to a JMS resource.
*
* @version $Rev$ $Date$
*/
public class JMSBinding implements BindingRRB, PolicySetAttachPoint {
@Override
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
// properties required to implement the Tuscany binding extension SPI
private String uri = null;
private String name = null;
private boolean unresolved = false;
private List<Object> extensions = new ArrayList<Object>();
// properties required by PolicySetAttachPoint
private List<PolicySet> policySets = new ArrayList<PolicySet>();
private List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>();
// properties required by IntentAttachPoint
private List<Intent> requiredIntents = new ArrayList<Intent>();
private IntentAttachPointType intentAttachPointType;
// Properties required to describe the JMS binding model
private String correlationScheme = JMSBindingConstants.CORRELATE_MSG_ID;
private String initialContextFactoryName;
private String jndiURL;
private String destinationName = JMSBindingConstants.DEFAULT_DESTINATION_NAME;
private String destinationType = JMSBindingConstants.DESTINATION_TYPE_QUEUE;
private String destinationCreate = JMSBindingConstants.CREATE_IF_NOT_EXIST;
private Map<String, BindingProperty> destinationProperties = new HashMap<String, BindingProperty>();
private String connectionFactoryName = JMSBindingConstants.DEFAULT_CONNECTION_FACTORY_NAME;
private String connectionFactoryCreate = JMSBindingConstants.CREATE_IF_NOT_EXIST;
private Map<String, BindingProperty> connectionFactoryProperties = new HashMap<String, BindingProperty>();
private String activationSpecName = null;
private String activationSpecCreate = null;
private Map<String, BindingProperty> activationSpecProperties = new HashMap<String, BindingProperty>();
private String resourceAdapterName;;
private Map<String, BindingProperty> resourceAdapterProperties = new HashMap<String, BindingProperty>();
private String responseActivationSpecName = null;
private String responseActivationSpecCreate = null;
private Map<String, BindingProperty> responseActivationSpecProperties = new HashMap<String, BindingProperty>();
private String responseDestinationName = JMSBindingConstants.DEFAULT_RESPONSE_DESTINATION_NAME;
private String responseDestinationType = JMSBindingConstants.DESTINATION_TYPE_QUEUE;
private String responseDestinationCreate = JMSBindingConstants.CREATE_IF_NOT_EXIST;
private Map<String, BindingProperty> responseDestinationProperties = new HashMap<String, BindingProperty>();
private String responseConnectionFactoryName = JMSBindingConstants.DEFAULT_CONNECTION_FACTORY_NAME;
private String responseConnectionFactoryCreate = JMSBindingConstants.CREATE_IF_NOT_EXIST;
private Map<String, BindingProperty> responseConnectionFactoryProperties = new HashMap<String, BindingProperty>();
// Provides the name of the factory that interfaces to the JMS API for us.
private String jmsResourceFactoryName = JMSBindingConstants.DEFAULT_RF_CLASSNAME;
// Message processors used to deal with the request and response messages
public String requestMessageProcessorName = JMSBindingConstants.DEFAULT_MP_CLASSNAME;
public String responseMessageProcessorName = JMSBindingConstants.DEFAULT_MP_CLASSNAME;
// The JMS message property used to hold the name of the operation being called
private String operationSelectorPropertyName = JMSBindingConstants.DEFAULT_OPERATION_PROP_NAME;
// If the operation selector is derived automatically from the service interface it's stored here
private String operationSelectorName = null;
private String replyTo;
private String jmsType;
private String jmsCorrelationId;
private Boolean deliveryModePersistent;
private Long timeToLive;
private Integer jmsPriority;
private Map<String, Object> properties = new HashMap<String, Object>();
private Map<String, Map<String, Object>> operationProperties = new HashMap<String, Map<String,Object>>();
private Map<String, String> nativeOperationNames = new HashMap<String, String>();
private Map<String, String> operationJMSTypes = new HashMap<String, String>();
private Map<String, String> operationJMSCorrelationIds = new HashMap<String, String>();
private Map<String, Boolean> operationJMSDeliveryModes = new HashMap<String, Boolean>();
private Map<String, Long> operationJMSTimeToLives = new HashMap<String, Long>();
private Map<String, Integer> operationJMSPriorities = new HashMap<String, Integer>();
private Map<String, Map<String, BindingProperty>> operationPropertiesProperties = new HashMap<String, Map<String,BindingProperty>>();
private String jmsSelector;
private String requestConnectionName;
private String responseConnectionName;
private JMSBinding requestConnectionBinding;
private JMSBinding responseConnectionBinding;
private WireFormat requestWireFormat;
private WireFormat responseWireFormat;
private OperationSelector operationSelector;
public JMSBinding() {
super();
}
// operations required by Binding
public String getURI() {
return this.uri;
}
public void setURI(String uri) {
this.uri = uri;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public boolean isUnresolved() {
return this.unresolved;
}
public void setUnresolved(boolean unresolved) {
this.unresolved = unresolved;
}
public List<Object> getExtensions() {
return extensions;
}
public WireFormat getRequestWireFormat() {
return requestWireFormat;
}
public void setRequestWireFormat(WireFormat wireFormat) {
this.requestWireFormat = wireFormat;
}
public WireFormat getResponseWireFormat() {
return responseWireFormat;
}
public void setResponseWireFormat(WireFormat wireFormat) {
this.responseWireFormat = wireFormat;
}
public OperationSelector getOperationSelector() {
return operationSelector;
}
public void setOperationSelector(OperationSelector operationSelector) {
this.operationSelector = operationSelector;
}
// Methods for getting/setting JMS binding model information
// as derived from the XML of the binding.jms element
public void setCorrelationScheme(String correlationScheme) {
this.correlationScheme = correlationScheme;
}
public String getCorrelationScheme() {
return correlationScheme;
}
public String getInitialContextFactoryName() {
return initialContextFactoryName;
}
public void setInitialContextFactoryName(String initialContextFactoryName) {
this.initialContextFactoryName = initialContextFactoryName;
}
public String getJndiURL() {
return this.jndiURL;
}
public void setJndiURL(String jndiURL) {
this.jndiURL = jndiURL;
}
public String getDestinationName() {
if (requestConnectionBinding != null && requestConnectionBinding.getDestinationName() != null) {
return requestConnectionBinding.getDestinationName();
} else {
return destinationName;
}
}
public void setDestinationName(String destinationName) {
this.destinationName = destinationName;
}
public String getDestinationType() {
if (requestConnectionBinding != null && requestConnectionBinding.getDestinationType() != null) {
return requestConnectionBinding.getDestinationType();
} else {
return destinationType;
}
}
public void setDestinationType(String destinationType) {
this.destinationType = destinationType;
}
public String getDestinationCreate() {
if (requestConnectionBinding != null && requestConnectionBinding.getDestinationCreate() != null) {
return requestConnectionBinding.getDestinationCreate();
} else {
return this.destinationCreate;
}
}
public void setDestinationCreate(String create) {
this.destinationCreate = create;
}
public String getConnectionFactoryName() {
if (requestConnectionBinding != null && requestConnectionBinding.getConnectionFactoryName() != null) {
return requestConnectionBinding.getConnectionFactoryName();
} else {
return connectionFactoryName;
}
}
public void setConnectionFactoryName(String connectionFactoryName) {
this.connectionFactoryName = connectionFactoryName;
}
public String getConnectionFactoryCreate() {
if (requestConnectionBinding != null && requestConnectionBinding.getConnectionFactoryCreate() != null) {
return requestConnectionBinding.getConnectionFactoryCreate();
} else {
return this.connectionFactoryCreate;
}
}
public void setConnectionFactoryCreate(String create) {
this.connectionFactoryCreate = create;
}
public String getResourceAdapterName() {
return resourceAdapterName;
}
public void setResourceAdapterName(String name) {
resourceAdapterName = name;
}
public String getActivationSpecName() {
if (requestConnectionBinding != null && requestConnectionBinding.getActivationSpecName() != null) {
return requestConnectionBinding.getActivationSpecName();
} else {
return activationSpecName;
}
}
public void setActivationSpecName(String activationSpecName) {
this.activationSpecName = activationSpecName;
}
public String getActivationSpecCreate() {
if (requestConnectionBinding != null && requestConnectionBinding.getActivationSpecCreate() != null) {
return requestConnectionBinding.getActivationSpecCreate();
} else {
return this.activationSpecCreate;
}
}
public void setActivationSpecCreate(String create) {
this.activationSpecCreate = create;
}
public String getResponseDestinationName() {
if (requestConnectionBinding != null && requestConnectionBinding.getResponseDestinationName() != null) {
return requestConnectionBinding.getResponseDestinationName();
} else {
return this.responseDestinationName;
}
}
public void setResponseDestinationName(String name) {
this.responseDestinationName = name;
}
public String getResponseDestinationType() {
if (requestConnectionBinding != null && requestConnectionBinding.getResponseDestinationType() != null) {
return requestConnectionBinding.getResponseDestinationType();
} else {
return this.responseDestinationType;
}
}
public void setResponseDestinationType(String type) {
this.responseDestinationType = type;
}
public String getResponseDestinationCreate() {
if (requestConnectionBinding != null && requestConnectionBinding.getResponseDestinationCreate() != null) {
return requestConnectionBinding.getResponseDestinationCreate();
} else {
return this.responseDestinationCreate;
}
}
public void setResponseDestinationCreate(String create) {
this.responseDestinationCreate = create;
}
public String getResponseConnectionFactoryName() {
if (requestConnectionBinding != null && requestConnectionBinding.getResponseConnectionFactoryName() != null) {
return requestConnectionBinding.getResponseConnectionFactoryName();
} else {
return responseConnectionFactoryName;
}
}
public void setResponseConnectionFactoryName(String connectionFactoryName) {
this.responseConnectionFactoryName = connectionFactoryName;
}
public String getResponseConnectionFactoryCreate() {
if (requestConnectionBinding != null && requestConnectionBinding.getResponseConnectionFactoryCreate() != null) {
return requestConnectionBinding.getResponseConnectionFactoryCreate();
} else {
return this.responseConnectionFactoryCreate;
}
}
public void setResponseConnectionFactoryCreate(String create) {
this.responseConnectionFactoryCreate = create;
}
public String getResponseActivationSpecName() {
if (requestConnectionBinding != null && requestConnectionBinding.getResponseActivationSpecName() != null) {
return requestConnectionBinding.getResponseActivationSpecName();
} else {
return responseActivationSpecName;
}
}
public void setResponseActivationSpecName(String activationSpecName) {
this.responseActivationSpecName = activationSpecName;
}
public String getResponseActivationSpecCreate() {
if (requestConnectionBinding != null && requestConnectionBinding.getResponseActivationSpecCreate() != null) {
return requestConnectionBinding.getResponseActivationSpecCreate();
} else {
return this.responseActivationSpecCreate;
}
}
public void setResponseActivationSpecCreate(String create) {
this.responseActivationSpecCreate = create;
}
public String getJmsResourceFactoryName() {
return jmsResourceFactoryName;
}
public void setJmsResourceFactoryName(String jmsResourceFactoryName) {
this.jmsResourceFactoryName = jmsResourceFactoryName;
}
public void setRequestMessageProcessorName(String name) {
this.requestMessageProcessorName = name;
}
public String getRequestMessageProcessorName() {
return requestMessageProcessorName;
}
public void setResponseMessageProcessorName(String name) {
this.responseMessageProcessorName = name;
}
public String getResponseMessageProcessorName() {
return responseMessageProcessorName;
}
public String getOperationSelectorPropertyName() {
return operationSelectorPropertyName;
}
public void setOperationSelectorPropertyName(String operationSelectorPropertyName) {
this.operationSelectorPropertyName = operationSelectorPropertyName;
}
public String getOperationSelectorName() {
return operationSelectorName;
}
public void setOperationSelectorName(String operationSelectorName) {
this.operationSelectorName = operationSelectorName;
}
public String getReplyTo() {
return replyTo;
}
public void setReplyTo(String replyTo) {
this.replyTo = replyTo;
}
public String getJMSType() {
return jmsType;
}
public void setJMSType(String jmsType) {
this.jmsType = jmsType;
}
public String getJMSCorrelationId() {
return jmsCorrelationId;
}
public void setJMSCorrelationId(String jmsCorrelationId) {
this.jmsCorrelationId = jmsCorrelationId;
}
public Boolean isdeliveryModePersistent() {
return deliveryModePersistent;
}
public void setJMSDeliveryMode(boolean persistent) {
this.deliveryModePersistent = Boolean.valueOf(persistent);
}
public Integer getJMSPriority() {
return jmsPriority;
}
public void setJMSPriority(int jmsPriority) {
this.jmsPriority = Integer.valueOf(jmsPriority);
}
public Long getJMSTimeToLive() {
return timeToLive.longValue();
}
public void setJMSTimeToLive(long timeToLive) {
this.timeToLive = Long.valueOf(timeToLive);
}
public Set<String> getPropertyNames() {
return properties.keySet();
}
public Object getProperty(String name) {
return properties.get(name);
}
public void setProperty(String name, Object value) {
properties.put(name, value);
}
/**
* Adds an operationName to this binding.
* @param opName
*/
public void addOperationName(String opName) {
Map<String, Object> props = operationProperties.get(opName);
if (props == null) {
props = new HashMap<String, Object>();
operationProperties.put(opName, props);
}
}
/**
* Provides set of operation names in this binding.
* @return a Set<String> of operation names
*/
public Set<String> getOperationNames() {
// Make a defensive copy since key changes affect map, map changes affect keys.
Set<String> opNames = operationProperties.keySet();
Set<String> opNamesCopy = new TreeSet<String>( opNames );
return opNamesCopy;
}
public Map<String, Object> getOperationProperties(String opName) {
return operationProperties.get(opName);
}
public void setOperationProperty(String opName, String propName, Object value) {
Map<String, Object> props = operationProperties.get(opName);
if (props == null) {
props = new HashMap<String, Object>();
operationProperties.put(opName, props);
}
props.put(propName, value);
}
/**
* Provides the value of a property for a given operation
* @param opName is the name of the operation in this binding.
* @param propName is the key name for the property
* @return Object representing the property value for this property name. Returns
* null for non existant operation name or property name.
*/
public Object getOperationProperty(String opName, String propName ) {
Map<String, Object> props = operationProperties.get(opName);
if (props == null) {
return null;
}
return props.get(propName);
}
public boolean hasNativeOperationName(String opName) {
return nativeOperationNames.containsKey(opName);
}
public String getNativeOperationName(String opName) {
if (nativeOperationNames.containsKey(opName)) {
return nativeOperationNames.get(opName);
} else {
return opName;
}
}
public void setNativeOperationName(String opName, String nativeOpName) {
this.nativeOperationNames .put(opName, nativeOpName);
}
public String getOperationJMSType(String opName) {
if (operationJMSTypes.containsKey(opName)) {
return operationJMSTypes.get(opName);
} else {
return jmsType;
}
}
public void setOperationJMSType(String opName, String jmsType) {
this.operationJMSTypes.put(opName, jmsType);
}
public String getOperationJMSCorrelationId(String opName) {
if (operationJMSCorrelationIds.containsKey(opName)) {
return operationJMSCorrelationIds.get(opName);
} else {
return jmsCorrelationId;
}
}
public void setOperationJMSCorrelationId(String opName, String jmsCorrelationId) {
operationJMSCorrelationIds.put(opName, jmsCorrelationId);
}
public Boolean getOperationJMSDeliveryMode(String opName) {
if (operationJMSDeliveryModes.containsKey(opName)) {
return operationJMSDeliveryModes.get(opName);
} else {
return deliveryModePersistent;
}
}
public void setOperationJMSDeliveryMode(String opName, boolean b) {
operationJMSDeliveryModes.put(opName, b);
}
public Long getOperationJMSTimeToLive(String opName) {
if (operationJMSTimeToLives.containsKey(opName)) {
return operationJMSTimeToLives.get(opName);
} else {
return timeToLive;
}
}
public void setOperationJMSTimeToLive(String opName, Long ttl) {
operationJMSTimeToLives.put(opName, ttl);
}
public Integer getOperationJMSPriority(String opName) {
if (operationJMSPriorities.containsKey(opName)) {
return operationJMSPriorities.get(opName);
} else {
return jmsPriority;
}
}
public void setOperationJMSPriority(String opName, int p) {
operationJMSPriorities.put(opName, p);
}
public String getJMSSelector() {
return jmsSelector;
}
public void setJMSSelector(String jmsSelector) {
this.jmsSelector = jmsSelector;
}
public String getRequestConnectionName() {
return requestConnectionName;
}
public void setRequestConnectionName(String requestConnectionName) {
this.requestConnectionName = requestConnectionName;
}
public void setResponseConnectionName(String responseConnectionName) {
this.responseConnectionName = responseConnectionName;
}
public String getResponseConnectionName() {
return responseConnectionName;
}
public void setRequestConnectionBinding(JMSBinding binding) {
this.requestConnectionBinding = binding;
}
public JMSBinding getRequestConnectionBinding() {
return requestConnectionBinding;
}
public void setResponseConnectionBinding(JMSBinding binding) {
this.responseConnectionBinding = binding;
}
public JMSBinding getResponseConnectionBinding() {
return responseConnectionBinding;
}
// operations required by PolicySetAttachPoint
public List<PolicySet> getPolicySets() {
return policySets;
}
public List<PolicySet> getApplicablePolicySets() {
return applicablePolicySets;
}
// operations required by IntentAttachPoint
public List<Intent> getRequiredIntents() {
return requiredIntents;
}
public IntentAttachPointType getType() {
return intentAttachPointType;
}
public void setType(IntentAttachPointType intentAttachPointType) {
this.intentAttachPointType = intentAttachPointType;
}
public Map<String, BindingProperty> getDestinationProperties() {
return destinationProperties;
}
public Map<String, BindingProperty> getConnectionFactoryProperties() {
return connectionFactoryProperties;
}
public Map<String, BindingProperty> getResourceAdapterProperties() {
return resourceAdapterProperties;
}
public Map<String, BindingProperty> getActivationSpecProperties() {
return activationSpecProperties;
}
public Map<String, BindingProperty> getResponseActivationSpecProperties() {
return responseActivationSpecProperties;
}
public Map<String, BindingProperty> getResponseDestinationProperties() {
return responseDestinationProperties;
}
public Map<String, BindingProperty> getResponseConnectionFactoryProperties() {
return responseConnectionFactoryProperties;
}
public Map<String, BindingProperty> getOperationPropertiesProperties(String opName) {
if (operationPropertiesProperties.get(opName)==null) {
operationPropertiesProperties.put(opName, new HashMap<String, BindingProperty>());
}
return operationPropertiesProperties.get(opName);
}
}
|