Class RateLimitInterceptor

java.lang.Object
org.omnifaces.cdi.ratelimit.RateLimitInterceptor

@Dependent @Interceptor @Priority(1000) public class RateLimitInterceptor extends Object

CDI interceptor that enforces rate limiting on methods annotated with RateLimit.

This interceptor intercepts method invocations and checks if the rate limit has been exceeded. If the rate limit is exceeded, a RateLimitExceededException is thrown. Otherwise, the method execution continues normally.

With an explicit client ID, the counter is shared by all methods with the same client ID and limits. Without it, the counter is per client IP address per annotated method, or per class which declares a class-level annotation. The client IP address is resolved as per RateLimiter.checkRateLimit(HttpServletRequest, int, Duration, int).

Since:
5.0
Author:
Bauke Scholtz
See Also: