Camel-blueprint

来源:互联网 发布:js防水涂料施工图集 编辑:程序博客网 时间:2024/06/05 05:30

在camel路由时,使用blueprint属性占位器。

camel支持blueprint,blueprint提供属性占位器服务。

camel支持“覆盖配置”公约,所以我们得在xml文档中定义blueprint属性占位器。

样例:

  1. <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
  2. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
  4. xsi:schemaLocation="
  5. http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/
  6. blueprint/v1.0.0/blueprint.xsd">
  7. <!-- OSGI blueprint property placeholder -->
  8. <cm:property-placeholder id="myblueprint.placeholder"
  9. persistent-id="camel.blueprint">
  10. <!-- list some properties for this test -->
  11. <cm:default-properties>
  12. <cm:property name="result" value="mock:result"/>
  13. </cm:default-properties>
  14. </cm:property-placeholder>
  15. <camelContext xmlns="http://camel.apache.org/schema/blueprint">
  16. <!-- in the route we can use {{ }} placeholders which will lookup in blueprint
  17. as Camel will auto detect the OSGi blueprint property placeholder and use
  18. it -->
  19. <route>
  20. <from uri="direct:start"/>
  21. <to uri="mock:foo"/>
  22. <to uri="{{result}}"/>
  23. </route>
  24. </camelContext>
  25. </blueprint>

说明:缺省情况下,camel会探测和使用OSGI blueprint的属性占位器服务。我们可以通过设置属性:useBlueprintPropertyResolver=false(在<camelContext>中设置)来制止这种默认行为。