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

Apache camel Camel:在CXF端点配置中为布尔属性使用属性占位符,apache-camel,blueprint-osgi,Apache Camel,Blueprint Osgi,我喜欢在CXF端点定义中为布尔属性使用属性占位符。我在中阅读了有关占位符前缀的文档,但ik无法确定如何在端点配置中应用它们。字符串占位符工作正常。在下面的示例中,我使用布尔属性${ws-logging},XML不会验证。如何在CXF端点配置中为布尔属性使用属性占位符 <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-inst

我喜欢在CXF端点定义中为布尔属性使用属性占位符。我在中阅读了有关占位符前缀的文档,但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>

我认为您缺少一个模式引用和名称空间: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>

我认为您缺少一个模式引用和名称空间: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>


尝试了您的解决方案,但结果为阴性。看起来布尔类型属性仅接受实际布尔值,在上下文之外定义时不接受占位符。因此,仅接受值true、false、0或1。尝试解决方案时结果为负值。看起来布尔类型属性仅接受实际布尔值,在上下文之外定义时不接受占位符。因此,只接受值true、false、0或1。