constretto / constretto-core

Constretto is a versatile configuration toolkit for the JVM implemented in Java
https://github.com/constretto
Other
65 stars 20 forks source link

Having many .properties files to choose from - Changing spring loaded config #65

Open StigLau opened 7 years ago

StigLau commented 7 years ago

The main problem with Constretto its too damn addictive and works too well... Kudos!
Our secondary problem is a question of best practice: Can we change the Constretto config / append it, after its initial setup? We set up Constretto via Spring, and some .properties files are not known until runtime of the app. However, I cannot figure how to accomplish changing the config in either constretto or spring, as the constretto wiring is masked by Spring. An example is that I will want to run my constretto-configured application against several database tables. The app can be started anew, having all the diff'ing config contained in separate a .properties file per table. However, since the loading of the .configuration files is locked inside a spring.xml config, they cannot be changed. I don't like the alternatives I've come up with; sym-links for the .properties or feeding ClassPathXmlApplicationContext a spring-xml with the config-du-jour. What would you recommend?

StigLau commented 7 years ago

In short; this is what I'm trying to do:

<constretto:configuration>
  <constretto:stores>
    <constretto:properties-store>
      <constretto:resource location="classpath:myproperties/hardwired.properties"/>
      <constretto:resource location="file:./override.properties"/>
      <constretto:resource location="${config-du-jour}"/>
    </constretto:properties-store>
  </constretto:stores>
</constretto:configuration>

Excerpt from spring config.