Spring AOP pointcut with one certain argument

前端 未结 1 1635
情歌与酒
情歌与酒 2021-02-08 07:09

I need to create an aspect that I find hard to describe, so let me point out the ideas:

  • any method within the package (or any subpackage) of com.x.y...
  • on
相关标签:
1条回答
  • 2021-02-08 07:59

    As the error suggests you need to use the fully qualified name of the PortletRequest in the point cut expression - since it is a string the import context is not available during the time of evaluation of the expression.

    @Pointcut("execution(* com.x.y..*.*(javax.portlet.PortletRequest.PortletRequest,..)) && args(request,..)")
    public void thePointcut(PortletRequest request) {
    }
    

    Since you already are selecting the type in the args construct you don't need that in the signature. The following should also work.

    @Pointcut("execution(* com.x.y..*.*(..)) && args(request,..)")
    public void thePointcut(PortletRequest request) {
    }
    

    It is a and boolean operation - i.e., it needs to match the method pattern as well as the args construct.

    0 讨论(0)
提交回复
热议问题