在OSGI蓝图中读取环境变量 [英] Reading enviroment variable in osgi blueprint
问题描述
我正在构建一些部署在OSGi(JBoss保险丝)中的骆驼路线
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>
但是现在我想更改带有路径的占位符的"file:/C:TestBed/"(例如KARAF_ETC).我知道此环境变量存在是因为当我在路由中使用它时,它可以正常工作
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>
但是不起作用.
属性占位符有点棘手,因此我尝试使用file:/{{env:KARAF_ETC}},file:/{{KARAF_ETC}},file:$ {KARAF_ETC}和更多组合,但没有一个可用(但有些他们会引发差异错误.
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?
推荐答案
您尝试过吗?
<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>
我在这里找到了它: http://karaf .922171.n3.nabble.com/Get-environment-variable-td4025807.html
这篇关于在OSGI蓝图中读取环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!