可能的 AOP 用例是什么? [英] What are the possible AOP use cases?
问题描述
我想描述一下在应用程序设计中有效参与 AOP 的可能情况.到目前为止,我遇到的只有:
I'd like to make a picture of what are the possible cases for effective involvement of AOP in application design. All I have met so far is:
- 日志相关
- 安全检查
- 交易管理
- 调整遗留应用程序
还有什么吗?
(不一定是基于 Spring 的代理的 AOP - 而是 JBoss AOP.)
(It doesn't have to be necessarily Spring's proxy based AOP - rather JBoss AOP.)
(相关问题)
推荐答案
我可以举两个例子:
在 JMX 中自动注册对象以进行远程管理.如果一个类使用我们的
@AutoRegister
注释,我们有一个方面可以监视该类的新实例并自动在 JMX 中注册它们.
Automatically registering objects in JMX for remote management. If a class is annotated with our
@AutoRegister
annotation, we have an aspect that watches for new instantiations of that class and registers them in JMX automatically.
审计日志(黄金标准的 AOP 用例).它有点粗糙,但一般的方法是注释表示一些可审计操作的方法.结合 Spring Security 之类的东西,我们可以很好地了解:
Audit logging (the gold standard AOP use case). Its a bit coarse but the general approach is to annotate methods that represent some auditable action. Combined with something like Spring Security, we can get a pretty good idea of:
- 用户是谁
- 他们正在调用什么方法
- 他们提供什么数据
- 调用方法的时间
- 调用是否成功(即是否抛出异常)
这篇关于可能的 AOP 用例是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!