...
Code Block |
---|
package org.sakaiproject.sitemanagement.configuration.impl;
// imports ...
public class SitePagesAndToolsImpl implements SitePagesAndTools {
private Map pagesAndTools = null;
// DI
public void setPagesAndTools(Map pagesAndTools) {
this.pagesAndTools = pagesAndTools;
}
public Map getPagesAndTools() {
return pagesAndTools;
}
}
|
...
Code Block |
---|
<property name="dynamicSakaiProperties">
<map>
<entry key="org.sakaiproject.sitemanagement.service.CourseService.SitePagesAndTools">
<ref bean="org.sakaiproject.sitemanagement.configuration.api.SitePagesAndTools" />
</entry>
</map>
</property>
|
We use the SitePagesAndTools property in our CourseService class:
Code Block |
---|
public class CourseServiceImpl
extends AbstractSiteService
implements CourseService, ConfigurationNotificationListener, ConfigurationProperties {
// ...
private SitePagesAndTools sitePagesAndTools;
private DynamicServerConfigurationService dynamicServerConfigurationService;
// Spring DSCS injection
public void setDynamicServerConfigurationService(DynamicServerConfigurationService dynamicServerConfigurationService) {
this.dynamicServerConfigurationService = dynamicServerConfigurationService;
}
// Spring Bean Init
public void init() {
dynamicServerConfigurationService.addNotificationListener(this, SITE_MANAGEMENT_PAGES_AND_TOOLS);
try {
sitePagesAndTools = (SitePagesAndTools) dynamicServerConfigurationService.getDynamicObject(SITE_MANAGEMENT_PAGES_AND_TOOLS);
} 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(SITE_MANAGEMENT_PAGES_AND_TOOLS.equals(configurationItemKey)) {
sitePagesAndTools = (SitePagesAndTools) dynamicServerConfigurationService.getDynamicObject(SITE_MANAGEMENT_PAGES_AND_TOOLS);
}
} 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);
}
}
}
|