/
JTAEnvironmentBean.java
1313 lines (1195 loc) · 49.2 KB
/
JTAEnvironmentBean.java
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
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags.
* See the copyright.txt in the distribution for a
* full listing of individual contributors.
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License, v. 2.1.
* This program is distributed in the hope that it will be useful, but WITHOUT A
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License,
* v.2.1 along with this distribution; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
* (C) 2009,
* @author JBoss, a division of Red Hat.
*/
package com.arjuna.ats.jta.common;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.transaction.TransactionManager;
import javax.transaction.TransactionSynchronizationRegistry;
import javax.transaction.UserTransaction;
import org.jboss.tm.usertx.UserTransactionOperationsProvider;
import org.jboss.tm.usertx.client.ServerVMClientUserTransactionOperationsProvider;
import com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecordWrappingPlugin;
import com.arjuna.ats.jta.recovery.XAResourceOrphanFilter;
import com.arjuna.ats.jta.recovery.XAResourceRecovery;
import com.arjuna.ats.jta.resources.XAResourceMap;
import com.arjuna.common.internal.util.ClassloadingUtility;
import com.arjuna.common.internal.util.propertyservice.ConcatenationPrefix;
import com.arjuna.common.internal.util.propertyservice.FullPropertyName;
import com.arjuna.common.internal.util.propertyservice.PropertyPrefix;
/**
* A JavaBean containing configuration properties for the JTA subsystem.
*
* @author Jonathan Halliday (jonathan.halliday@redhat.com)
*/
@PropertyPrefix(prefix = "com.arjuna.ats.jta.")
public class JTAEnvironmentBean implements JTAEnvironmentBeanMBean
{
private volatile boolean supportSubtransactions = false;
private volatile String transactionManagerClassName = "com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple";
private volatile TransactionManager transactionManager = null;
private volatile String userTransactionClassName = "com.arjuna.ats.internal.jta.transaction.arjunacore.UserTransactionImple";
private volatile UserTransaction userTransaction = null;
private volatile String transactionSynchronizationRegistryClassName = "com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple";
private volatile TransactionSynchronizationRegistry transactionSynchronizationRegistry = null;
@ConcatenationPrefix(prefix = "com.arjuna.ats.jta.xaRecoveryNode")
private volatile List<String> xaRecoveryNodes = new ArrayList<String>();
@ConcatenationPrefix(prefix = "com.arjuna.ats.jta.recovery.XAResourceRecovery")
private volatile List<String> xaResourceRecoveryClassNames = new ArrayList<String>();
private volatile List<XAResourceRecovery> xaResourceRecoveries = null;
private volatile List<String> xaResourceOrphanFilterClassNames = new ArrayList<String>();
private volatile List<XAResourceOrphanFilter> xaResourceOrphanFilters = null;
private volatile boolean xaRollbackOptimization = false;
private volatile boolean xaAssumeRecoveryComplete = false;
// com.arjuna.ats.jta.utils.
@FullPropertyName(name = "com.arjuna.ats.jta.utils.UTJNDIContext")
private volatile String userTransactionJNDIContext = "java:/UserTransaction";
@FullPropertyName(name = "com.arjuna.ats.jta.utils.TMJNDIContext")
private volatile String transactionManagerJNDIContext = "java:/TransactionManager";
@FullPropertyName(name = "com.arjuna.ats.jta.utils.TSRJNDIContext")
private volatile String transactionSynchronizationRegistryJNDIContext = "java:/TransactionSynchronizationRegistry";
@ConcatenationPrefix(prefix = "com.arjuna.ats.jta.xaErrorHandler")
private volatile List<String> xaResourceMapClassNames = new ArrayList<String>();
private volatile List<XAResourceMap> xaResourceMaps = null;
private volatile boolean xaTransactionTimeoutEnabled = true;
private volatile String lastResourceOptimisationInterfaceClassName = "com.arjuna.ats.jta.resources.LastResourceCommitOptimisation";
private volatile Class lastResourceOptimisationInterface = null;
private volatile String xaResourceRecordWrappingPluginClassName;
private volatile XAResourceRecordWrappingPlugin xaResourceRecordWrappingPlugin;
private int asyncCommitPoolSize = 10;
private int orphanSafetyInterval = 20000;
private String commitMarkableResourceTableName = "xids";
private Map<String, String> commitMarkableResourceTableNameMap = new HashMap<String, String>();
private List<String> commitMarkableResourceJNDINames = new ArrayList<String>();
private boolean performImmediateCleanupOfCommitMarkableResourceBranches = false;
private boolean notifyCommitMarkableResourceRecoveryModuleOfCompleteBranches = true;
private int commitMarkableResourceRecordDeleteBatchSize = 30000;
private Map<String, Boolean> performImmediateCleanupOfCommitMarkableResourceBranchesMap = new HashMap<String, Boolean>();
private Map<String, Integer> commitMarkableResourceRecordDeleteBatchSizeMap = new HashMap<String, Integer>();
private static final String defaultTransactionOperationsProviderClassName = ServerVMClientUserTransactionOperationsProvider.class.getName();
private volatile String userTransactionOperationsProviderClassName = defaultTransactionOperationsProviderClassName;
private volatile UserTransactionOperationsProvider userTransactionOperationsProvider = null;
private boolean strictJTA12DuplicateXAENDPROTOErr = false;
/**
* Returns true if subtransactions are allowed.
* Warning: subtransactions are not JTA spec compliant and most XA resource managers don't understand them.
*
* Default: false.
* Equivalent deprecated property: com.arjuna.ats.jta.supportSubtransactions
*
* @return true if subtransactions are enabled, false otherwise.
*/
public boolean isSupportSubtransactions()
{
return supportSubtransactions;
}
/**
* Sets if subtransactions should be allowed.
*
* @param supportSubtransactions true to enable subtransactions, false to disable.
*/
public void setSupportSubtransactions(boolean supportSubtransactions)
{
this.supportSubtransactions = supportSubtransactions;
}
/**
* Returns the class name of the javax.transaction.TransactionManager implementation.
*
* Default: "com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple"
* Equivalent deprecated property: com.arjuna.ats.jta.transactionManagerClassName
*
* @return the name of the class implementing TransactionManager.
*/
public String getTransactionManagerClassName()
{
return transactionManagerClassName;
}
/**
* Sets the class name of the javax.transaction.TransactionManager implementation.
*
* @param transactionManagerClassName the name of a class which implements TransactionManager.
*/
public void setTransactionManagerClassName(String transactionManagerClassName)
{
synchronized(this)
{
if(transactionManagerClassName == null)
{
this.transactionManager = null;
}
else if(!transactionManagerClassName.equals(this.transactionManagerClassName))
{
this.transactionManager = null;
}
this.transactionManagerClassName = transactionManagerClassName;
}
}
/**
* Returns an instance of a class implementing javax.transaction.TransactionManager.
*
* If there is no pre-instantiated instance set and classloading or instantiation fails,
* this method will log an appropriate warning and return null, not throw an exception.
*
* @return a javax.transaction.TransactionManager implementation instance, or null.
*/
public TransactionManager getTransactionManager()
{
if(transactionManager == null && transactionManagerClassName != null)
{
synchronized(this) {
if(transactionManager == null && transactionManagerClassName != null) {
TransactionManager instance = ClassloadingUtility.loadAndInstantiateClass(TransactionManager.class, transactionManagerClassName, null);
transactionManager = instance;
}
}
}
return transactionManager;
}
/**
* Sets the instance of javax.transaction.TransactionManager
*
* @param instance an Object that implements javax.transaction.TransactionManager, or null.
*/
public void setTransactionManager(TransactionManager instance)
{
synchronized(this)
{
TransactionManager oldInstance = this.transactionManager;
transactionManager = instance;
if(instance == null)
{
this.transactionManagerClassName = null;
}
else if(instance != oldInstance)
{
String name = ClassloadingUtility.getNameForClass(instance);
this.transactionManagerClassName = name;
}
}
}
/**
* Returns the class name of the javax.transaction.UserTransaction implementation.
*
* Default: "com.arjuna.ats.internal.jta.transaction.arjunacore.UserTransactionImple"
* Equivalent deprecated property: com.arjuna.ats.jta.userTransactionClassName
*
* @return the name of the class implementing javax.transaction.UserTransaction.
*/
public String getUserTransactionClassName()
{
return userTransactionClassName;
}
/**
* Sets the class name of the javax.transaction.UserTransaction implementation.
*
* @param userTransactionClassName the name of a class which implements javax.transaction.UserTransaction.
*/
public void setUserTransactionClassName(String userTransactionClassName)
{
synchronized(this)
{
if(userTransactionClassName == null)
{
this.userTransaction = null;
}
else if(!userTransactionClassName.equals(this.userTransactionClassName))
{
this.userTransaction = null;
}
this.userTransactionClassName = userTransactionClassName;
}
}
/**
* Returns an instance of a class implementing javax.transaction.UserTransaction.
*
* If there is no pre-instantiated instance set and classloading or instantiation fails,
* this method will log an appropriate warning and return null, not throw an exception.
*
* @return a javax.transaction.UserTransaction implementation instance, or null.
*/
public UserTransaction getUserTransaction()
{
if(userTransaction == null && userTransactionClassName != null)
{
synchronized (this) {
if(userTransaction == null && userTransactionClassName != null) {
UserTransaction instance = ClassloadingUtility.loadAndInstantiateClass(UserTransaction.class, userTransactionClassName, null);
userTransaction = instance;
}
}
}
return userTransaction;
}
/**
* Sets the instance of javax.transaction.UserTransaction
*
* @param instance an Object that implements javax.transaction.UserTransaction, or null.
*/
public void setUserTransaction(UserTransaction instance)
{
synchronized(this)
{
UserTransaction oldInstance = this.userTransaction;
userTransaction = instance;
if(instance == null)
{
this.userTransactionClassName = null;
}
else if(instance != oldInstance)
{
String name = ClassloadingUtility.getNameForClass(instance);
this.userTransactionClassName = name;
}
}
}
/**
* Returns the class name of the javax.transaction.TransactionSynchronizationRegistry implementation.
*
* Default: "com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple"
* Equivalent deprecated property: com.arjuna.ats.jta.transactionSynchronizationRegistryClassName
*
* @return the name of the class implementing javax.transaction.TransactionSynchronizationRegistry.
*/
public String getTransactionSynchronizationRegistryClassName()
{
return transactionSynchronizationRegistryClassName;
}
/**
* Sets the class name of the javax.transaction.TransactionSynchronizationRegistry implementation.
*
* @param transactionSynchronizationRegistryClassName the name of a class which implements TransactionSynchronizationRegistry.
*/
public void setTransactionSynchronizationRegistryClassName(String transactionSynchronizationRegistryClassName)
{
synchronized(this)
{
if(transactionSynchronizationRegistryClassName == null)
{
this.transactionSynchronizationRegistry = null;
}
else if(!transactionSynchronizationRegistryClassName.equals(this.transactionSynchronizationRegistryClassName))
{
this.transactionSynchronizationRegistry = null;
}
this.transactionSynchronizationRegistryClassName = transactionSynchronizationRegistryClassName;
}
}
/**
* Returns an instance of a class implementing javax.transaction.transactionSynchronizationRegistry.
*
* If there is no pre-instantiated instance set and classloading or instantiation fails,
* this method will log an appropriate warning and return null, not throw an exception.
*
* @return a javax.transaction.TransactionSynchronizationRegistry implementation instance, or null.
*/
public TransactionSynchronizationRegistry getTransactionSynchronizationRegistry()
{
if(transactionSynchronizationRegistry == null && transactionSynchronizationRegistryClassName != null)
{
synchronized (this) {
if(transactionSynchronizationRegistry == null && transactionSynchronizationRegistryClassName != null) {
TransactionSynchronizationRegistry instance = ClassloadingUtility.loadAndInstantiateClass(TransactionSynchronizationRegistry.class, transactionSynchronizationRegistryClassName, null);
transactionSynchronizationRegistry = instance;
}
}
}
return transactionSynchronizationRegistry;
}
/**
* Sets the instance of javax.transaction.TransactionSynchronizationRegistry
*
* @param instance an Object that implements javax.transaction.TransactionSynchronizationRegistry, or null.
*/
public void setTransactionSynchronizationRegistry(TransactionSynchronizationRegistry instance)
{
synchronized(this)
{
TransactionSynchronizationRegistry oldInstance = this.transactionSynchronizationRegistry;
transactionSynchronizationRegistry = instance;
if(instance == null)
{
this.transactionSynchronizationRegistryClassName = null;
}
else if(instance != oldInstance)
{
String name = ClassloadingUtility.getNameForClass(instance);
this.transactionSynchronizationRegistryClassName = name;
}
}
}
/**
* Returns the set of node identifiers for which recovery will be performed.
* The returned list is a copy. May return an empty list, will not return null.
*
* Default: empty list.
* Equivalent deprecated property prefix: com.arjuna.ats.jta.xaRecoveryNode
*
* @return the set of node identifiers for which to perform recovery.
*/
public List<String> getXaRecoveryNodes()
{
return new ArrayList<String>(xaRecoveryNodes);
}
/**
* Sets the node identifiers for which recovery will be performed.
* The provided list will be copied, not retained.
*
* @param xaRecoveryNodes the set of node identifiers for which to perform recovery.
*/
public void setXaRecoveryNodes(List<String> xaRecoveryNodes)
{
if(xaRecoveryNodes == null) {
this.xaRecoveryNodes = new ArrayList<String>();
} else {
this.xaRecoveryNodes = new ArrayList<String>(xaRecoveryNodes);
}
}
/**
* Returns the set of XAResourceRecovery implementation class names,
* each of which may have configuration data appended to it.
* The returned list is a copy. May return an empty list, will not return null.
*
* Default: empty list.
* Equivalent deprecated property prefix: com.arjuna.ats.jta.recovery.XAResourceRecovery
*
* @return the set of XAResourceRecovery implementations with their configuration data.
*/
public List<String> getXaResourceRecoveryClassNames()
{
synchronized(this)
{
return new ArrayList<String>(xaResourceRecoveryClassNames);
}
}
/**
* Sets the class names of the XAResourceRecovery implementations that will be used,
* each optionally including trailing configuration data.
* The provided list will be copied, not retained.
*
* @param xaResourceRecoveryClassNames the XAResourceRecovery implementation class names and configuration.
*/
public void setXaResourceRecoveryClassNames(List<String> xaResourceRecoveryClassNames)
{
synchronized(this)
{
if(xaResourceRecoveryClassNames == null)
{
this.xaResourceRecoveries = null;
this.xaResourceRecoveryClassNames = new ArrayList<String>();
}
else if(!xaResourceRecoveryClassNames.equals(this.xaResourceRecoveryClassNames))
{
this.xaResourceRecoveries = null;
this.xaResourceRecoveryClassNames = new ArrayList<String>(xaResourceRecoveryClassNames);
}
}
}
/**
* Returns the set of XAResourceRecovery instances.
* The returned list is a copy. May return an empty list, will not return null.
*
* If there is no pre-instantiated instance set and classloading or instantiation of one or more
* elements fails, this method will log an appropriate warning and return a non-null set with
* fewer elements.
*
* @return the set of XAResourceRecovery instances.
*/
public List<XAResourceRecovery> getXaResourceRecoveries()
{
synchronized(this)
{
if(xaResourceRecoveries == null) {
List<XAResourceRecovery> instances = ClassloadingUtility.loadAndInstantiateClassesWithInit(XAResourceRecovery.class, xaResourceRecoveryClassNames);
xaResourceRecoveries = instances;
}
return new ArrayList<XAResourceRecovery>(xaResourceRecoveries);
}
}
/**
* Sets the instances of XAResourceRecovery.
* The provided list will be copied, not retained.
*
* @param xaResourceRecoveries the set of XAResourceRecovery instances.
*/
public void setXaResourceRecoveries(List<XAResourceRecovery> xaResourceRecoveries)
{
synchronized(this)
{
if(xaResourceRecoveries == null)
{
this.xaResourceRecoveries = new ArrayList<XAResourceRecovery>();
this.xaResourceRecoveryClassNames = new ArrayList<String>();
}
else
{
this.xaResourceRecoveries = new ArrayList<XAResourceRecovery>(xaResourceRecoveries);
List<String> names = ClassloadingUtility.getNamesForClasses(this.xaResourceRecoveries);
this.xaResourceRecoveryClassNames = names;
}
}
}
/**
* Returns a list of names of classes that implement XAResourceOrphanFilter.
* The returned list is a copy. May return an empty list, will not return null.
*
* Default: empty list.
* Equivalent deprecated property prefix:
*
* @return a list of XAResourceOrphanFilter implementation class names.
*/
public List<String> getXaResourceOrphanFilterClassNames()
{
synchronized(this)
{
return new ArrayList<String>(xaResourceOrphanFilterClassNames);
}
}
/**
* Sets the class names of XAResourceOrphanFilter implementations.
* List elements should be names of classes that implement XAResourceOrphanFilter.
* The provided list will be copied, not retained.
*
* @param xaResourceOrphanFilterClassNames a list of XAResourceOrphanFilter implementation classes.
*/
public void setXaResourceOrphanFilterClassNames(List<String> xaResourceOrphanFilterClassNames)
{
synchronized(this)
{
if(xaResourceOrphanFilterClassNames == null)
{
this.xaResourceOrphanFilters = new ArrayList<XAResourceOrphanFilter>();
this.xaResourceOrphanFilterClassNames = new ArrayList<String>();
}
else if(!xaResourceOrphanFilterClassNames.equals(this.xaResourceOrphanFilterClassNames))
{
this.xaResourceOrphanFilters = null;
this.xaResourceOrphanFilterClassNames = new ArrayList<String>(xaResourceOrphanFilterClassNames);
}
}
}
/**
* Returns the set of XAResourceOrphanFilter instances.
* The returned list is a copy. May return an empty list, will not return null.
*
* If there is no pre-instantiated instance set and classloading or instantiation of one or more
* elements fails, this method will log an appropriate warning and return a non-null set with
* fewer elements.
*
* @return the set of XAResourceOrphanFilter instances.
*/
public List<XAResourceOrphanFilter> getXaResourceOrphanFilters()
{
synchronized(this)
{
if(xaResourceOrphanFilters == null) {
List<XAResourceOrphanFilter> instances = ClassloadingUtility.loadAndInstantiateClassesWithInit(XAResourceOrphanFilter.class, xaResourceOrphanFilterClassNames);
xaResourceOrphanFilters = instances;
}
return new ArrayList<XAResourceOrphanFilter>(xaResourceOrphanFilters);
}
}
/**
* Sets the instances of XAResourceOrphanFilter.
* The provided list will be copied, not retained.
*
* @param xaResourceOrphanFilters the set of XAResourceOrphanFilter instances.
*/
public void setXaResourceOrphanFilters(List<XAResourceOrphanFilter> xaResourceOrphanFilters)
{
synchronized(this)
{
if(xaResourceOrphanFilters == null)
{
this.xaResourceOrphanFilters = new ArrayList<XAResourceOrphanFilter>();
this.xaResourceOrphanFilterClassNames = new ArrayList<String>();
}
else
{
this.xaResourceOrphanFilters = new ArrayList<XAResourceOrphanFilter>(xaResourceOrphanFilters);
List<String> names = ClassloadingUtility.getNamesForClasses(this.xaResourceOrphanFilters);
this.xaResourceOrphanFilterClassNames = names;
}
}
}
/**
* Returns if connections associated to XAResources that fail during prepare should be cleaned up immediately.
* TODO move to JDBC module as it's only for our own connection manager?
*
* Default: false.
* Equivalent deprecated property: com.arjuna.ats.jta.xaRollbackOptimization
*
* @return true for cleanup during prepare, false for cleanup during phase two rollback.
*/
public boolean isXaRollbackOptimization()
{
return xaRollbackOptimization;
}
/**
* Sets if failed resources should be cleaned up during prepare or during phase two.
*
* @param xaRollbackOptimization true for immediate cleanup, false for phase two cleanup.
*/
public void setXaRollbackOptimization(boolean xaRollbackOptimization)
{
this.xaRollbackOptimization = xaRollbackOptimization;
}
/**
* Returns if XAResources that can't be recovered should be assumed to have completed.
* WARNING: enabling this property is not recommended and may cause inconsistency if
* your recovery configuration is incorrect or resource managers are not available.
*
* Default: false.
* Equivalent deprecated property: com.arjuna.ats.jta.xaAssumeRecoveryComplete
*
* @return true for assumed completion, false for no such assumption.
*/
public boolean isXaAssumeRecoveryComplete()
{
return xaAssumeRecoveryComplete;
}
/**
* Sets if XAResources that can't be recovered should be assumed to have completed.
*
* @param xaAssumeRecoveryComplete true to enable completion assumption, false to disable.
*/
public void setXaAssumeRecoveryComplete(boolean xaAssumeRecoveryComplete)
{
this.xaAssumeRecoveryComplete = xaAssumeRecoveryComplete;
}
/**
* Returns the JNDI bind name for the implementation of UserTransaction.
*
* Default: "java:/UserTransaction"
* Equivalent deprecated property: com.arjuna.ats.jta.utils.UTJNDIContext
*
* @return the JNDI bind location for the UserTransaction interface.
*/
public String getUserTransactionJNDIContext()
{
return userTransactionJNDIContext;
}
/**
* Sets the JNDI bind name for the implementation of UserTransaction.
*
* @param userTransactionJNDIContext the JNDI bind location for the UserTransaction interface.
*/
public void setUserTransactionJNDIContext(String userTransactionJNDIContext)
{
this.userTransactionJNDIContext = userTransactionJNDIContext;
}
/**
* Returns the JNDI bind name for the implementation of TransactionManager.
*
* Default: "java:/TransactionManager"
* Equivalent deprecated property: com.arjuna.ats.jta.utils.TMJNDIContext
*
* @return the JNDI bind location for the TransactionManager interface.
*/
public String getTransactionManagerJNDIContext()
{
return transactionManagerJNDIContext;
}
/**
* Sets the JNDI bind name for the implementation of TransactionManager.
*
* @param transactionManagerJNDIContext the JNDI bind location for the TransactionManager interface.
*/
public void setTransactionManagerJNDIContext(String transactionManagerJNDIContext)
{
this.transactionManagerJNDIContext = transactionManagerJNDIContext;
}
/**
* Returns the JNDI bind name for the implementation of TransactionSynchronizationRegistry.
*
* Default: "java:/TransactionSynchronizationRegistry"
* Equivalent deprecated property: com.arjuna.ats.jta.utils.TSRJNDIContext
*
* @return the JNDI bind location for the TransactionSynchronizationRegistry interface.
*/
public String getTransactionSynchronizationRegistryJNDIContext()
{
return transactionSynchronizationRegistryJNDIContext;
}
/**
* Sets tje JNDI bind name for the implementation of TransactionSynchronizationRegistry.
*
* @param transactionSynchronizationRegistryJNDIContext the JNDI bind location for the TransactionSynchronizationRegistry implementation.
*/
public void setTransactionSynchronizationRegistryJNDIContext(String transactionSynchronizationRegistryJNDIContext)
{
this.transactionSynchronizationRegistryJNDIContext = transactionSynchronizationRegistryJNDIContext;
}
/**
* Returns the set of XAResourceMap implementation class names used to configure XAException handling.
* The returned list is a copy. May return an empty list, will not return null.
*
* Default: empty list.
* Equivalent deprecated property prefix: com.arjuna.ats.jta.xaErrorHandler
*
* @return a set of class names, each an implementation of XAResourceMap.
*/
public List<String> getXaResourceMapClassNames()
{
synchronized(this)
{
return new ArrayList<String>(xaResourceMapClassNames);
}
}
/**
* Sets the names of the XAResourceMap classes used for XAException handling.
* The provided list will be copied, not retained.
*
* @param xaResourceMapClassNames a set of names of classes, each implementing XAResourceMap.
*/
public void setXaResourceMapClassNames(List<String> xaResourceMapClassNames)
{
synchronized(this)
{
if(xaResourceMapClassNames == null)
{
this.xaResourceMaps = null;
this.xaResourceMapClassNames = new ArrayList<String>();
}
else if(!xaResourceMapClassNames.equals(this.xaResourceMapClassNames))
{
this.xaResourceMaps = null;
this.xaResourceMapClassNames = new ArrayList<String>(xaResourceMapClassNames);
}
}
}
/**
* Returns the set of XAResourceMap instances.
* The returned list is a copy. May return an empty list, will not return null.
*
* If there is no pre-instantiated instance set and classloading or instantiation of one or more
* elements fails, this method will log an appropriate warning and return a non-null set with
* fewer elements.
*
* @return the set of XAResourceMap instances.
*/
public List<XAResourceMap> getXaResourceMaps()
{
synchronized(this)
{
if(xaResourceMaps == null) {
List<XAResourceMap> instances = ClassloadingUtility.loadAndInstantiateClassesWithInit(XAResourceMap.class, xaResourceMapClassNames);
xaResourceMaps = instances;
}
return new ArrayList<XAResourceMap>(xaResourceMaps);
}
}
/**
* Sets the instances of XAResourceMap.
* The provided list will be copied, not retained.
*
* @param xaResourceMaps the set of XAResourceMap instances.
*/
public void setXaResourceMaps(List<XAResourceMap> xaResourceMaps)
{
synchronized(this)
{
if(xaResourceMaps == null)
{
this.xaResourceMaps = new ArrayList<XAResourceMap>();
this.xaResourceMapClassNames = new ArrayList<String>();
}
else
{
this.xaResourceMaps = new ArrayList<XAResourceMap>(xaResourceMaps);
List<String> names = ClassloadingUtility.getNamesForClasses(this.xaResourceMaps);
this.xaResourceMapClassNames = names;
}
}
}
/**
* Returns if the transaction timeout is passed on to the enlisted XAResources.
*
* Default: true.
* Equivalent deprecated property: com.arjuna.ats.jta.xaTransactionTimeoutEnabled
*
* @return true to pass transaction timeout configuration on to the XAResources, false to skip setting resource timeout.
*/
public boolean isXaTransactionTimeoutEnabled()
{
return xaTransactionTimeoutEnabled;
}
/**
* Sets if the transaction timeout should be passed to the enlisted XAResource or not.
*
* @param xaTransactionTimeoutEnabled true to enable setting XAResource timeouts, false to disable.
*/
public void setXaTransactionTimeoutEnabled(boolean xaTransactionTimeoutEnabled)
{
this.xaTransactionTimeoutEnabled = xaTransactionTimeoutEnabled;
}
/**
* Returns the class name of the marker interface used to indicate a LastResource.
*
* Default: null.
* Equivalent deprecated property: com.arjuna.ats.jta.lastResourceOptimisationInterfaceClassName
*
* @return the class name of the market interface for LastResource handling.
*/
public String getLastResourceOptimisationInterfaceClassName()
{
return lastResourceOptimisationInterfaceClassName;
}
/**
* Sets the class name of the marker interface used to indicate a LastResource.
*
* @param lastResourceOptimisationInterfaceClassName the class name of the marker interface.
*/
public void setLastResourceOptimisationInterfaceClassName(String lastResourceOptimisationInterfaceClassName)
{
synchronized(this)
{
if(lastResourceOptimisationInterfaceClassName == null)
{
this.lastResourceOptimisationInterface = null;
}
else if(!lastResourceOptimisationInterfaceClassName.equals(this.lastResourceOptimisationInterfaceClassName))
{
this.lastResourceOptimisationInterface = null;
}
this.lastResourceOptimisationInterfaceClassName = lastResourceOptimisationInterfaceClassName;
}
}
/**
* Returns the Class representing the marker interface for LastResource.
*
* If there is no Class set and loading fails, this method will log an appropriate warning
* and return null, not throw an exception.
*
* @return the LastResource marker interface.
*/
public Class getLastResourceOptimisationInterface()
{
if(lastResourceOptimisationInterface == null && lastResourceOptimisationInterfaceClassName != null) {
synchronized(this) {
if(lastResourceOptimisationInterface == null && lastResourceOptimisationInterfaceClassName != null) {
lastResourceOptimisationInterface = ClassloadingUtility.loadClass(lastResourceOptimisationInterfaceClassName);
}
}
}
return lastResourceOptimisationInterface;
}
/**
* Sets a Class to use as the marker interface for LastResource
*
* @param clazz a marker interface Class, or null.
*/
public void setLastResourceOptimisationInterface(Class clazz)
{
synchronized(this)
{
Class oldClazz = this.lastResourceOptimisationInterface;
lastResourceOptimisationInterface = clazz;
if(clazz == null)
{
this.lastResourceOptimisationInterfaceClassName = null;
}
else if(clazz != oldClazz)
{
String name = ClassloadingUtility.getNameForClass(clazz);
this.lastResourceOptimisationInterfaceClassName = name;
}
}
}
/**
* Returns the class name of the XAResourceRecordWrappingPlugin implementation.
*
* Default: null
*
* @return the name of the class implementing XAResourceRecordWrappingPlugin.
*/
public String getXaResourceRecordWrappingPluginClassName()
{
return xaResourceRecordWrappingPluginClassName;
}
/**
* Sets the class name of the XAResourceRecordWrappingPlugin implementation.
*
* @param xaResourceRecordWrappingPluginClassName the name of a class which implements XAResourceRecordWrappingPlugin.
*/
public void setXaResourceRecordWrappingPluginClassName(String xaResourceRecordWrappingPluginClassName)
{
synchronized(this)
{
if(xaResourceRecordWrappingPluginClassName == null)
{
this.xaResourceRecordWrappingPlugin = null;
}
else if(!xaResourceRecordWrappingPluginClassName.equals(this.xaResourceRecordWrappingPluginClassName))
{
this.xaResourceRecordWrappingPlugin = null;
}
this.xaResourceRecordWrappingPluginClassName = xaResourceRecordWrappingPluginClassName;
}
}
/**
* Returns an instance of a class implementing XAResourceRecordWrappingPlugin.
*
* If there is no pre-instantiated instance set and classloading or instantiation fails,
* this method will log an appropriate warning and return null, not throw an exception.
*
* @return a XAResourceRecordWrappingPlugin implementation instance, or null.
*/
public XAResourceRecordWrappingPlugin getXAResourceRecordWrappingPlugin()
{
if(xaResourceRecordWrappingPlugin == null && xaResourceRecordWrappingPluginClassName != null)
{
synchronized(this) {
if(xaResourceRecordWrappingPlugin == null && xaResourceRecordWrappingPluginClassName != null) {
XAResourceRecordWrappingPlugin instance = ClassloadingUtility.loadAndInstantiateClass(XAResourceRecordWrappingPlugin.class, xaResourceRecordWrappingPluginClassName, null);
xaResourceRecordWrappingPlugin = instance;
}
}
}
return xaResourceRecordWrappingPlugin;
}
/**
* Sets the instance of XAResourceRecordWrappingPlugin
*
* @param instance an Object that implements XAResourceRecordWrappingPlugin, or null.
*/
public void setXAResourceRecordWrappingPlugin(XAResourceRecordWrappingPlugin instance)
{
synchronized(this)
{
XAResourceRecordWrappingPlugin oldInstance = this.xaResourceRecordWrappingPlugin;
xaResourceRecordWrappingPlugin = instance;
if(instance == null)
{
this.xaResourceRecordWrappingPluginClassName = null;
}
else if(instance != oldInstance)
{
String name = ClassloadingUtility.getNameForClass(instance);
this.xaResourceRecordWrappingPluginClassName = name;
}
}
}
/**
* Returns maximum size of a thread pool, used to execute asynchronous commits.
*
* @return maximum size of a thread pool, used to execute asynchronous commits.
*/
public int getAsyncCommitPoolSize() {
return asyncCommitPoolSize;
}
/**
* Sets maximum size of a thread pool, used to execute asynchronous commits.
*
* @param asyncCommitPoolSize maximum size of a thread pool, used to execute asynchronous commits.
*/
public void setAsyncCommitPoolSize(int asyncCommitPoolSize) {
this.asyncCommitPoolSize = asyncCommitPoolSize;
}
public int getOrphanSafetyInterval() {
return orphanSafetyInterval;