繁体   English   中英

Camel Property-Placeholder:无法使用嵌套属性配置`camel:sslContextParameters`

[英]Camel Property-Placeholder: Not able to configure `camel:sslContextParameters` with nested properties

我使用Camel-HTTP4 2.10.4组件从我的应用程序调用远程REST服务。 此通信需要SSL配置。 我用resourcepassword硬编码值成功测试了我的配置。

现在我需要使用camel的Property-Placeholder来配置相同的内容。 我在spring配置中使用嵌套属性。 例如:

${${env:${default.fallback.env}}.path.to.keystore} 

我跟着使用PropertyPlaceholder并定义了

<bean id="bridgePropertyPlaceholder" class="org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer">
    <property name="locations">
        <list>
            <ref bean="confgPath1" />
            <ref bean="configPath2" />
        </list>
    </property>
</bean>

和sslContextParameters如下

<camel:sslContextParameters id="sslContextParameters">
    <camel:trustManagers>
        <camel:keyStore resource="{{{{default.fallback.env}}.keystore.file}}"
            password="{{{{default.fallback.env}}.keystore.password}}" />
    </camel:trustManagers>
    <camel:keyManagers keyPassword="{{{{default.fallback.env}}.keystore.password}}">
        <camel:keyStore resource="{{{{default.fallback.env}}.keystore.file}}"
            password="{{{{default.fallback.env}}.keystore.password}}" />
    </camel:keyManagers>
    <camel:clientParameters>
        <camel:cipherSuitesFilter>
            <camel:include>.*</camel:include>
        </camel:cipherSuitesFilter>
    </camel:clientParameters>
</camel:sslContextParameters>

我的应用程序在启动时成功加载了spring上下文。 但是在点击端点后我得到错误:

Failed to resolve endpoint <<My remote service URL>> due to: Error parsing property value: {{{{default.fallback.env}}.keystore.password}}.

我能够使用Camel的属性占位符来获得简单的属性。 对于前者

{{default.fallback.env}}

但是,当我尝试使用嵌套属性时,它给出了我上面指定的错误。 帮我找出解决这个问题的正确方法。

当前的camel属性组件不支持嵌套属性,所以我只为它填充一个JIRA

由于Camel属性首先不支持嵌套属性,因此您可以定义这样的属性文件,并从系统属性设置环境并使用{{someproperty}}来引用属性。

someproperty={{{{environment}}.someproperty}}

# LOCAL SERVER
junit.someproperty=junit

# LOCAL SERVER
local.someproperty=local

# TEST
test.someproperty=test

# PROD
prod.someproperty=prod

我只是用Spring方式创建了Camel SSL配置:

  <bean id="sslContextParameters" class="org.apache.camel.util.jsse.SSLContextParameters">
    <property name="keyManagers">
      <bean class="org.apache.camel.util.jsse.KeyManagersParameters">
        <property name="keyPassword" value="${dsi.key.password}" />
        <property name="keyStore">
          <bean class="org.apache.camel.util.jsse.KeyStoreParameters">
            <property name="resource" value="${dsi.keystore.file}" />
            <property name="type" value="JKS" />
            <property name="password" value="${dsi.keystore.password}" />
            <property name="camelContext" ref="camelContext" />
          </bean>
        </property>
        <property name="camelContext" ref="camelContext" />
      </bean>
    </property>
    <property name="camelContext" ref="camelContext" />
  </bean>

我相信使用Spring的属性解析器,您可以获得更多,而且您不需要使用自定义桥接解析器。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM