I want to be able to load properties from a yaml file and then set a property dynamically everytime the application starts up. The active profile determines the source.system properties below, different per profile as is the back-end.url
yaml looks like this:
source:
system:
google:
uri: https://www.google.com
user: testUser
value: {dynamically_set_property}
source:
system:
facebook:
uri: https://www.facebook.com
user: testUser
value: {dynamically_set_property}
back-end:
url: /version1/
There is some UTIL class that i have written which takes in the properties above and then uses them to set the dynamic property.
@ConfigurationProperties(prefix=source.system)
public class MyUtil {
private Map<String, SourceSystem> sourceSystems;
//doSomething with the source system
public void setDynamicProperty(String value) {
SourceSystem source = sourceSystems.get(value);
//check back-end.url and set source.value
}
}
So on startup when the application runs, I want to set "dynamically_set_property" but to do that I need to have access to the back-end.url property. I have looked at DynamicPropertyResolver but that doesn't give me access to the "back-end.url" property in the static method implementation.
Is implementing EnvironmentAware the only other option? Ideally what I would like is some configuration bean loading before any spring core, 3rd party or other annotated beans within my application and it would run some pre-processing so set the dynamically_set_property.