OSGI上的AspectJ LoadTimeWeaving

时间:2018-09-23 10:02:57

标签: osgi aspectj equinox load-time-weaving osgi-fragment

我正试图在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]

我想知道如何启动挂钩罐? 我将不胜感激... ps。有人通过将捆绑包“ org.eclipse.osgi”和片段“ org.eclipse.equinox.weaving.hook”作为“具有链接内容的二进制项目”导入到他的工作空间中来解决了他的问题,但是我不确定如何去做: https://www.eclipse.org/forums/index.php?t=msg&th=440862

感谢您的回复

1 个答案:

答案 0 :(得分:1)

当我在工作中遇到铁路交通控制应用程序的问题时,就在我的博客上写了一篇有关该主题的较大文章。它仍在其核心功能方面运行-不仅用于呼叫跟踪,而且还用于JPA和线程安全方面的自动资源和事务处理等等(因此,我知道该解决方案在我以前的项目中仍然可以实际使用): / p>

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捆绑包附近?上次我对它有一些不太清楚的要求,这就是为什么我在博客文章中写下来的原因。 2.)您是否通过以下链接尝试了我的示例代码?

https://github.com/prenex/equinox_osgi_skeleton

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

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

最好的问候, 理查德·蒂尔

PS .:您是如何偶然发现我的博客的?我很高兴有人真正阅读它并发现它对您有帮助,即使它不能完全解决所有问题。 :-) “