44
44
*/
45
45
public abstract class AbstractEngineConfigurator implements ProcessEngineConfigurator {
46
46
47
+ protected boolean enableMybatisXmlMappingValidation ;
48
+
47
49
@ Override
48
50
public void beforeInit (ProcessEngineConfigurationImpl processEngineConfiguration ) {
49
51
registerCustomDeployers (processEngineConfiguration );
@@ -93,7 +95,7 @@ protected void registerCustomMybatisMappings(ProcessEngineConfigurationImpl proc
93
95
if (cfgPath != null ) {
94
96
Set <String > resources = new HashSet <>();
95
97
try (InputStream inputStream = this .getClass ().getClassLoader ().getResourceAsStream (cfgPath )) {
96
- DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory . newInstance ();
98
+ DocumentBuilderFactory docBuilderFactory = createDocumentBuilderFactory ();
97
99
DocumentBuilder docBuilder = docBuilderFactory .newDocumentBuilder ();
98
100
Document document = docBuilder .parse (inputStream );
99
101
NodeList nodeList = document .getElementsByTagName ("mapper" );
@@ -115,6 +117,18 @@ protected void registerCustomMybatisMappings(ProcessEngineConfigurationImpl proc
115
117
}
116
118
}
117
119
120
+ protected DocumentBuilderFactory createDocumentBuilderFactory () throws ParserConfigurationException {
121
+ DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory .newInstance ();
122
+ if (!enableMybatisXmlMappingValidation ) {
123
+ docBuilderFactory .setValidating (false );
124
+ docBuilderFactory .setNamespaceAware (false );
125
+ docBuilderFactory .setExpandEntityReferences (false );
126
+ docBuilderFactory .setFeature ("http://apache.org/xml/features/nonvalidating/load-external-dtd" , false );
127
+ docBuilderFactory .setFeature ("http://apache.org/xml/features/nonvalidating/load-dtd-grammar" , false );
128
+ }
129
+ return docBuilderFactory ;
130
+ }
131
+
118
132
/**
119
133
* Override when custom type aliases are needed.
120
134
*/
@@ -203,8 +217,16 @@ protected void initClock(ProcessEngineConfigurationImpl processEngineConfigurati
203
217
targetEngineConfiguration .setClock (processEngineConfiguration .getClock ());
204
218
}
205
219
206
- protected abstract List <Class <? extends Entity >> getEntityInsertionOrder () ;
220
+ protected abstract List <Class <? extends Entity >> getEntityInsertionOrder ();
207
221
208
- protected abstract List <Class <? extends Entity >> getEntityDeletionOrder () ;
222
+ protected abstract List <Class <? extends Entity >> getEntityDeletionOrder ();
223
+
224
+ public boolean isEnableMybatisXmlMappingValidation () {
225
+ return enableMybatisXmlMappingValidation ;
226
+ }
227
+
228
+ public void setEnableMybatisXmlMappingValidation (boolean enableMybatisXmlMappingValidation ) {
229
+ this .enableMybatisXmlMappingValidation = enableMybatisXmlMappingValidation ;
230
+ }
209
231
210
232
}
0 commit comments