Class ContentCachingFilter

java.lang.Object
net.solarnetwork.central.web.support.ContentCachingFilter
All Implemented Interfaces:
jakarta.servlet.Filter, net.solarnetwork.service.PingTest

public class ContentCachingFilter extends Object implements jakarta.servlet.Filter, net.solarnetwork.service.PingTest
Filter for caching HTTP responses, returning cached data when possible.

This filter delegates most behavior to a ContentCachingService.

Since:
1.16
  • Field Details

    • DEFAULT_STAT_LOG_ACCESS_COUNT

      public static final int DEFAULT_STAT_LOG_ACCESS_COUNT
      The default value for the statLogAccessCount property.
      See Also:
  • Constructor Details

  • Method Details

    • lockPoolWithCapacity

      public static BlockingQueue<ContentCachingFilter.LockAndCount> lockPoolWithCapacity(int lockPoolCapacity)
      Create a look pool.
      Parameters:
      lockPoolCapacity - the desired capacity of the pool
      Returns:
      the pool
    • doFilter

      public void doFilter(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, jakarta.servlet.FilterChain chain) throws IOException, jakarta.servlet.ServletException
      Specified by:
      doFilter in interface jakarta.servlet.Filter
      Throws:
      IOException
      jakarta.servlet.ServletException
    • getPingTestId

      public String getPingTestId()
      Specified by:
      getPingTestId in interface net.solarnetwork.service.PingTest
    • getPingTestName

      public String getPingTestName()
      Specified by:
      getPingTestName in interface net.solarnetwork.service.PingTest
    • getPingTestMaximumExecutionMilliseconds

      public long getPingTestMaximumExecutionMilliseconds()
      Specified by:
      getPingTestMaximumExecutionMilliseconds in interface net.solarnetwork.service.PingTest
    • performPingTest

      public net.solarnetwork.service.PingTest.Result performPingTest() throws Exception
      Specified by:
      performPingTest in interface net.solarnetwork.service.PingTest
      Throws:
      Exception
    • setMethodsToCache

      public void setMethodsToCache(Set<String> methodsToCache)
      Configure the HTTP methods that can be cached.

      The method names should be all upper case.

      Parameters:
      methodsToCache - the methods to cache; defaults to GET only
    • setRequestLockTimeout

      public void setRequestLockTimeout(long requestLockTimeout)
      A timeout for waiting for a request lock.
      Parameters:
      requestLockTimeout - the timeout to use, in milliseconds; defaults to 4 minutes
    • setStatLogAccessCount

      public void setStatLogAccessCount(int statLogAccessCount)
      Set the statistic log update count.

      Setting this to something greater than 0 will cause INFO level statistic log entries to be emitted every statLogAccessCount times a cachable request has been processed.

      Parameters:
      statLogAccessCount - the access count the access count; defaults to DEFAULT_STAT_LOG_ACCESS_COUNT
      Since:
      3.0