Discussion:
when karaf.home in the cm property of blueprint configuration
XiLai Dai
2012-07-30 06:16:12 UTC
Permalink
Hi,

In the blueprint xml of the bundle we have <cm:property-placeholder> and <bean> configuration like this:
<cm:property-placeholder persistent-id="x.y.z" update-strategy="reload">
<cm:default-properties>
<cm:property name="myapp.home" value="${karaf.home}/myapp" />
</cm:default-properties>
</cm:property-placeholder>

<bean id="myServer" class="x.y.zImpl">
<property name="myHome" value="${myapp.home}" />
</bean>

And we have a <feature> definition like this:
<feature name='my-feature' version='0.1-SNAPSHOT'>
<configfile finalname="/etc/x.y.z.cfg">mvn:x.y.z/myapp/0.1-SNAPSHOT/cfg/x.y.z</configfile>
<bundle>mvn:x.y.z/myapp/0.1-SNAPSHOT</bundle>
</feature>

When installed this feature into karaf container at first time, ${karaf.home} will not be replaced with the actual path like : /home/karaf2.2.8. Then, after execute refresh <bundle_id> or restart container, ${karaf.home} will be raplaced correctly. Does anyone know possible solution/workaround how to make this happen at the first time of feature installation?

Thanks in advance!
Xilai
Jean-Baptiste Onofré
2012-07-30 06:20:07 UTC
Permalink
Hi XiLai,

${karaf.home} is a System property. To be able to replace System
properties in Blueprint, you have to use blueprint-ext.

So something like:

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"

xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0">

<ext:property-placeholder />

<bean id="myBean" class="...">
<property name="home" value="${karaf.home}"/>
</bean>

</blueprint>

You can mix cm and ext together to use both System properties and
ConfigAdmin properties.

Regards
JB
Post by XiLai Dai
Hi,
In the blueprint xml of the bundle we have <cm:property-placeholder> and
<cm:property-placeholder persistent-id="x.y.z"
update-strategy="reload">
<cm:default-properties>
<cm:property name="myapp.home" value="${karaf.home}/myapp" />
</cm:default-properties>
</cm:property-placeholder>
<bean id="myServer" class="x.y.zImpl">
<property name="myHome" value="${myapp.home}" />
</bean>
<feature name='my-feature' version='0.1-SNAPSHOT'>
<configfile
finalname="/etc/x.y.z.cfg">mvn:x.y.z/myapp/0.1-SNAPSHOT/cfg/x.y.z</configfile>
<bundle>mvn:x.y.z/myapp/0.1-SNAPSHOT</bundle>
</feature>
When installed this feature into karaf container at first time,
/home/karaf2.2.8. Then, after execute refresh <bundle_id> or restart
container, ${karaf.home} will be raplaced correctly. Does anyone know
possible solution/workaround how to make this happen at the first time
of feature installation?
Thanks in advance!
Xilai
--
Jean-Baptiste Onofré
jbonofre-1oDqGaOF3Lkdnm+***@public.gmane.org
http://blog.nanthrax.net
Talend - http://www.talend.com
Loading...