public class DBPropertyMessageResources extends MessageResources {
public DBPropertyMessageResources(MessageResourcesFactory factory, String config,boolean returnNull) {
super(factory, config,returnNull);
this.factory=factory;
this.config=config;
this.returnNull=false;
}
public String getMessage(Locale locale, String key) {
String result = DBPropertyMessageService.getMessage(locale, key,
returnNull);
// we need to flush the cache of the super class MessageResource as
//we want to have real dynamic data here (no caches
//except the one in DBPropertyMessageService)
formats.clear();
return result;
}
}
DBPropertyMessageResourcesFactory.java
public class DBPropertyMessageResourcesFactory extends
MessageResourcesFactory {
public MessageResources createResources(String config) {
return new DBPropertyMessageResources(this, config, this.returnNull);
}
}
DBPropertyMessageService.java
public class DBPropertyMessageService {
public static String getMessage(Locale locale, String key, boolean returnNull) {
key=null;
returnNull=true;
locale=null;
// do the jdbc coding to get the value from the database using the key
return "sparkle software";
}
}
struts-config.xml
<message-resources factory="com.sparkle.resources.DBPropertyMessageResourcesFactory" parameter="param1"/>