有人可以解释一下如何将OSGI DS配置为单身人士吗? 我使用Equinox作为OSGi容器。
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="Simple Dictionary">
<implementation class="foo.bar.services.DictionaryImpl"/>
<service>
<provide interface="foo.bar.services.Dictionary"/>
</service>
</scr:component>
osgi&gt; 服务(objectClass = foo.bar.services *)
{foo.bar.services.Dictionary} = {
component.name =简单字典,
component.id = 0,
service.id = 51,
service.bundleid = 7,
的 service.scope =捆
}
&#34;通过捆绑注册:&#34; foo.bar.services_1.0.0.qualifier [7]
&#34;没有使用服务的捆绑包。&#34;
答案 0 :(得分:1)
除非你说servicefactory="true"
,否则它是单身。 DS将始终使用SerivceFactory来注册组件的服务。这允许实际的组件创建和激活是惰性的。所以你永远不会在注册的服务上看到service.scope = singleton。
对于DS 1.3,servicefactory
将替换为scope
,但上述关于DS的声明始终使用ServiceFactory仍然有效。