-
1. Re: What are Best Practice Recommendations for Property File Configuration?
rcd Oct 3, 2014 9:32 PM (in response to firepod)In my opinion, configuration should NOT be inside the deployment because, as you noted, you would have to re-assemble it for each environment. That's practically begging for someone to make a mistake.
For our projects, we usually define configuration in two places because we do a lot of clustered applications. Most configuration (anything that should be uniform across all nodes in the cluster) goes in a database table. Anything that can't be in the database (because it needs to be accessed too early during deployment and we may not have a database connection yet) or shouldn't be in the database (because it's specific to that node) goes into the WildFly configuration file in the <system-properties> section.
Then, as part of our build process, we construct a full WildFly instance, add a custom config file plus the deployment and anything else we need (like extra modules), and zip the whole thing up. In the custom config file, we use system property interpolation with reasonable defaults to set database URLs, bind addresses, ports, and anything else that needs to be configured for WildFly itself. So when we need to deploy a build somewhere, we just grab the zip, decompress it, open the config file, and just paste in whatever the appropriate system properties are. It's a simple and uniform process that makes installing or upgrading any environment very easy.
-
2. Re: What are Best Practice Recommendations for Property File Configuration?
firepod Oct 13, 2014 12:09 AM (in response to rcd)Many thanks for the reply.
Do you happen to know where in the Wildfly docs I can read more about system property interpolation? I checked out the docs and Google it, but didn't find anything.
-
3. Re: What are Best Practice Recommendations for Property File Configuration?
rcd Oct 15, 2014 3:59 PM (in response to firepod)I'm not sure if it's actually documented anywhere. It's pretty straight-forward to use though. For any situation where you want to use interpolation, instead of putting
myValue
you would put
${myProperty}
and then this somewhere (WildFly puts it between </extensions> and <management> when it rewrites the config file)
<system-properties>
<property name="myProperty" value="myValue"/>
</system-properties>
System property interpolation can also be specified in the form
${myProperty:defaultValue}
which will cause defaultValue to be used if myProperty is not set.
It should also be noted that interpolation may not work everywhere. The WildFly devs have made an effort to support it everywhere, but there may still be some seldom-used areas they missed. If you run into such an area, file a bug report.