Index: lams_common/src/java/org/lamsfoundation/lams/commonContext.xml =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/commonContext.xml,v diff -u -r1.11 -r1.12 --- lams_common/src/java/org/lamsfoundation/lams/commonContext.xml 8 Mar 2006 23:56:10 -0000 1.11 +++ lams_common/src/java/org/lamsfoundation/lams/commonContext.xml 27 Mar 2006 03:27:25 -0000 1.12 @@ -139,6 +139,16 @@ + + + + + + + + + + Index: lams_common/src/java/org/lamsfoundation/lams/util/ILoadedMessageSourceService.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/util/ILoadedMessageSourceService.java,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_common/src/java/org/lamsfoundation/lams/util/ILoadedMessageSourceService.java 27 Mar 2006 03:27:43 -0000 1.1 @@ -0,0 +1,15 @@ +package org.lamsfoundation.lams.util; + +import org.springframework.context.MessageSource; + + +public interface ILoadedMessageSourceService { + + /** Get the MessageSource for the specified message file. + * + * @param messageFilename Mandatory + * @return Null if messageFilename is null, otherwise a MessageSource (even if the bundle cannot be found) + */ + public abstract MessageSource getMessageService(String messageFilename); + +} \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/util/LoadedMessageSourceService.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/util/LoadedMessageSourceService.java,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_common/src/java/org/lamsfoundation/lams/util/LoadedMessageSourceService.java 27 Mar 2006 03:27:43 -0000 1.1 @@ -0,0 +1,45 @@ +package org.lamsfoundation.lams.util; + + +import java.util.HashMap; + +import org.springframework.beans.BeansException; +import org.springframework.beans.factory.BeanFactory; +import org.springframework.beans.factory.BeanFactoryAware; +import org.springframework.context.MessageSource; +import org.springframework.context.support.ResourceBundleMessageSource; + +/** + * Access a message service related to a programatically loaded message file. + * Authoring uses this to access the message files for tools and activities. + */ +public class LoadedMessageSourceService implements ILoadedMessageSourceService, BeanFactoryAware { + + private static final String LOADED_MESSAGE_SOURCE_BEAN = "loadedMessageSource"; + private HashMap messageServices = new HashMap(); + private BeanFactory beanFactory = null; + + /* (non-Javadoc) + * @see org.lamsfoundation.lams.authoring.service.ILoadMessageService#getMessageService(java.lang.String) + */ + public MessageSource getMessageService(String messageFilename) { + if ( messageFilename != null ) { + MessageSource ms = messageServices.get(messageFilename); + if ( ms == null ) { + ResourceBundleMessageSource rbms = (ResourceBundleMessageSource) beanFactory.getBean(LOADED_MESSAGE_SOURCE_BEAN); + rbms.setBasename(messageFilename); + messageServices.put(messageFilename,rbms); + ms = rbms; + } + return ms; + } else { + return null; + } + } + + /* **** Method for BeanFactoryAware interface *****************/ + public void setBeanFactory(BeanFactory beanFactory) throws BeansException { + this.beanFactory = beanFactory; + } + +}