[英]How to configure OSGI Declarative Service scope?
有人可以解释一下如何将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>服务(objectClass = foo.bar.services *)
{foo.bar.services.Dictionary} = {
component.name =简单字典,
component.id = 0,
service.id = 51,
service.bundleid = 7,
service.scope =束
}
“按捆绑包注册:” foo.bar.services_1.0.0.qualifier [7]
“没有捆绑使用服务。”
除非您说servicefactory="true"
否则它是单例。 DS将始终使用SerivceFactory来注册组件的服务。 这使得实际的组件创建和激活变得很懒。 因此,您将永远不会在注册的服务上看到service.scope = singleton。
对于DS 1.3, servicefactory
将被scope
替换,但是上述有关DS始终使用ServiceFactory的声明仍然适用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.