【发布时间】:2013-02-11 21:10:45
【问题描述】:
是否可以在方法结束时执行操作,换句话说,当函数控制使用注释返回给调用者时(由于异常或正常返回)?
例子:
@DoTaskAtMethodReturn
public void foo() {
.
.
.
Method foo Tasks
.
.
.
return; --------> Background task done by annotation hook here before returning to caller.
}
【问题讨论】:
-
你在使用像 Spring 或 Guice 这样的依赖注入框架吗?它们提供简单的 AOP 功能。
-
@CodyA.Ray 感谢您的回复。是的,我正在使用 Spring。我不了解 AOP,所以我将使用它。
标签: java annotations spring-annotations