【发布时间】:2014-12-17 14:11:10
【问题描述】:
我正在使用 Spring 框架 (4.0.5) 和 AspectJ 开发用于 AOP 日志记录的 java (JDK1.6) 应用程序。
我的 Aspect 类工作正常,但我无法为构造函数对象创建切入点。
这是我的对象:
@Controller
public class ApplicationController {
public ApplicationController(String myString, MyObject myObject) {
...
}
...
..
.
}
这是我的 Aspect 类:
@Aspect
@Component
public class CommonLogAspect implements ILogAspect {
Logger log = Logger.getLogger(CommonLogAspect.class);
// @Before("execution(my.package.Class.new(..)))
@Before("execution(* *.new(..))")
public void constructorAnnotatedWithInject() {
log.info("CONSTRUCTOR");
}
}
如何为我的构造函数对象创建切入点?
谢谢
【问题讨论】:
-
@kocko
"有,我在输入问题时错过了它们。 -
我不相信你可以拦截纯Spring AOP中的构造函数调用。
-
@SotiriosDelimanolis 如何拦截构造函数调用?
-
也许使用 AspectJ 工具。
-
@SotiriosDelimanolis 你能给我举个例子或链接一个指南吗?谢谢
标签: java spring aop aspectj spring-aop