簡體   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