osgi包生命周期问题
我尝试了解 osgi 是如何工作的。我已经编写了第一个 hello-world 包,当执行包激活器类的启动方法时,它会提供一些控制台输出。现在,我已经了解了延迟启动机制,并将此标志放入我的捆绑清单中。然后,我启动了 Equinox 控制台,安装了我的包并启动了它。但现在我希望我的包被标记为“开始”。但它已经调用了它的 start 方法并被标记为活动状态。 我是否理解延迟启动机制有什么问题???
I try to learn how osgi works. I've written my first hello-world bundle which gives some console output when the start-method of the bundle activator class is executed. Now, I've read about the lazy starting mechanism and I put this flag to my bundle manifest. then, I started the equinox console, installed my bundle and started it. but now I would have expected my bundle to be marked as 'starting'. but instead it already calls it's start method and is marked as active.
did I understand anything wrong with the lazy starting mechanism???
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当您有依赖于您的捆绑包和捆绑包中的类的其他捆绑包时,将使用惰性启动标志。
假设您有两个包 A 和 B,其中
激活包 B 时会发生什么?
如果没有延迟加载标志,则首先加载并激活 A 包。
使用延迟加载标志,直到类 D 需要引用类 C 时,A 捆绑包才会被加载或激活。
这可以在激活配置文件中产生很大的差异,因为加载和激活使用延迟加载标志,捆绑包的激活会被推迟到尽可能晚的时间,因此捆绑包的初始响应非常快...
相反,这个标志也使得推断执行时间变得更加困难对于 B 中的方法,因为这可以通过加载和激活包来拦截任何时候....
The lazy-start flag is used when you have other bundles that depend on your bundle and classes in your bundle.
Say you have two bundles A and B, where
What happens when the bundle B is activated?
Without the lazy-load flag, the A bundle is loaded and activated first.
With the lazy-load flag, the A bundle is not loaded or activated until the class D needs to refer to the class C.
That can make a very big difference in the activation profile, as the load and activation of bundles are postponed to happen as late as possible with the lazy-load flag so the initial response from the bundle is very fast...
On the contrary, this flag also makes it a hole lot more difficult to reason about the execution time for methods in B as this can be intercepted with load and activation of bundles at any time....
您说过,您在安装后已经启动了捆绑包 - 如果您手动启动捆绑包,则无论延迟激活策略如何,它都会被激活。
根据 OSGi 规范,以下激活正确:
更新:由于我无法说出在写答案时我打开了哪个版本的规范(但是,我相信它是 4.2 或 4.3),所以我检查了当前的 v5.1 版本。 0 规范,第 4.4.6.2 节包含实际的、语义上等效的位置。
You said, you already started your bundle after install - if you start your bundle manually, it is activated regardless of the lazy activation policy.
According to the OSGi specification the following is true for activation:
Update: as I cannot say which version of the specification I have opened at the time I wrote the answer (however, I believe, it was either 4.2 or 4.3), I have checked the current, v5.0 specification, and section 4.4.6.2 contains the actual, semantically equivalent place.