简体   繁体   English

如何使用Apache Felix在OSGi中归档AOP

[英]How to archieve AOP in OSGi with Apache Felix

I'm currently working on an OSGi project where some parts are perfect for AOP programming. 我目前正在研究OSGi项目,其中的某些部分非常适合AOP编程。 Without many experiences in AOP combined with OSGi, I would like to know how to best do AOP in an OSGi environment? 如果没有将AOP与OSGi结合使用的丰富经验,我想知道如何在OSGi环境中最好地进行AOP? I've read some articles about this problem, but did not find a solution that suits well for me. 我已经阅读了一些有关此问题的文章,但没有找到适合我的解决方案。 There is, for example, an Equinox Incubator project for AspectJ, but the last build was on 2008. But since I'm using Apache Felix and Bnd(tools) I want to avoid using something from Equinox. 例如,有一个针对AspectJ的Equinox孵化器项目,但最后一次构建是在2008年。但是由于我使用的是Apache Felix和Bnd(tools),因此我想避免使用Equinox的某些功能。 Btw., one requirement for the weaving process will be that it should be at compile-time and maybe later load-time as well. 顺便说一句,编织过程的一个要求是它应该在编译时,也可能在以后的加载时。 Furthermore I'm using Ant and Bnd to build my bundles. 此外,我正在使用Ant和Bnd构建我的捆绑包。 So it would be great if I can integrate Aspectj into this build process as well. 因此,如果我也可以将Aspectj集成到此构建过程中,那就太好了。

Hopefully someone can share experiences with such a use case. 希望有人可以分享这种用例的经验。

EDIT 编辑

Summary so far: 到目前为止的摘要:

  • there is a possibility to use Spring AOP as Christian Schneider mentioned in his answer (but pityful not what I am looking for) 可以使用克里斯汀·施耐德(Christian Schneider)在他的回答中提到的Spring AOP(但可惜的不是我在寻找什么)

I think you can take a look at Aries JPA. 我认为您可以看看Aries JPA。 Load time weaving was added recently there. 最近在此处添加了加载时间编织。 Seems like there is also a weaving hook in the newer OSGi spec. 似乎在更新的OSGi规范中也有一个编织钩。 So support for AspectJ and the like may be quite possible now. 因此,现在有可能对AspectJ等提供支持。 I have not yet seen it in action though. 我还没有看到它的实际应用。

A big question is of course. 当然有一个大问题。 Why do you need AOP and what do you want to do with it? 为什么需要AOP?您要如何处理? In general AOP in most cases looks simpler than it is and gives you lees benefits than you think at first. 通常,在大多数情况下,AOP看起来比实际要简单,并且给您带来的好处远不如您最初想象的那样。 So my advice is be careful and think twice before using AOP too much. 因此,我的建议是谨慎使用,在过多使用AOP之前要三思。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM