@@ -67,7 +67,11 @@ public XMLConfigBuilder(Reader reader, String environment) {
67
67
}
68
68
69
69
public XMLConfigBuilder (Reader reader , String environment , Properties props ) {
70
- this (new XPathParser (reader , true , props , new XMLMapperEntityResolver ()), environment , props );
70
+ this (Configuration .class , reader , environment , props );
71
+ }
72
+
73
+ public XMLConfigBuilder (Class <? extends Configuration > configClass , Reader reader , String environment , Properties props ) {
74
+ this (configClass , new XPathParser (reader , true , props , new XMLMapperEntityResolver ()), environment , props );
71
75
}
72
76
73
77
public XMLConfigBuilder (InputStream inputStream ) {
@@ -79,11 +83,15 @@ public XMLConfigBuilder(InputStream inputStream, String environment) {
79
83
}
80
84
81
85
public XMLConfigBuilder (InputStream inputStream , String environment , Properties props ) {
82
- this (new XPathParser (inputStream , true , props , new XMLMapperEntityResolver ()), environment , props );
86
+ this (Configuration .class , inputStream , environment , props );
87
+ }
88
+
89
+ public XMLConfigBuilder (Class <? extends Configuration > configClass , InputStream inputStream , String environment , Properties props ) {
90
+ this (configClass , new XPathParser (inputStream , true , props , new XMLMapperEntityResolver ()), environment , props );
83
91
}
84
92
85
- private XMLConfigBuilder (XPathParser parser , String environment , Properties props ) {
86
- super (new Configuration ( ));
93
+ private XMLConfigBuilder (Class <? extends Configuration > configClass , XPathParser parser , String environment , Properties props ) {
94
+ super (newConfig ( configClass ));
87
95
ErrorContext .instance ().resource ("SQL Mapper Configuration" );
88
96
this .configuration .setVariables (props );
89
97
this .parsed = false ;
@@ -406,4 +414,12 @@ private boolean isSpecifiedEnvironment(String id) {
406
414
return environment .equals (id );
407
415
}
408
416
417
+ private static Configuration newConfig (Class <? extends Configuration > configClass ) {
418
+ try {
419
+ return configClass .getDeclaredConstructor ().newInstance ();
420
+ } catch (Exception ex ) {
421
+ throw new BuilderException ("Failed to create a new Configuration instance." , ex );
422
+ }
423
+ }
424
+
409
425
}
0 commit comments