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

查看:78
本文介绍了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天全站免登陆