Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Camel now provides a new PropertiesComponent in camel-core which allows you to use property placeholders when defining Camel Endpoint URIs.
This works much like you would do if using Spring's <property-placeholder> tag. However Spring have a limitation which prevents 3rd party frameworks to leverage Spring property placeholders to the fullest. See more at How do I use Spring Property Placeholder with Camel XML.

The property placeholder is generally in use when doing:

  • lookup or creating endpoints
  • lookup of beans in the Registry
  • additional supported in Spring XML (see below in examples)

Syntax

The syntax to use Camel's property placeholder is to use #{key} for example #{file.uri} where file.uri is the property key.
You can use property placeholders in parts of the endpoint URI's which for example you can use placeholders for parameters in the URIs.

...

Code Block
// bar.properties
bar.quote=Beer tastes good

// route
from("direct:start")
    .transform().simple("Hi ${body}. ${properties:com/mycompany/bar.properties:bar.quote}.");

Additional property placeholder supported in Spring XML

The property placeholders is also supported in many of the Camel Spring XML tags such as {{<package>, <packageScan>, <jmxAgent>, <endpoint>, <routeBuilder>, <proxy> and the others.

The example below has property placeholder in the <jmxAgent> tag:

Wiki Markup
{snippet:id=e1|lang=xml|url=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/jmxConfigUsingProperties.xml}

You can also define property placeholders in the various attributes on the <camelContext> tag such as trace as shown here:

Wiki Markup
{snippet:id=e1|lang=xml|url=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringTraceUsingPropertyTest-context.xml}

Unit tests

See the unit tests in camel-core and camel-spring

...