Java 面向方面的编程 [英] Aspect-oriented programming in Java

查看:33
本文介绍了Java 面向方面的编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Java 面向方面编程的最佳工具是什么?

What is the best tool for Java for aspect-oriented programming?

对工具的要求当然是 IDE 支持、表达能力和适当的文档.

The requirements for a tool are of course IDE support, expressiveness and proper documentation.

推荐答案

JBossAOP 和 AspectJ 是两个常用的、成熟的 AOP 框架.另一个流行的选择是 Spring AOP,但它缺少其他两个的一些特性.

JBossAOP and AspectJ are two commonly used, mature frameworks for AOP. Another popular choice is Spring AOP, but it lacks some of the features of the other two.

JBossAOP 和 AspectJ 都有相似的特性,一个很大的区别是 AspectJ 依赖于对 Java 语言的扩展,而 JBoss AOP 则没有.

Both JBossAOP and AspectJ have similar features, one big difference being that AspectJ relies on extensions to the Java language, whereas JBoss AOP does not.

如果您的 AOP 要求相当简单,那么也值得考虑一个字节码操作库,例如 ASM.我已经使用 ASM 来实现简单的around-advice"(即在方法调用之前和之后注入的代码),并且它被证明是 JBossAOP 的更轻量级的替代方案.ASM 设计简洁且文档齐全.

If your AOP requirements are fairly simple, it's also worth considering a byte-code manipulation library, such as ASM. I've used ASM to implement simple 'around-advice' (ie, code that is injected before and after method invocations), and it proved to be a more lightweight alternative to JBossAOP. ASM is cleanly-designed and well-documented.

这篇关于Java 面向方面的编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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