/**
   * Get the current ModuleConfig. <br>
   * Lookup in the request and do selectModule if not found. The side effect is, that the
   * ModuleConfig object is set in the request if it was not present.
   *
   * @param request Current request.
   * @param servletContext Current servlet context*.
   * @return The ModuleConfig for current request.
   */
  protected ModuleConfig getModuleConfig(
      HttpServletRequest request, ServletContext servletContext) {

    ModuleConfig moduleConfig = ModuleUtils.getInstance().getModuleConfig(request);

    if (moduleConfig == null) {
      // ModuleConfig not found in current request. Select it.
      ModuleUtils.getInstance().selectModule(request, servletContext);
      moduleConfig = ModuleUtils.getInstance().getModuleConfig(request);
    }

    return moduleConfig;
  }
Ejemplo n.º 2
0
  /**
   * Retrieve <code>ValidatorResources</code> for the current module.
   *
   * @param application Application Context
   * @param request The ServletRequest
   */
  public static ValidatorResources getValidatorResources(
      ServletContext application, HttpServletRequest request) {

    String prefix = ModuleUtils.getInstance().getModuleConfig(request, application).getPrefix();

    return (ValidatorResources) application.getAttribute(ValidatorPlugIn.VALIDATOR_KEY + prefix);
  }
Ejemplo n.º 3
0
  /**
   * Retrieve <code>MessageResources</code> for the module and bundle.
   *
   * @param application the servlet context
   * @param request the servlet request
   * @param bundle the bundle key
   */
  public static MessageResources getMessageResources(
      ServletContext application, HttpServletRequest request, String bundle) {

    if (bundle == null) {
      bundle = Globals.MESSAGES_KEY;
    }

    MessageResources resources = (MessageResources) request.getAttribute(bundle);

    if (resources == null) {
      ModuleConfig moduleConfig = ModuleUtils.getInstance().getModuleConfig(request, application);
      resources = (MessageResources) application.getAttribute(bundle + moduleConfig.getPrefix());
    }

    if (resources == null) {
      resources = (MessageResources) application.getAttribute(bundle);
    }

    if (resources == null) {
      throw new NullPointerException("No message resources found for bundle: " + bundle);
    }

    return resources;
  }