将 AOP 与 OSGI 结合使用的最佳解决方案?
我正在使用 Equinox,因此 Equinox Aspect 项目似乎是理所当然的,但该项目似乎处于非活动状态,并且只有一页文档,让我最终悬而未决。
除了那个项目之外,我没有看到在 OSGI 中使用 AOP 的很多选项。让我知道你们的想法以及可能性,谢谢:)
I am using Equinox, so the Equinox Aspect project seems like a no-brainer, but that project appears to be inactive and has only one page of documentation that leaves me hanging at the end.
Other than that project, I do not see many options for using AOP in OSGI. Let me know what you all think and what the possibilities are, thanks :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不知道有什么其他选择,但我不认为 Equinox Aspects 不活跃。它甚至在即将发布的 Helios 发布。
I don't know of any alternative, but I didn't think Equinox Aspects was inactive. It's even receiving new features in the upcoming Helios release.
显然,最大的问题是缺乏标准化的加载时间编织; Equinox Aspects 和 weaver(AJDT 使用)是目前唯一的选择。好消息是 OSGi 工作组正在积极推进字节码编织的所有辉煌,并将“很快”实现标准化。如果您现在确实需要可靠运行的东西,那么最好的选择仍然是编译时编织。恕我直言,无论如何,这都是一个更好的方法,至少对于 AOP 作为设计时活动来说,正如最初设想的那样。
The big issue is obviously with the lack of standardized loadtime weaving; Equinox Aspects and the weaver (used by AJDT) has been the only option for now. The good news is that bytecode weaving in all its glory is actively in progress in the OSGi working group and will "soon" be standardized. If you really need something that works reliably right now, your best bet is still compile-time weaving. IMHO that is a much better approach anyway, at least for AOP as design-time activity as it was originally envisioned..
作为替代方案,您还可以考虑使用 Apache Felix 依赖管理器,它允许您在运行时向现有 OSGi 服务添加拦截器。当然,这绝不是完整的 AOP 替代品,但对于某些用例来说可能就足够了。
您可以在此处找到更多文档和示例:
http ://felix.apache.org/site/apache-felix-dependency-manager-osgi-design-patterns.html
As an alternative, you could also consider using the Apache Felix Dependency Manager, which allows you to at runtime add interceptors to existing OSGi services. Of course this is in no way a full AOP replacement, but for some use cases it might be enough.
You can find more documentation and an example here:
http://felix.apache.org/site/apache-felix-dependency-manager-osgi-design-patterns.html