Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • 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 { ... }
      
  • 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");
      		}
      	}