开发者

Check whether advice is applied

Consider I wrote AOP point开发者_高级运维cut and made a misprint in it:

@Pointcut("within(com.example.servic..*)")
public void serviceMethod() {}

There is "servic" instead of "service".

I am going to use this pointcut to apply security check before service method invocation. Due to the misprint the security check won't be applied but there will be no error message also.

It seems to be very easy to make such mistakes during refactoring for example.

The question is: how do you check that advices are really applied in your projects?

Thanks in advance!


Perfect candidate for a unit test.


The most elegant solution is to use a good IDE.

If you are using Eclipse, install the AJDT plugin and you will see an orange arrow to the left of all lines that is matched by an Spring AOP/AspectJ advice and all advices have information on how many matches it has in the code.

Another advantage with a plugin like AJDT is that it also weaves automatically for you everytime Eclipse compiles a class.

An example with the AJDT plugin activated:

Check whether advice is applied


(source: espenberntsen.net)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜