javaosgiosgi-bundleeclipse-virgo

Can i create separate properties file for Virgo OSGi bundle?


I have Tomcat Virgo Server. I am deploying couple of OSGi bundles. I want to expose settings through properties, so the service within bundle can read it though Java System.getProperty(String) API. Is it possible ?


Solution

  • You should use OSGis ConfigurationAdmin for doing this. You can deploy your properties files into [VIRGO_HOME]/pickup and then consume the properties from ConfigurationAdmin Service over the configurations pid. Virgo recognizes your properties files in its pickup folder and automatically exposes them over the 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.

    And if you are using Spring/Blueprint you can stick to the property placeholder as you are used to. Just use the osgix namespace handlers and do something like this:

    <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. For further reference have a look at Gemini Blueprint Documentation as well [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

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