コード例 #1
0
  /**
   * Process all non-boolean context initialization parameters.
   *
   * @param servletContext the ServletContext of interest
   * @param contextName the context name
   */
  private void processInitParameters(ServletContext servletContext, String contextName) {

    for (WebContextInitParameter param : WebContextInitParameter.values()) {
      String value = servletContext.getInitParameter(param.getQualifiedName());

      if (value != null && value.length() > 0 && param.isDeprecated()) {
        WebContextInitParameter alternate = param.getAlternate();
        DeprecationLoggingStrategy strategy = param.getDeprecationLoggingStrategy();
        if (strategy == null || strategy.shouldBeLogged(this)) {
          if (LOGGER.isLoggable(Level.WARNING)) {
            if (alternate != null) {
              queueLoggingAction(
                  new DeferredParameterLoggingAction(
                      param,
                      Level.WARNING,
                      "jsf.config.webconfig.param.deprecated",
                      new Object[] {
                        contextName, param.getQualifiedName(), alternate.getQualifiedName()
                      }));

            } else {
              queueLoggingAction(
                  new DeferredParameterLoggingAction(
                      param,
                      Level.WARNING,
                      "jsf.config.webconfig.param.deprecated.no_replacement",
                      new Object[] {contextName, param.getQualifiedName()}));
            }
          }
        }

        if (alternate != null) {
          queueLoggingAction(
              new DeferredParameterLoggingAction(
                  param,
                  Level.INFO,
                  "jsf.config.webconfig.configinfo.reset",
                  new Object[] {contextName, alternate.getQualifiedName(), value}));

          contextParameters.put(alternate, value);
        }
        continue;
      }

      if ((value == null || value.length() == 0) && !param.isDeprecated()) {
        value = param.getDefaultValue();
      }
      if (value == null || value.length() == 0) {
        continue;
      }

      if (value.length() > 0) {
        if (LOGGER.isLoggable(loggingLevel)) {
          LOGGER.log(
              loggingLevel,
              "jsf.config.webconfig.configinfo",
              new Object[] {contextName, param.getQualifiedName(), value});
        }
        contextParameters.put(param, value);
      } else {
        if (LOGGER.isLoggable(loggingLevel)) {
          LOGGER.log(
              loggingLevel,
              "jsf.config.webconfig.option.notconfigured",
              new Object[] {contextName, param.getQualifiedName()});
        }
      }
    }
  }
コード例 #2
0
  /**
   * Process all boolean context initialization parameters.
   *
   * @param servletContext the ServletContext of interest
   * @param contextName the context name
   */
  private void processBooleanParameters(ServletContext servletContext, String contextName) {

    // process boolean contxt parameters
    for (BooleanWebContextInitParameter param : BooleanWebContextInitParameter.values()) {
      String strValue = servletContext.getInitParameter(param.getQualifiedName());
      boolean value;

      if (strValue != null && strValue.length() > 0 && param.isDeprecated()) {
        BooleanWebContextInitParameter alternate = param.getAlternate();
        if (LOGGER.isLoggable(Level.WARNING)) {
          if (alternate != null) {
            queueLoggingAction(
                new DeferredBooleanParameterLoggingAction(
                    param,
                    Level.WARNING,
                    "jsf.config.webconfig.param.deprecated",
                    new Object[] {
                      contextName, param.getQualifiedName(), alternate.getQualifiedName()
                    }));

          } else {
            queueLoggingAction(
                new DeferredBooleanParameterLoggingAction(
                    param,
                    Level.WARNING,
                    "jsf.config.webconfig.param.deprecated.no_replacement",
                    new Object[] {contextName, param.getQualifiedName()}));
          }
        }

        if (alternate != null) {
          if (isValueValid(param, strValue)) {
            value = Boolean.valueOf(strValue);
          } else {
            value = param.getDefaultValue();
          }

          if (LOGGER.isLoggable(Level.INFO) && alternate != null) {
            queueLoggingAction(
                new DeferredBooleanParameterLoggingAction(
                    param,
                    Level.INFO,
                    ((value)
                        ? "jsf.config.webconfig.configinfo.reset.enabled"
                        : "jsf.config.webconfig.configinfo.reset.disabled"),
                    new Object[] {contextName, alternate.getQualifiedName()}));
          }

          booleanContextParameters.put(alternate, value);
        }
        continue;
      }

      if (!param.isDeprecated()) {
        if (strValue == null) {
          value = param.getDefaultValue();
        } else {
          if (isValueValid(param, strValue)) {
            value = Boolean.valueOf(strValue);
          } else {
            value = param.getDefaultValue();
          }
        }

        // first param processed should be
        // com.sun.faces.displayConfiguration
        if (BooleanWebContextInitParameter.DisplayConfiguration.equals(param) && value) {
          loggingLevel = Level.INFO;
        }

        if (LOGGER.isLoggable(loggingLevel)) {
          LOGGER.log(
              loggingLevel,
              ((value)
                  ? "jsf.config.webconfig.boolconfiginfo.enabled"
                  : "jsf.config.webconfig.boolconfiginfo.disabled"),
              new Object[] {contextName, param.getQualifiedName()});
        }

        booleanContextParameters.put(param, value);
      }
    }
  }