...
- lookup or creating endpoints
- lookup of beans in the Registry
- additional supported in Spring XML (see below in examples)
- using Blueprint PropertyPlaceholder with Camel Properties component
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.
...
Wiki Markup |
---|
{snippet:id=e1|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/component/properties/OptionalPropertiesDslTest.java} |
Using Blueprint property placeholder with Camel routes
Available as of Camel 2.7
Camel supports Blueprint which also offers a property placeholder service. Camel supports convention over configuration, so all you have to do is to define the OSGi Blueprint property placeholder in the XML file as shown below:
Wiki Markup |
---|
{snippet:id=e1|lang=xml|title=Using OSGi blueprint property placeholders in Camel routes|url=camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/blueprint/blueprint-17.xml} |
By default Camel detects and uses OSGi blueprint property placeholder service. You can disable this by setting the attribute useBlueprintPropertyResolver
to false on the <camelContext>
definition.
Info | ||
---|---|---|
| ||
Notice how we can use the Camel syntax for placeholders {{ }} in the Camel route, which will lookup the value from OSGi blueprint. |
You can also explicit refer to a specific OSGi blueprint property placeholder by its id. For that you need to use the Camel's <propertyPlaceholder> as shown in the example below:
Wiki Markup |
---|
{snippet:id=e1|lang=xml|title=Explicit referring to a OSGi blueprint placeholder in Camel|url=camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/blueprint/blueprint-16.xml} |
Notice how we use the blueprint
scheme to refer to the OSGi blueprint placeholder by its id. This allows you to mix and match, for example you can also have additional schemes in the location. For example to load a file from the classpath you can do:
Code Block |
---|
location="blueprint:myblueprint.placeholder,classpath:myproperties.properties"
|
Each location is separated by comma.