Пример #1
0
  @Override
  public void init(FilterConfig filterConfig) throws ServletException {
    super.init(filterConfig);

    int reloadTime = readInt(filterConfig.getInitParameter(INIT_PARAM_RELOAD_TIME), 0);

    this.resetTime = readInt(filterConfig.getInitParameter(INIT_PARAM_RESET_TIME), resetTime);

    lastResetTime = new Date().getTime();

    if (cache == null) // fixme: checking for letting the unit test happy but nothing.
    cache = buildCache(reloadTime);

    LOGGER.debug(
        "Cache Filter initialized with: {}:{},\n{}:{}",
        INIT_PARAM_RELOAD_TIME,
        String.valueOf(reloadTime),
        INIT_PARAM_RESET_TIME,
        String.valueOf(resetTime));
  }
  /* (non-Javadoc)
   * @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
   */
  @Override
  public void init(FilterConfig filterConfig) throws ServletException {
    super.init(filterConfig);

    int compressionMinSize =
        readInt(
            filterConfig.getInitParameter(INIT_PARAM_COMPRESSION_THRESHOLD),
            this.compressionThreshold);
    long decompressMaxBytesPerSecond =
        readLong(
            filterConfig.getInitParameter(INIT_PARAM_DECOMPRESS_MAX_BYTES_PER_SECOND),
            this.decompressionRate);

    long maxDecompressedRequestSize =
        readLong(
            filterConfig.getInitParameter(INIT_PARAM_MAX_DECOMPRESSED_REQUEST_SIZE_IN_BYTES),
            this.maxDecompressedRequestSizeInBytes);

    if (compressionMinSize > 0) { // priority given to configured value
      this.compressionThreshold = compressionMinSize;
    }
    if (decompressMaxBytesPerSecond > 0) { // priority given to configured value
      this.decompressionRate = decompressMaxBytesPerSecond;
    }
    if (maxDecompressedRequestSize > 0) { // priority given to configured value
      this.maxDecompressedRequestSizeInBytes = maxDecompressedRequestSize;
    }
    LOGGER.trace(
        "Filter initialized with: {}:{},\n{}:{}\n{}:{}",
        INIT_PARAM_COMPRESSION_THRESHOLD,
        String.valueOf(this.compressionThreshold),
        INIT_PARAM_DECOMPRESS_MAX_BYTES_PER_SECOND,
        String.valueOf(this.decompressionRate),
        INIT_PARAM_MAX_DECOMPRESSED_REQUEST_SIZE_IN_BYTES,
        String.valueOf(this.maxDecompressedRequestSizeInBytes));
  }