Spring AOP Pointcut syntax for AND, OR and NOT

前端 未结 3 2078
半阙折子戏
半阙折子戏 2021-02-12 13:31

I\'m having trouble with a pointcut definition in Spring (version 2.5.6). I\'m trying to intercept all method calls to a class, except for a given method (someMethod in the exam

3条回答
  •  渐次进展
    2021-02-12 13:56

    I'm also using spring 2.5.6 and was having a similar problem with OR not working, but AND was working. It turns out that or (in lowercase) does work, so there is clearly a bug in that code.

    It is interesting that the proper aspectJ syntax is &&, ||, and !, but the and/or/not syntax was added by spring to make working in xml easier. From the manual:

    When combining pointcut sub-expressions, '&&' is awkward within an XML document, and so the keywords 'and', 'or' and 'not' can be used in place of '&&', '||' and '!' respectively.

    I would guess that since && is the only one that is actually awkward in xml (there is nothing difficult about putting | or ! in xml) then AND is the only one that was properly tested

提交回复
热议问题