I am using cm:property-placeholder in blueprint to load config file:
<!-- External configuration -->
<cm:property-placeholder persistent-id="mubyndle" update-strategy="reload">
<cm:default-properties>
<cm:property name="schemaValidation" value="false"/>
</cm:default-properties>
</cm:property-placeholder>
<bean id="myBean" class="com.mybean">
<property name="abc" value="${abc}" />
</bean>
I can set values into beans, like ${abc}.
How can I access any other property of the config from java?
I am planning to add list of properties: prop1=11 prop2=22 ... propn=nn
I cannot add all in blueprint as the number varies.
Thank you, Viktor
Add reference to ConfigurationAdmin service in blueprint:
<reference id="configAdmin" interface="org.osgi.service.cm.ConfigurationAdmin" />
Set it to bean:
<bean id="myBean" class="com.mybean">
<property name="abc" value="${abc}" />
<property name="configAdmin" ref="configAdmin" />
</bean>
In bean:
private ConfigurationAdmin configAdmin;
public void setConfigAdmin(ConfigurationAdmin configAdmin) throws IOException {
this.configAdmin = configAdmin;
System.out.println(configAdmin);
System.out.println(configAdmin.getConfiguration("any-persistent-id").getProperties());
}