在camel路由时,使用blueprint属性占位器。
camel支持blueprint,blueprint提供属性占位器服务。
camel支持“覆盖配置”公约,所以我们得在xml文档中定义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 http://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 for this test -->
- <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>
说明:缺省情况下,camel会探测和使用OSGI blueprint的属性占位器服务。我们可以通过设置属性:useBlueprintPropertyResolver=false(在<camelContext>中设置)来制止这种默认行为。