简体   繁体   English

访问osgi包资源

[英]Access to osgi bundle resources

I have an osgi bundle that gets activated when I start my application. 我有一个osgi包,当我启动我的应用程序时会激活它。 I only need to use it from time to time, but I need the bundle to maintain its state (its variables should stay with the same value). 我只需要不时地使用它,但我需要bundle来维持它的状态(它的变量应保持相同的值)。 But I have been unable to do this: each time the handler gets activated, I have to initialize the bundle's variables again. 但是我无法做到这一点:每次处理程序被激活时,我都必须再次初始化bundle的变量。

Can someone explain how this is done? 有人能解释一下这是怎么做到的吗?

Each time a bundle started, a new instance of the BundleActivator is created and called at the start method. 每次捆绑包启动时,都会创建BundleActivator的新实例并在start方法中调用。 It you need to preserve state across multiple bundle starts, you will need to persist your state so that upon each start, you can restore the state. 您需要在多个捆绑包启动时保留状态,您需要保持状态,以便每次启动时都可以恢复状态。 There are of course many many ways to persist data. 当然有许多方法可以持久保存数据。

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

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