java - Eclipse 插件单例设置

标签 java eclipse-plugin

我有一个插件,其中包含工作区中所有项目都可以访问的自定义 Xpath 函数。在创建插件时,它将其创建为单例,因为它需要扩展和扩展点。这样做是为了让自定义功能只注册一次吗?

[ ] 这个插件是单例的

同样在运行时,这是否意味着所有利用自定义函数的应用程序都需要等待另一个应用程序才能调用自定义函数?如果是这样,这不会减慢一切吗?或者它们可以并发调用函数并且彼此之间对插件没有等待依赖性?

最佳答案

此标志的作用是确保仅加载插件的一个版本。因此,如果 RCP 中同时存在插件的 1.0.0 版和 2.0.0 版,则只会使用其中一个(通常是最高版本)。

它不会以任何方式影响插件的执行方式。

来自“Bundle-SymbolicName”的 OSGi 规范:

singleton - Indicates that the bundle can only have a single version resolved in an environment. A value of true indicates that the bundle is a singleton bundle. The default value is false. The Framework must resolve at most one bundle when multiple versions of a singleton bundle with the same symbolic name are installed.

关于java - Eclipse 插件单例设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37028857/

相关文章:

Java ResultSet 复制到通用对象或列表

java - 自定义 Java Servlet 过滤器

java - 使@Singular 和@Builder 在eclipse 中工作

java - 不带 Eclipse 平台的 GEF 5

java - 如何: Send collection of objects over a socket?

java - 枚举中的重载等于方法 - 有什么陷阱吗?

java - Eclipse RCP - 以编程方式刷新 PackageExplorerPart

java - 使用 xml 隐藏 eclipse 中的透视图

java - 如何在标准序列化中序列化不可序列化的基类?

java - Eclipse 插件 - 开关文件的监听器