比较 CDI 和 AspectJ

发布于 2024-12-21 23:49:34 字数 135 浏览 2 评论 0原文

我们正在尝试在我们的项目中评估 CDI 和 AspectJ。这里有人做过类似的事情吗?有人可以分享一下他们对在某些主题上使用 CDI 或 AspectJ 的看法吗? 1. 学习曲线 2. 不同服务器的可移植性 3、可维护性 4. 调试

感谢

We are trying to evaluate CDI and AspectJ in our project. Has someone here done something similar? Can some one share their views on using CDI or AspectJ on some topics like
1. Learning Curve
2. Portability to different servers
3. Maintainability
4. Debuging

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

陌路黄昏 2024-12-28 23:49:34

这些实际上是非常不同的技术。 CDI 是一个依赖注入堆栈(如 Spring 或 Guice),具有一些 AOP 功能(在典型用例中足够了)。 AspectJ 是一种成熟的面向方面的编程语言,它并不真正提供任何依赖注入功能。

.1。学习曲线

这两种技术都有大量的材料。 CDI 是个新事物,但引起了很多关注。例如,请参阅CDI AOP 教程:Java 标准方法拦截教程

AspectJ 历史悠久,关于它的精彩书籍很少。但我想说的是,这要求更高一些。

.2。可移植到不同的服务器

CDI 是 DI 的 Java 标准。我们将看到越来越多的服务器实现它。 AspectJ 是一种在字节码级别上工作的语言。它几乎可以在任何 JVM 上工作(移动、桌面、服务器、小程序...)

至于可维护性和调试 - 这些是真正不同的技术,所以我不会在这里深入比较它们。然而,CDI 是标准 Java 代码,而 AspectJ 主要是字节码级别的代码生成。另一方面,AspectJ 生成的代码(堆栈跟踪、反编译)可能比大量反射代理和 CGLIB 使用 CDI 生成的类更具可读性。

These are actually very different technologies. CDI is a dependency injection stack (like Spring or Guice) with some AOP features (sufficient in typical use cases). AspectJ is a full-blown aspect-oriented programming language that doesn't really offer any dependency-injection features.

.1. Learning Curve

Both technologies have lots of materials. CDI is new but there is a lot of buzz around it. E.g. see CDI AOP Tutorial: Java Standard Method Interception Tutorial.

AspectJ is much older and there are few fantastic books about it. But I would say it is a bit more demanding.

.2. Portability to different servers

CDI is a Java standard for DI. We will see more and more servers implementing it. AspectJ is a language that works on a bytecode level. It should work on virtually any JVM (mobile, desktop, server, applet...)

As for maintainability and debugging - these are really different technologies so I won't dive into comparing them here. However CDI is a standard Java code while AspectJ is mostly code-generation at bytecode level. On the other hand AspectJ generated code (stack-traces, decompiling) might be more readable than tons of reflective proxies and CGLIB generated classes with CDI.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文