Property endpoints allow you to resolve the address for an endpoint using a property placeholder. Property placeholders can be created using a properties file, OSGi properties, the OSGi registry, Spring beans, or as part of the route definition.
The property placeholder is typically used when:
looking up or creating endpoints
looking up beans in the Registry
using Blueprint's PropertyPlaceholder
with Apache Camel's Properties
component
using property placeholder in many of Spring's Camel xml
tags, such as package
,
packageScan
,
contextScan
,
jmxAgent
,
endpoint
,
routeBuilder
,
proxy
, and others
The URI format for a property endpoint is:
properties:key
[?options
]
Where key
is the key for the property
to lookup.
Table 65, “Properties options” describes the options for a property endpoint.
Table 65. Properties options
Name | Default | Description |
---|---|---|
cache
|
true
| Specifies whether to cache loaded properties. |
locations
| Specifies a list of locations from which to load
properties. A comma separated list is use to specify
multiple locations. This option will override any
locations specified in the
camelContext or the configuration. | |
ignoreMissingLocation
|
false
| Apache Camel 2.10: Specifies whether to silently ignore a resource that cannot be located, such as a properties file that cannot be found. |
propertyPrefix
|
null
| Apache Camel 2.9: Optional prefix prepended to property names before resolution. |
propertySuffix
|
null
| Apache Camel 2.9: Optional suffix appended to property names before resolution. |
fallBackToUnaugmentedProperty
|
true
| Apache Camel 2.9:
When true , first attempt to
resolve property name augmented with
propertyPrefix or
propertySuffix before falling
back to the specified unaugmented name. Otherwise,
search only for the augmented property name. |
prefixToken
|
{{
| Apache Camel 2.9: Specifies the token that indicates the beginning of a property token. |
suffixToken
|
}}
| Apache Camel 2.9: Specifies the token that indicates the end of a property token. |
![]() | Note |
---|---|
You can resolve a property from any Java code by using the
|
Available as of Apache Camel 2.10.
The Spring Framework does not allow third-party frameworks, such
as Apache Camel, to seamlessly hook into the Spring property placeholder
mechanism. However, you can easily bridge Spring and Camel by
declaring a Spring bean with the type
org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer
,
which is a Spring
org.springframework.beans.factory.config.PropertyPlaceholderConfigurer
type.
To bridge Spring and Camel you must define a single bean as shown here:
<!-- bridge spring property placeholder with Camel --> <!-- you must NOT use the <context:property-placeholder at the same time, only this bridge bean --> <bean id="bridgePropertyPlaceholder" class="org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer"> <property name="location" value="classpath:org/apache/camel/component/properties/cheese.properties"/> </bean>
![]() | Important |
---|---|
You must not use the spring
|
After declaring this bean, you can define property placeholders using either the Spring style or the Camel style within the <camelContext> tag as shown here:
<!-- a bean that uses Spring property placeholder --> <!-- the ${hi} is a spring property placeholder --> <bean id="hello" class="org.apache.camel.component.properties.HelloBean"> <property name="greeting" value="${hi}"/> </bean> <camelContext xmlns="http://camel.apache.org/schema/spring"> <!-- in this route we use Camels property placeholder {{ }} style --> <route> <from uri="direct:{{cool.bar}}"/> <bean ref="hello"/> <to uri="{{cool.end}}"/> </route> </camelContext>
Notice how the hello bean uses pure Spring property placeholders via the ${ } notation. And in the Camel routes, we use the Camel placeholder notation with {{ }}.