@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface RateLimiter {
int value() default 100;
}
@Aspect
@Component
public class RateLimitAspect {
private static final RateLimiterInterceptor interceptor = new RateLimiterInterceptor();
@Pointcut("@annotation(com.example.RateLimiter)")
public void rateLimitPointcut() {}
@Around("rateLimitPointcut()")
public Object rateLimit(ProceedingJoinPoint joinPoint) throws Throwable {
return interceptor.invoke(joinPoint);
}
}
public class RateLimiterInterceptor implements MethodInterceptor {
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
return null;
}
}
@Configuration
@EnableAspectJAutoProxy
public class RateLimiterConfig {
@Bean
public RateLimitAspect rateLimitAspect() {
return new RateLimitAspect();
}
}
<dependency>
<groupId>com.nepxion</groupId>
<artifactId>nepxion-matrix-aop-starter</artifactId>
<version>xxx</version>
</dependency>