Handling Intercepted request

63 Views Asked by At

Consider you have Aspect or Interceptor that intercepts all the requests to your controller. In case of Aspect, you can define some pointcuts and intercept request having ProceedingJoinPoint object. You can call ProceedingJoinPoint.proceed() to perform request. And consider you have, f.e., boolean flag; that indicates whether to perform intercepted request or not. The question is how to not perform intercepted request if needed. I added some code of my case, but you're welcome to provide your case (filter instead of aspect or so on)

@Pointcut("execution(public * *(..))")
    public void publicMethodPointcut() {
    }

 @Around("publicMethodPointcut()")
    public Object do(ProceedingJoinPoint pjp) {
        if (flag){
            return pjp.proceed();
        }
    }
0

There are 0 best solutions below