Java Aspect oriented - interface Around not working as expected when applied on a class

29 Views Asked by At

My interface code;

@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD, ElementType.ANNOTATION_TYPE})
@Documented
@Inherited
public @interface JwtTokenRequired {
}

My aspect code

@Pointcut("execution(* com.compamy..*(..))")
public void controllerMethods() {}

   @Around("@annotation(com.company.aspect.JwtTokenRequired)")
    public Object validateJwtToken(ProceedingJoinPoint joinPoint) throws Throwable {
        HttpServletRequest request = getRequest(joinPoint.getArgs());

}

My controller class, if I set @JwtTokenRequired - on the method create, its going inside Around validate token but if I add it to the class level it wont, what could be the issue ?

@RestController
@RequestMapping("/content")
@JwtTokenRequired
public class Content extends AbstractController{


    @PostMapping("/create")
    public boolean create() {
        return true;
    }
0

There are 0 best solutions below