Camel:在CXF端点配置中使用属性占位符作为布尔属性

时间:2015-10-20 14:27:57

标签: apache-camel blueprint-osgi

我喜欢在我的CXF端点定义中使用属性占位符作为布尔属性。我已经在http://camel.apache.org/using-propertyplaceholder.html中阅读了有关占位符前缀的文档,但是ik无法弄清楚如何在我的端点配置中应用它们。字符串占位符工作正常。在下面的示例中,我使用布尔属性$ {ws-logging},并且XML不会验证。如何在CXF端点配置中使用属性占位符作为布尔属性?

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:prop="http://camel.apache.org/schema/placeholder"
   xmlns:camel-cxf="http://camel.apache.org/schema/blueprint/cxf"
   xsi:schemaLocation="
   http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
   http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">

  <property-placeholder persistent-id="test.config" id="test.config.placeholder" xmlns="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0">
    <default-properties>
        <property name="ws-logging" value="true"/>
    </default-properties>
  </property-placeholder>

  <camel-cxf:cxfEndpoint id="update"
    address="http://someaddress"
    endpointName="ssp:someendpoint"
    serviceName="ssp:someservice"
    wsdlURL="http://someaddress/wsdl?targetURI=sometargeturi"
    xmlns:ssp="somenamespace"
    loggingFeatureEnabled="${ws-logging}">
    <camel-cxf:properties>
        <entry key="dataFormat" value="PAYLOAD"/>
    </camel-cxf:properties>
  </camel-cxf:cxfEndpoint>

  <camelContext xmlns="http://camel.apache.org/schema/blueprint">
    <route id="timerToLog">
      <from uri="timer:foo?period=5000"/>
      <to uri="mock:result"/>
    </route>
  </camelContext>
</blueprint>

1 个答案:

答案 0 :(得分:0)

我相信您缺少架构引用和命名空间:blueprint-cm。尝试添加它,如下例所示。

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:camel-cxf="http://camel.apache.org/schema/cxf"
       xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
       xsi:schemaLocation="http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd
  http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.0.0.xsd
   http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
   http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">

    <cm:property-placeholder persistent-id="com.example">
        <cm:default-properties>
            <property name="ws-logging" value="true"/>
        </cm:default-properties>
    </cm:property-placeholder>

</blueprint>