263.17. 使用带有 Camel 路由的 Blueprint 属性占位符

可作为 Camel 2.7 提供

Camel 支持蓝图还提供属性占位符服务。Camel 支持有关配置的惯例,因此您必须做的一点是定义 XML 文件中的 OSGi Blueprint 属性占位符,如下所示:

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

    <!-- OSGI blueprint property placeholder -->
    <cm:property-placeholder id="myblueprint.placeholder" persistent-id="camel.blueprint">
        <!-- list some properties as needed -->
        <cm:default-properties>
            <cm:property name="result" value="mock:result"/>
        </cm:default-properties>
    </cm:property-placeholder>

    <camelContext xmlns="http://camel.apache.org/schema/blueprint">
        <!-- in the route we can use {{ }} placeholders which will lookup in blueprint
             as Camel will auto detect the OSGi blueprint property placeholder and use it -->
        <route>
            <from uri="direct:start"/>
            <to uri="mock:foo"/>
            <to uri="{{result}}"/>
        </route>
    </camelContext>
</blueprint>

263.17.1. 在 Camel 路由中使用 OSGi 蓝图属性占位符

默认情况下,Camel 会检测并使用 OSGi 蓝图属性占位符服务。您可以通过在 < camelContext > 定义中将属性 useBlueprintPropertyResolver 设置为 false 来禁用此功能。