|
15 | 15 |
|
16 | 16 | import org.fugerit.java.core.cfg.ConfigException; |
17 | 17 | import org.fugerit.java.core.cfg.helpers.XMLConfigurableObject; |
| 18 | +import org.fugerit.java.core.cfg.provider.ConfigProvider; |
| 19 | +import org.fugerit.java.core.cfg.provider.ConfigProviderFacade; |
18 | 20 | import org.fugerit.java.core.io.helper.StreamHelper; |
19 | 21 | import org.fugerit.java.core.lang.helpers.BooleanUtils; |
20 | 22 | import org.fugerit.java.core.lang.helpers.ClassHelper; |
@@ -94,6 +96,8 @@ public class GenericListCatalogConfig<T> extends XMLConfigurableObject { |
94 | 96 |
|
95 | 97 | private Properties generalProps; |
96 | 98 |
|
| 99 | + private ConfigProvider configProvider; |
| 100 | + |
97 | 101 | /** |
98 | 102 | * Creates a new DataListCatalogConfig wth default configuration. |
99 | 103 | */ |
@@ -179,6 +183,11 @@ public GenericListCatalogConfig( String attTagDataList, String attTagData ) { |
179 | 183 | * Bean population mode |
180 | 184 | */ |
181 | 185 | public static final String ATT_BEAN_MODE = "bean-mode"; |
| 186 | + |
| 187 | + /** |
| 188 | + * Name of the config provider to use |
| 189 | + */ |
| 190 | + public static final String ATT_CONFIG_PROVIDER_NAME = "config-provider-name"; |
182 | 191 |
|
183 | 192 | /** |
184 | 193 | * Default, bean population mode (by default read only attributes) |
@@ -284,6 +293,9 @@ public void configure(Element tag) throws ConfigException { |
284 | 293 | DOMUtils.attributesToProperties( tag, this.getGeneralProps() ); |
285 | 294 | logger.info( "general props : "+this.getGeneralProps() ); |
286 | 295 |
|
| 296 | + String confgiProviderName = this.getGeneralProps().getProperty( ATT_CONFIG_PROVIDER_NAME ); |
| 297 | + this.configProvider = ConfigProviderFacade.getInstance().getProviderWithDefault( confgiProviderName , this ); |
| 298 | + |
287 | 299 | String tryXsdValidation = this.getGeneralProps().getProperty( ATT_TRY_XSD_VALIDATION, ATT_TRY_XSD_VALIDATION_DEFAULT ); |
288 | 300 | if ( BooleanUtils.isTrue( tryXsdValidation ) ) { |
289 | 301 | if ( this.hasDefinition() ) { |
@@ -414,8 +426,7 @@ public void configure(Element tag) throws ConfigException { |
414 | 426 | String path = currentModule.getAttribute( ATT_TAG_MODULE_CONF_PATH ); |
415 | 427 | String unsafe = currentModule.getAttribute( ATT_TAG_MODULE_CONF_UNSAFE ); |
416 | 428 | logger.info( "Loading module id="+id+" mode="+mode+" path="+path ); |
417 | | - try { |
418 | | - InputStream is = StreamHelper.resolveStreamByMode( mode , path ); |
| 429 | + try ( InputStream is = this.getConfigProvider().readConfiguration( mode, path) ) { |
419 | 430 | Document currentModuleDoc = DOMIO.loadDOMDoc( is ); |
420 | 431 | Element rootTag = currentModuleDoc.getDocumentElement(); |
421 | 432 | this.configure( rootTag ); |
@@ -479,6 +490,10 @@ public void setSchemaId(String schemaId) { |
479 | 490 | this.schemaId = schemaId; |
480 | 491 | } |
481 | 492 |
|
| 493 | + protected ConfigProvider getConfigProvider() { |
| 494 | + return this.configProvider; |
| 495 | + } |
| 496 | + |
482 | 497 | /** |
483 | 498 | * Check if the catalog config has a schema definition |
484 | 499 | * |
|
0 commit comments