use of org.apache.struts.config.MessageResourcesConfig 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.config.MessageResourcesConfig in project sonarqube by SonarSource.
the class ModuleUtils method selectModule.
/**
* Select the module to which the specified request belongs, and add
* corresponding request attributes to this request.
*
* @param prefix The module prefix of the desired module
* @param request The servlet request we are processing
* @param context The ServletContext for this web application
*/
public void selectModule(String prefix, HttpServletRequest request, ServletContext context) {
// Expose the resources for this module
ModuleConfig config = getModuleConfig(prefix, context);
if (config != null) {
request.setAttribute(Globals.MODULE_KEY, config);
MessageResourcesConfig[] mrConfig = config.findMessageResourcesConfigs();
for (int i = 0; i < mrConfig.length; i++) {
String key = mrConfig[i].getKey();
MessageResources resources = (MessageResources) context.getAttribute(key + prefix);
if (resources != null) {
request.setAttribute(key, resources);
} else {
request.removeAttribute(key);
}
}
} else {
request.removeAttribute(Globals.MODULE_KEY);
}
}
use of org.apache.struts.config.MessageResourcesConfig in project sonarqube by SonarSource.
the class ModuleConfigImpl method freeze.
/**
* <p> Freeze the configuration of this module. After this method
* returns, any attempt to modify the configuration will return an
* IllegalStateException. </p>
*/
public void freeze() {
super.freeze();
ActionConfig[] aconfigs = findActionConfigs();
for (int i = 0; i < aconfigs.length; i++) {
aconfigs[i].freeze();
}
matcher = new ActionConfigMatcher(aconfigs);
getControllerConfig().freeze();
ExceptionConfig[] econfigs = findExceptionConfigs();
for (int i = 0; i < econfigs.length; i++) {
econfigs[i].freeze();
}
FormBeanConfig[] fbconfigs = findFormBeanConfigs();
for (int i = 0; i < fbconfigs.length; i++) {
fbconfigs[i].freeze();
}
ForwardConfig[] fconfigs = findForwardConfigs();
for (int i = 0; i < fconfigs.length; i++) {
fconfigs[i].freeze();
}
MessageResourcesConfig[] mrconfigs = findMessageResourcesConfigs();
for (int i = 0; i < mrconfigs.length; i++) {
mrconfigs[i].freeze();
}
PlugInConfig[] piconfigs = findPlugInConfigs();
for (int i = 0; i < piconfigs.length; i++) {
piconfigs[i].freeze();
}
}
use of org.apache.struts.config.MessageResourcesConfig in project sonarqube by SonarSource.
the class TestPropertyMessageResources method createMessageResources.
/**
* Create the PropertyMessageResources.
*/
private MessageResources createMessageResources(String file, boolean returnNull, String mode) {
MessageResourcesConfig config = new MessageResourcesConfig();
config.setNull(returnNull);
if (mode != null) {
config.setProperty("mode", mode);
}
PropertyMessageResourcesFactory factory = new PropertyMessageResourcesFactory();
factory.setConfig(config);
factory.setReturnNull(returnNull);
return factory.createResources(file);
}
Aggregations