Spring AOP pointcut that matches annotation on interface

后端 未结 2 657
梦谈多话
梦谈多话 2020-12-01 06:14

I have a service class implemented in Java 6 / Spring 3 that needs an annotation to restrict access by role.

I have defined an annotation called RequiredPermission t

2条回答
  •  感情败类
    2020-12-01 07:13

    If I understand you correct, you want a pointcut that finds all methods in classes that extends MyService and is annotated and with the preferred arguments.

    I propose that you replace:

    execution(public * com.mycompany.myserviceimpl.*(..))
    

    with:

    execution(public * com.mycompany.myservice.MyService+.*(..))
    

    The plus sign is used if you want a joinpoint to match the MyService class or a class that extends it.

    I hope it helps!

提交回复
热议问题