Hi again,
To whom it may concern...
This problem has now been solved.
The solution was to create a MessageResourceFactory that extends MessageResourcesFactory and define it in struts-config.xml.
struts.xml:
<message-resources
parameter="MessageResources"
factory="my.package.MyMessageResourceFactory"
null="false" />
MyMessageResourceFactory:
public class MyMessageResourceFactory extends MessageResourcesFactory
{
public MessageResources createResources(
String config)
{
return new MyMessageResources(this, config, this.returnNull);
}
}
MyMessageResources:
public class MyMessageResources extends MessageResources
{
public MyMessageResources(MessageResourcesFactory factory, String config, boolean returnNull)
{
super(factory, config, returnNull);
}
public String getMessage(Locale locale, String key)
{
// get the configuration for the specified locale
Configuration resource = getConfiguration(this.config + "_" + locale.getLanguage() + ".properties");
if(resource == null || !resource.containsKey(key))
{
// look for the key in the root configuration
resource = getConfiguration(this.config + ".properties");
}
return resource != null ? resource.getString(key,null) : null;
}
private Configuration getConfiguration(String name)
{
Configuration configuration = null;
URL url = Thread.currentThread().getContextClassLoader().getResource(name);
if(url != null)
{
PropertiesConfiguration pc = new PropertiesConfiguration();
pc.setURL(url);
FileChangedReloadingStrategy strategy = new FileChangedReloadingStrategy();
strategy.setRefreshDelay(10000); //Milli seconds
pc.setReloadingStrategy(strategy);
try
{
pc.load();
configuration = pc;
}
catch(ConfigurationException e)
{
//Logg it
}
}
return configuration;
}
}
I didn't sove this myself so I might not be able to answer questions on it.. . The example have to be modified to suite the specific project.
//P-A R