将捕获构造函数调用的切入点 [英] Pointcut that will capture constructor calls

查看:18
本文介绍了将捕获构造函数调用的切入点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试定义一个切入点,它将捕获所有构造函数调用,而不管修饰符、返回类型或类如何.我使用了以下代码

I am trying to define a pointcut which will capture all the constructor calls, regardless of the modifier, return type, or class. I have used the following code

after():execution(* * * .new(..))

我遇到了一个错误:

标记*"、("预期的语法错误.

Syntax error on token "*", "(" expected.

有人可以建议什么是正确的方法吗?

Can anybody suggest what may be the right approach?

推荐答案

只需去掉中间的星号*"即可.为构造函数调用指定返回类型是没有意义的,因为很明显,构造函数将始终返回为其定义的类的实例.

Just remove the middle star "*". It does not make sense to specify a return type for a constructor call because it is clear that the constructor will always return an instance of the class it is defined for.

after() : execution(* *.new(..))

顺便说一句,您还应该删除.new"之前的空格.

BTW, you should also remove the whitespace before ".new".

这篇关于将捕获构造函数调用的切入点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆