简体   繁体   English

我可以为处女座OSGi捆绑包创建单独的属性文件吗?

[英]Can i create separate properties file for Virgo OSGi bundle?

I have Tomcat Virgo Server. 我有Tomcat处女座服务器。 I am deploying couple of OSGi bundles. 我正在部署几个OSGi捆绑包。 I want to expose settings through properties, so the service within bundle can read it though Java System.getProperty(String) API. 我想通过属性公开设置,因此捆绑包中的服务可以通过Java System.getProperty(String) API读取它。 Is it possible ? 可能吗 ?

You should use OSGis ConfigurationAdmin for doing this. 您应该使用OSGis ConfigurationAdmin来执行此操作。 You can deploy your properties files into [VIRGO_HOME]/pickup and then consume the properties from ConfigurationAdmin Service over the configurations pid . 您可以将属性文件部署到[VIRGO_HOME] / pickup中 ,然后通过Configuration pid使用 ConfigurationAdmin Service中的属性。 Virgo recognizes your properties files in its pickup folder and automatically exposes them over the ConfigurationAdmin Service. 处女座会在其拾取文件夹中识别您的属性文件,并通过ConfigurationAdmin Service自动公开它们。 You could also list your properties files in a plan file if you use plans to deploy your bundles as an application. 如果使用计划将捆绑软件部署为应用程序,则还可以在计划文件中列出属性文件。

Please refer to the official documentation on the Virgo Documentation Page [1] for further details. 有关更多详细信息,请参考处女座文档页面[1]上的官方文档。

And if you are using Spring/Blueprint you can stick to the property placeholder as you are used to. 而且,如果您使用的是Spring / Blueprint,则可以像往常一样坚持使用属性占位符。 Just use the osgix namespace handlers and do something like this: 只需使用osgix命名空间处理程序,然后执行以下操作:

<osgix:cm-properties id="cmProps" persistent-id="com.xyz.myapp">
  <prop key="host">localhost</prop>
</osgix:cm-properties>

As by default the persistent-id or pid is the name of your properties file. 默认情况下, persistent-idpid是属性文件的名称。 For further reference have a look at Gemini Blueprint Documentation as well [2]. 有关更多参考,请参见Gemini蓝图文档[2]。

[1] http://www.eclipse.org/virgo/documentation/virgo-documentation-3.6.4.RELEASE/docs/virgo-programmer-guide/htmlsingle/virgo-programmer-guide.html#developing-applications-configuration-artifacts [1] http://www.eclipse.org/virgo/documentation/virgo-documentation-3.6.4.RELEASE/docs/virgo-programmer-guide/htmlsingle/virgo-programmer-guide.html#developing-applications-configuration -工件

[2] http://www.eclipse.org/gemini/blueprint/documentation/reference/1.0.2.RELEASE/html/compendium.html#compendium:cm [2] http://www.eclipse.org/gemini/blueprint/documentation/reference/1.0.2.RELEASE/html/compendium.html#compendium:cm

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM