use of org.apache.struts.util.MessageResourcesFactory in project sonarqube by SonarSource.
the class ActionServlet method initModuleMessageResources.
/**
* <p>Initialize the application <code>MessageResources</code> for the
* specified module.</p>
*
* @param config ModuleConfig information for this module
* @throws ServletException if initialization cannot be performed
* @since Struts 1.1
*/
protected void initModuleMessageResources(ModuleConfig config) throws ServletException {
MessageResourcesConfig[] mrcs = config.findMessageResourcesConfigs();
for (int i = 0; i < mrcs.length; i++) {
if ((mrcs[i].getFactory() == null) || (mrcs[i].getParameter() == null)) {
continue;
}
if (log.isDebugEnabled()) {
log.debug("Initializing module path '" + config.getPrefix() + "' message resources from '" + mrcs[i].getParameter() + "'");
}
String factory = mrcs[i].getFactory();
MessageResourcesFactory.setFactoryClass(factory);
MessageResourcesFactory factoryObject = MessageResourcesFactory.createFactory();
factoryObject.setConfig(mrcs[i]);
MessageResources resources = factoryObject.createResources(mrcs[i].getParameter());
resources.setReturnNull(mrcs[i].getNull());
resources.setEscape(mrcs[i].isEscape());
getServletContext().setAttribute(mrcs[i].getKey() + config.getPrefix(), resources);
}
}
use of org.apache.struts.util.MessageResourcesFactory in project sonarqube by SonarSource.
the class TagTestBase method putBundleInScope.
protected void putBundleInScope(int scope, boolean returnNull) {
MessageResourcesFactory factory = MessageResourcesFactory.createFactory();
MessageResources messageResources = new PropertyMessageResources(factory, "org.apache.struts.taglib.sample");
messageResources.setReturnNull(returnNull);
pageContext.setAttribute(Globals.MESSAGES_KEY, messageResources, scope);
}
Aggregations