Osgi 声明性服务在默认情况下是单例服务吗?

Osgi 声明性服务在默认情况下是单例服务吗?,osgi,equinox,declarative-services,Osgi,Equinox,Declarative Services,配置: <?xml version="1.0" encoding="UTF-8"?> <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" enabled="true" immediate="true" name="printing"> <implementation class="printing.PrinterManager"/> <service>

配置:

<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" enabled="true" immediate="true" name="printing">
   <implementation class="printing.PrinterManager"/>
   <service>
      <provide interface="service.printing.IPrinterManager"/>
   </service>
</scr:component>
当我在代码中的其他地方注入该类的对象时,如下所示:

@Inject
IPrinterManager pm;
我是否总是得到该类的相同实例?
如果这个实例还不是一个单例,那么如何在osgi/equinox工具的帮助下使它成为一个单例呢?(我知道如何用java/vanilla的方式编写单例程序,这不是我的问题)

是的,DS组件在默认情况下是单例程序。请参见

谢谢您的回答,您是否介意分享一个指向您的知识来源的链接?将该链接添加到answer@Inject? 这不应该是@Reference吗?我想这取决于您选择的DI框架@Inject在equinox/e4/javafx星座中对我有效
@Inject
IPrinterManager pm;