Loading XML configuration files in OSGi
I would like to load configuration data for a bundle in the OSGi environment (FUSE ESB 4.3.1). Spring DM provides abstraction of the Configuration Admin and allows to read the properties files in etc folder.
What I want to achieve is to load an XML file, since I need a configuration of greater complexity than simple properties file. An example could be:
<measurements>
<measurementsList name="First">
<measurement>First-1</measurement>
<measurement>First-2</measurement>
</measurementsList>
<measurementsList name="Second">
<measurement>Second-1</measurement>
<measurement>Second-2</measurement>
<measurement>Second-3</measurement>
<measurement>Second-4</measurement>
</measurementsList>
...
</measurements>
and then to parse it to get a Map> where the key is the name of measurementsList and value is the list of the measurement names.
How can I do it in OSGi? Where do I need to place my file for it to be accessible from a certain bundle?
Best wishes, Stefan开发者_高级运维
Save the configuration in a separate XML file. Pass the file name or the URL as a string value in a property managed by the Configuration Admin. In the configurable object, open the file and read/process the XML contents there.
I would place the XML file in etc folder under servicemix, and pass the relative path in the spring DM config admin.
<bean ...>
<osgix:managed-properties persistent-id="com.sample.your.config.location.path" />
<property name="config-path" value="etc/config.xml"/>
</bean>
relative path works relative off servicemix directory
精彩评论