Eclipse RCP : bundle activation upon resource request

标签 eclipse eclipse-rcp rcp osgi-bundle lazy-initialization

The Eclipse-LazyStart header is used to specify if a bundle should be started before the first class or resource is accessed from that bundle

取自Eclipse官方documentation .
从这句话可以推断,如果指定Eclipse-LazyStart (或 Bundle-ActivationPolicy: lazy 在 Equinox 3.4+ 中)该 bundle 将在第一类或资源请求时激活。

最初我想问如何将资源文件添加到激活异常(exception)列表中,因为根据文档,异常(exception)列表仅包含类包:
Bundle-ActivationPolicy: lazy; exclude:="org.eclipse.foo1, org.eclipse.foo2"

但是后来我运行了一些测试,发现 bundle 没有在资源请求时被激活 - 只有类请求才会激活 bundle 。我能够访问我的资源文件并读取其内容,而无需触发 bundle Activator.start。

所以问题是:

  • 是否根据资源请求激活 bundle ?如果不是,则说明文档具有误导性。
  • 如果正在激活,如何将非 java 文件添加到排除/包含列表中?为什么 Activator.start 没有被触发?

最佳答案

Bundle-ActivationPolicy 的实际 OSGi 规范说:

By default, any class loaded from the bundle can trigger the lazy activation, however, resource loads must not trigger the activation. The lazy activation policy can define which classes cause the activation with the following directives:

• include - A list of package names that must trigger the activation when a class is loaded from any of these packages. The default is all package names present in the bundle.

• exclude - A list of package names that must not trigger the activation of the bundle when a class is loaded from any of these packages. The default is no package names.

(第 4.4.6.2 节 OSGi 核心版本,2014 年 6 月 6 日)

这就是说资源永远不会触发激活。

关于Eclipse RCP : bundle activation upon resource request,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36007279/

相关文章:

java - 代码不会在 Android Studio 中编译,但会在 Eclipse 中编译

java - BooleanFieldEditor 不从 PreferenceStore 加载值

java - 运行 eclipse RCP 应用程序后出现 "No application id has been found"

java - 如何在 RCP 工作台工具栏和 RCP View 之间进行通信

java - Eclipse RCP。添加 View 可恢复的附加条件

c - 我怎样才能让 Eclipse 在 #ifdef 中索引代码 .... #endif

java - 编译一个版本 - eclipse,maven

java - 不幸的是,卡里斯托已经停止工作

eclipse - 如何在必要时为所有项目Java类自动将@ Override,@ Deprecate和static修饰符添加到方法中?

java - 根据视角变化启用或禁用"file"->“新建”弹出菜单