【发布时间】:2015-10-09 16:30:04
【问题描述】:
我有一个捆绑包,它使用一个配置文件 org.jemz.karaf.tutorial.hello.service.config.cfg 和一个属性:
org.jemz.karaf.tutorial.hello.service.msg="I am a HelloServiceConfig!!"
我使用 ConfigAdmin 的蓝图是这样的:
<cm:property-placeholder persistent-id="org.jemz.karaf.tutorial.hello.service.config" update-strategy="reload" >
<cm:default-properties>
<cm:property name="org.jemz.karaf.tutorial.hello.service.msg" value="Hello World!"/>
</cm:default-properties>
</cm:property-placeholder>
<bean id="hello-service-config"
class="org.jemz.karaf.tutorial.hello.service.config.internal.HelloServiceConfig"
init-method="startup"
destroy-method="shutdown">
<property name="helloServiceConfiguration">
<props>
<prop key="org.jemz.karaf.tutorial.hello.service.msg" value="${org.jemz.karaf.tutorial.hello.service.msg}"/>
</props>
</property>
</bean>
<service ref="hello-service-config" interface="org.jemz.karaf.tutorial.hello.service.IHelloService" />
只要我可以更改属性的值并且捆绑包会自动更新该属性,它就可以正常工作。
我想知道是否有任何方法可以在我的配置文件中添加新属性而无需更改蓝图(这涉及再次编译/打包)。当然我的包应该准备好处理新属性。
不确定这在 OSGi 中是否有意义。谁能告诉我如何将新属性动态添加到现有配置文件并使其在 ConfigAdmin 中可用?
【问题讨论】:
标签: osgi apache-karaf karaf blueprint-osgi