当前位置: 首页>>代码示例>>Java>>正文


Java ModuleConfig.findMessageResourcesConfigs方法代码示例

本文整理汇总了Java中org.apache.struts.config.ModuleConfig.findMessageResourcesConfigs方法的典型用法代码示例。如果您正苦于以下问题:Java ModuleConfig.findMessageResourcesConfigs方法的具体用法?Java ModuleConfig.findMessageResourcesConfigs怎么用?Java ModuleConfig.findMessageResourcesConfigs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.struts.config.ModuleConfig的用法示例。


在下文中一共展示了ModuleConfig.findMessageResourcesConfigs方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initLookupMap

import org.apache.struts.config.ModuleConfig; //导入方法依赖的package包/类
/**
 * This is the first time this Locale is used so build the reverse lookup Map.
 * Search for message keys in all configured MessageResources for
 * the current module.
 */
private Map initLookupMap(HttpServletRequest request, Locale userLocale) {
    Map lookupMap = new HashMap();
    this.keyMethodMap = this.getKeyMethodMap();

    ModuleConfig moduleConfig =
            (ModuleConfig) request.getAttribute(Globals.MODULE_KEY);

    MessageResourcesConfig[] mrc = moduleConfig.findMessageResourcesConfigs();

    // Look through all module's MessageResources
    for (int i = 0; i < mrc.length; i++) {
        MessageResources resources = this.getResources(request, mrc[i].getKey());

        // Look for key in MessageResources
        Iterator iter = this.keyMethodMap.keySet().iterator();
        while (iter.hasNext()) {
            String key = (String) iter.next();
            String text = resources.getMessage(userLocale, key);

            // Found key and haven't added to Map yet, so add the text
            if ((text != null) && !lookupMap.containsKey(text)) {
                lookupMap.put(text, key);
            }
        }
    }

    return lookupMap;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:34,代码来源:LookupDispatchAction.java

示例2: selectModule

import org.apache.struts.config.ModuleConfig; //导入方法依赖的package包/类
/**
 * 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);
    } else {
        request.removeAttribute(Globals.MODULE_KEY);
    }

    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);
      }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:35,代码来源:ModuleUtils.java

示例3: initModuleMessageResources

import org.apache.struts.config.ModuleConfig; //导入方法依赖的package包/类
/**
 * <p>Initialize the application <code>MessageResources</code> for the specified
 * module.</p>
 *
 * @param config ModuleConfig information for this module
 *
 * @exception 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);
    }

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:44,代码来源:ActionServlet.java

示例4: selectModule

import org.apache.struts.config.ModuleConfig; //导入方法依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:35,代码来源:ModuleUtils.java

示例5: initModuleMessageResources

import org.apache.struts.config.ModuleConfig; //导入方法依赖的package包/类
/**
 * <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);
    }
}
 
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:43,代码来源:ActionServlet.java


注:本文中的org.apache.struts.config.ModuleConfig.findMessageResourcesConfigs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。