3

I'm building some camel routes deployed in OSGi (JBoss Fuse)

I'm reading my properties file using this:

  <ext:property-placeholder id="propiedades">
    <ext:location>file:/C:/TestBed/sucursal.propiedades</ext:location>
  </ext:property-placeholder>

But now I want change "file:/C:TestBed/" for some placeholder with some path (like KARAF_ETC). I know this enviroment variable exists because when I use it in the route, it works ok

    from(URI_IN)
    .log("{{env:KARAF_ETC}}") //Output is: C:\jboss-fuse-6.2.0.redhat-133\bin\..\etc
    .to(URI_OUT);

So, I want to do something like:

  <ext:property-placeholder id="propiedades">
    <ext:location>file:{{env:KARAF_ETC}}/sucursal.propiedades</ext:location>
  </ext:property-placeholder>

But does not work.

Property placeholder is kinda tricky, so I tried with file:/{{env:KARAF_ETC}}, file:/{{KARAF_ETC}}, file:${KARAF_ETC} and more combinations but no one works (but some of them throw differents errors).

What is the correct sintaxis to get the enviroments variables in blueprint?

Desenfoque
  • 804
  • 2
  • 11
  • 30
  • When using `ext` you are using the osgi namespace and its pure OSGi placeholder. So look at the karaf/osgi documentation. The {{ }} syntax is from Apache Camel. – Claus Ibsen Aug 04 '15 at 07:51
  • Thanks... this combination camel/karaf/osgi and a lot of other in jboss is kinda confusing. – Desenfoque Aug 04 '15 at 19:45

3 Answers3

3

Have you tried this?

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

   <!-- Load system property --> 
   <ext:property-placeholder /> 

   <bean ...><property name="foobar" value="${foobar}"/></bean> 

</blueprint> 

I've found it here: http://karaf.922171.n3.nabble.com/Get-environment-variable-td4025807.html

Jorge Martinez
  • 1,221
  • 8
  • 16
  • Thanks, your answer help to me. But for system environment variables I used value like this ${env:foobar} – Gennady Jun 05 '20 at 11:46
1

You can access to karaf enviroment vars using karaf.[something], but in camel you can access using KARAF_[SOMETHING]

Thanks Claus Ibsen for pointing the differences in the scopes...

nevertheless, this camel/osgi thing is really weird...It is hard to tame...

Desenfoque
  • 804
  • 2
  • 11
  • 30
1

This works for me:

<propertyPlaceholder id="properties" location="file:${karaf.home}/etc/sucursal.properties"/>
Timo Riikonen
  • 477
  • 5
  • 8