Android中面向方面的编程

发布于 2024-09-24 10:44:05 字数 68 浏览 0 评论 0原文

在 Android 应用程序中实现面向方面编程 (AOP) 的最佳方式是什么?

用手机电池的话效率会高吗?

What would be the best way to implement Aspect-oriented programming (AOP) in an Android application?

Would it be efficient with the mobile battery?

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

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

发布评论

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

评论(1

爱本泡沫多脆弱 2024-10-01 10:44:05

这取决于它如何实施。

例如,AspectJ 的编译时编织可以在 Android 上运行,但运行时编织则不能。
Android 不支持字节码生成。

查看 Guice wiki

幕后,方法拦截
通过生成字节码来实现
在运行时。 Guice动态创建
应用拦截器的子类
通过覆盖方法。如果您在
不支持字节码的平台
世代(例如 Android),您
应该使用没有 AOP 支持的 Guice。

It depends in how it is implemented.

For instance, AspectJ's compile-time weaving would work on android but runtime weaving do not.
Android does not support bytecode generation.

Check the Guice wiki:

Behind the scenes, method interception
is implemented by generating bytecode
at runtime. Guice dynamically creates
a subclass that applies interceptors
by overriding methods. If you are on a
platform that doesn't support bytecode
generation (such as Android), you
should use Guice without AOP support.

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