...
- The target class that wants to add a dynamically configurable property needs to implement "ConfigurationNotificationListener" and "ConfigurationProperties"
- e.g.
Code Block public class PersonImpl implements ConfigurationNotificationListener, ConfigurationProperties { ... }
- e.g.
- The class needs to get the initial property value either at construction time or during a Spring init() method invocation
- e.g.
Code Block public class PersonImpl implements ConfigurationNotificationListener, ConfigurationProperties { // ... private String firstName; private DynamicServerConfigurationService dynamicServerConfigurationService; // ... // Spring DSCS injection public void setDynamicServerConfigurationService(DynamicServerConfigurationService dynamicServerConfigurationService) { this.dynamicServerConfigurationService = dynamicServerConfigurationService; } // Spring init method public void init() { // Configuration Service dynamicServerConfigurationService.addNotificationListener(this, PERSON_FIRST_NAME); try { firstName = dynamicServerConfigurationService.getDynamicString(PERSON_FIRST_NAME); } catch (ConfigurationObjectNotFound e) { LOG.error("Was not able to find configuration property"); } catch (InvalidConfigurationKey e) { LOG.error("Provided invalid configuration key"); } }
- e.g.