Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

Description

The Dynamic Server Configuration Service (DSCS) is built around the Basic Configuration Service. The DSCS provides the environment to change specific Sakai properties during run-time using JMX.

Usage

  • The target class that wants to add a dynamically configurable property needs to implement "ConfigurationNotificationListener" and "ConfigurationProperties"
    • e.g.
      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.
      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");
      		}
      	}
      	
      	// Implementing ConfigurationNotificationListener API: handleNotification
      	public void handleNotification(String configurationItemKey) {
      		
      		try {
      
      			if(PERSON_FIRST_NAME.equals(configurationItemKey)) {
      				firstName = dynamicServerConfigurationService.getDynamicString(PERSON_FIRST_NAME);
      			}
      
      		} catch (ConfigurationObjectNotFound e) {
      			LOG.error("Was not able to find configuration property for key = " + configurationItemKey);
      		} catch (InvalidConfigurationKey e) {
      			LOG.error("Provided invalid configuration key = " + configurationItemKey);
      		}
      	}	
      
  • No labels