Class LockingFilter

All Implemented Interfaces:
jakarta.servlet.Filter, Aware, BeanNameAware, DisposableBean, InitializingBean, EnvironmentAware, EnvironmentCapable, ServletContextAware

@Component public class LockingFilter extends OncePerRequestFilter
A Filter that handles per user locking for the polling critical section.
Author:
Martin Lindström, Felix Hellman
  • Field Details

  • Constructor Details

    • LockingFilter

      public LockingFilter(TryLockRepository locks)
      Constructor.
      Parameters:
      locks - the lock repository
  • Method Details

    • doFilterInternal

      protected void doFilterInternal(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, jakarta.servlet.FilterChain filterChain) throws jakarta.servlet.ServletException, IOException
      Checks if the request is "/api/poll", and locks the same user from accessing the resource. If the resources is already being accessed, the api will return a HTTP-Status 429.
      Specified by:
      doFilterInternal in class OncePerRequestFilter
      Throws:
      jakarta.servlet.ServletException
      IOException