Java 如何配置OSGI声明性服务范围?
有人能解释一下如何将OSGI DS配置为单体吗? 我使用Equinox作为OSGi容器 可控硅元件Java 如何配置OSGI声明性服务范围?,java,osgi,declarative-services,Java,Osgi,Declarative Services,有人能解释一下如何将OSGI DS配置为单体吗? 我使用Equinox作为OSGi容器 可控硅元件 OSGI控制台输出 osgi>服务(objectClass=foo.bar.services*) {foo.bar.services.Dictionary}={ component.name=简单字典, 组件id=0, 服务id=51, service.bundleid=7, 服务范围=捆绑 } 捆绑注册:“foo.bar.services_1.0.0.qualifier[7] “没有使用服务
OSGI控制台输出
osgi>服务(objectClass=foo.bar.services*){foo.bar.services.Dictionary}={
component.name=简单字典,
组件id=0,
服务id=51,
service.bundleid=7,
服务范围=捆绑
}
捆绑注册:“foo.bar.services_1.0.0.qualifier[7]
“没有使用服务的捆绑包。”
除非您说
servicefactory=“true”
,否则它是一个单例。DS将始终使用SerivceFactory来注册组件的服务。这允许实际的组件创建和激活是延迟的。因此,您将永远不会在注册的服务上看到service.scope=singleton
对于DS 1.3,
servicefactory
将被scope
取代,但上面关于DS始终使用servicefactory的说法仍然正确。最新版本的apache felix是否支持DS 1.3?正如我所见。但是我找不到关于如何使用作用域的信息。
<?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>