Good catch. Still does not work.... here is the complete code for the class;
Code:
package com.cportfolios.map.web;
import java.util.Locale;
import javax.servlet.http.HttpSession;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
import com.cportfolios.map.domain.util.UserPreference;
public class WebManager
{
private static WebManager instance;
private Log log = LogFactory.getLog(WebManager.class);
private ReloadableResourceBundleMessageSource messageSource;
/**
* Default constructor
*/
public WebManager()
{
super();
}
/**
* Return the instance of this class
*
* @return - The one and only instance of WebManager
*/
public static WebManager instance()
{
if(instance == null)
{
synchronized(WebManager.class)
{
if(instance == null)
{
instance = new WebManager();
}
}
}
return instance;
}
/**
* @return Returns the messageSource.
*/
public ReloadableResourceBundleMessageSource getMessageSource()
{
return messageSource;
}
/**
* @param messageSource The messageSource to set.
*/
public void setMessageSource(ReloadableResourceBundleMessageSource messageSource)
{
this.messageSource = messageSource;
}
public UserPreference getUserPreference(HttpSession session)
{
UserPreference up = new UserPreference();
up = ( UserPreference ) session.getAttribute(getMessage("USER_PREF"));
return up;
}
private String getMessage(String key)
{
String message="";
if(messageSource==null)
{
log.error("The messageSource is null");
}
else
{
message = messageSource.getMessage(key, null, Locale.ENGLISH);
log.info("RETURNING MESSAGE: " + message);
}
return message;
}
}
The MessageSource wiring:
Code:
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basenames">
<list>
<value>classpath:messages</value>
<value>classpath:cptheme</value>
<value>classpath:theme</value>
</list>
</property>
</bean>
And the WebManager wired with the MessageSource:
Code:
<bean id="webManager">
<property name="target">
<bean class="com.cportfolios.map.web.WebManager">
<property name="messageSource" ref="messageSource"/>
</bean>
</property>
</bean>
Thanks again.
-Derrick