...
Code Block |
---|
<bean id="org.sakaiproject.sitemanagement.configuration.api.SitePagesAndTools" class="org.sakaiproject.sitemanagement.configuration.impl.SitePagesAndToolsImpl"> <property name="pagesAndTools"> <map> <entry> <key><value>Home</value></key> <list> <value>sakai.iframe.site</value> <value>sakai.synoptic.chat</value> <value>sakai.synoptic.announcement</value> </list> </entry> <entry> <key><value>Announcements</value></key> <list> <value>sakai.announcements</value> </list> </entry> <entry> <key><value>Assignments</value></key> <list> <value>sakai.assignment.grades</value> </list> </entry> <entry> <key><value>Chat Room</value></key> <list> <value>sakai.chat</value> </list> </entry> <entry> <key><value>Drop Box</value></key> <list> <value>sakai.dropbox</value> </list> </entry> <entry> <key><value>Email Archive</value></key> <list> <value>sakai.mailbox</value> </list> </entry> <entry> <key><value>Gradebook</value></key> <list> <value>sakai.gradebook.tool</value> </list> </entry> <entry> <key><value>Message Center</value></key> <list> <value>sakai.messagecenter</value> </list> </entry> <entry> <key><value>Modules</value></key> <list> <value>sakai.melete</value> </list> </entry> <entry> <key><value>Resources</value></key> <list> <value>sakai.resources</value> </list> </entry> <entry> <key><value>Schedule</value></key> <list> <value>sakai.schedule</value> </list> </entry> <entry> <key><value>Site Info</value></key> <list> <value>sakai.siteinfo</value> </list> </entry> <entry> <key><value>Support & Training</value></key> <list> <value>sakai.iframe</value> </list> </entry> <entry> <key><value>Syllabus</value></key> <list> <value>sakai.syllabus</value> </list> </entry> <entry> <key><value>Tests & Quizzes</value></key> <list> <value>sakai.samigo</value> </list> </entry> <entry> <key><value>Wiki</value></key> <list> <value>sakai.rwiki</value> </list> </entry> </map> </property> </bean> |
Now we configure the propertyThe SitePagesAndToolsImpl class looks like this:
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;
}
}
|
Now we define the property key:
Code Block |
---|
package org.sakaiproject.component.configuration.properties.api;
public interface ConfigurationProperties {
// Site Management
public static final String SITE_MANAGEMENT_PAGES_AND_TOOLS = "org.sakaiproject.sitemanagement.service.CourseService.SitePagesAndTools";
// ...
|
Now, modify the component-impl's components.xml file.
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); } } } |