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

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

问题描述

在 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?

推荐答案

这取决于它是如何实现的.

It depends in how it is implemented.

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

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

查看 Guice wiki:

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

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.

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

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