OSGI 上的 AspectJ LoadTimeWeaving

AspectJ LoadTimeWeaving on OSGI

我正在尝试在 equinox jars(org.aspectj.runtime、org.aspectj.weaver、org.eclipse.equinox.weaving.aspectj 捆绑包的帮助下在 OSGI 上使用 aspectJ 加载时间编织(无 Spring)文件夹和 org.eclipse.equinox.weaving.hook 位于与 org.eclipse.osgi 物理位置相同的文件夹)根据:https://wiki.eclipse.org/Equinox_Weaving_QuickStart

这是捆绑包的加载顺序:

[org.eclipse.equinox.weaving.hook::1 -> INSTALLED]
[org.aspectj.runtime::11 -> INSTALLED]
[org.aspectj.weaver::12 -> INSTALLED]
[org.eclipse.equinox.weaving.aspectj::13 -> INSTALLED]
[com.common-calculations_2.11::19 -> INSTALLED] //here I used aspects
[com.instrumentation_2.11::48 -> INSTALLED] //here I defined the aspects 
Done installing bundles
Starting bundles...
[org.eclipse.equinox.weaving.aspectj::13 -> ACTIVE]
[org.aspectj.runtime::11 -> ACTIVE]
[org.eclipse.osgi::0 -> ACTIVE]
 FRAGMENT Bundle - skip starting: org.eclipse.equinox.weaving.hook
 FRAGMENT Bundle - skip starting: org.aspectj.runtime
[org.aspectj.weaver::12 -> ACTIVE]
 FRAGMENT Bundle - skip starting: org.eclipse.equinox.weaving.aspectj
 Bundle started: [com.common-calculations_2.11::19 -> ACTIVE]
 Bundle started: [com.instrumentation_2.11::48 -> ACTIVE]

我想知道如何启动hook jar? 我会很感激任何帮助... p.s。有人通过将包 "org.eclipse.osgi" 和片段 "org.eclipse.equinox.weaving.hook" 作为 "Binary Project with Linked Content" 导入他的工作区解决了他的问题,但我不太确定该怎么做: https://www.eclipse.org/forums/index.php?t=msg&th=440862

感谢您的回复

有一次我在我的博客上写了一篇关于这个主题的更大的文章,当时我在工作中遇到了铁路交通控制应用程序的问题。它仍然 运行 具有核心功能方面的功能 - 不仅用于调用跟踪,还用于 JPA 和线程安全方面的自动资源和事务处理等等(所以我知道该解决方案在我的现实生活中仍然有效以前的项目):

http://ballmerpeak.web.elte.hu/devblog/setting-up-aspect-oriented-programming-with-equinox-osgi-and-ajdt.html

我的 github:

提供了独立的示例代码

https://github.com/prenex/equinox_osgi_skeleton

如果对其他人有帮助,我也会在这里添加我们的电子邮件内容:

” 嗨!

我在不久前研究这个主题,但它对我们来说确实运作良好,并且仍然是基于插件的铁路交通控制应用程序的一部分。

针对您的问题:

1.) 您是否将 equinox.weaving.hook 捆绑包放在核心 org.eclipse.osgi 捆绑包附近?有一些不太清楚的东西,比如我上次处理它时的这个需求,这就是为什么我把它写在博客 post 中的原因。 2.) 您是否从以下 link?

中尝试了我的示例代码

https://github.com/prenex/equinox_osgi_skeleton

我会先尝试 运行 我的这个示例项目,其中已经包含 AspectJ,然后在相关位置逐行比较您的解决方案,直到它开始工作。

查看以下提交,了解我在通用 equinox+osgi 框架项目中所做的更改以添加简单的 AspectJ 支持: https://github.com/prenex/equinox_osgi_skeleton/commit/882d7765f31a3fc8ee136e88b689fce116a73d1c

此致, 理查德·蒂尔

PS.: 你是怎么发现我的博客的?我很高兴有人真正阅读了它并发现它有帮助,即使它不能完全解决他们所有的问题。 :-) “