Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save caisback/0b3d62b37866284347055ddbb7219ccf to your computer and use it in GitHub Desktop.

Select an option

Save caisback/0b3d62b37866284347055ddbb7219ccf to your computer and use it in GitHub Desktop.
Apache Camel Blueprint DSL - Adding reference to property file (.cfg/.properties) as blueprint property placeholders

Took me 8 days to figured it out :(

Reference: https://camel.apache.org/manual/latest/using-propertyplaceholder.html#UsingPropertyPlaceholder-Usinga.cfgor.propertiesFileForBlueprintPropertyPlaceholders

For this example, we assumed the we are using trial.blueprint.cfg file which is saved at the [FUSE_FOLDER]/etc/trial.blueprint.cfg

  • [FUSE_FOLDER]/etc/trial.blueprint.cfg content;

      in.server.host=//localhost
      in.server.port=9002
      in.server.protocol=http
      in.server.uri.pattern=employee
      out.server.host=//localhost
      out.server.port=9002
      out.server.protocol=http
      out.server.uri.pattern=external/callmoko/api
    
  • Open blueprint.xml on Source tab

  • We need to add to entries to recognized our property file

    1. Adding xmlns:cm to the blueprint tag
    • From:
    <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd                            http://camel.apache.org/schema/blueprint https://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
    
    • To:
    <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
    xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd                            http://camel.apache.org/schema/blueprint https://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
    
    1. Adding the actual code to enable our property file, add below code above the <camelContext id=" tag
    <!-- blueprint property placeholders, that will use etc/stuff.cfg as the properties file -->
    <cm:property-placeholder persistent-id="trial.blueprint" update-strategy="reload"/>
    
    1. The whole blueprint.xml code example would be;
    <?xml version="1.0" encoding="UTF-8"?>
    <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
      xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd                            http://camel.apache.org/schema/blueprint https://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
        <!-- blueprint property placeholders, that will use etc/trial.blueprint.cfg as the properties file -->
        <cm:property-placeholder persistent-id="trial.blueprint" update-strategy="reload"/>
        <camelContext id="_context1" xmlns="http://camel.apache.org/schema/blueprint">
            <route id="_route1"/>
        </camelContext>
    </blueprint>
    
  • To use, {{in.server.host}} or {{out.server.protocol}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment