Class CamelPropertiesHelper
java.lang.Object
org.apache.camel.spring.boot.util.CamelPropertiesHelper
To help configuring Camel properties that have been defined in Spring Boot configuration files.
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
copyProperties
(org.apache.camel.CamelContext camelContext, Object source, Object target) getNonNullProperties
(org.apache.camel.CamelContext camelContext, Object target) Gets all the non-null properties from the given object,static boolean
setCamelProperties
(org.apache.camel.CamelContext context, Object target, Map<String, Object> properties, boolean failIfNotSet) Sets the properties on the target bean.
-
Method Details
-
copyProperties
-
setCamelProperties
public static boolean setCamelProperties(org.apache.camel.CamelContext context, Object target, Map<String, Object> properties, boolean failIfNotSet) Sets the properties on the target bean. This method usesPropertyBindingSupport
and therefore offers its capabilities such as:- property placeholders - Keys and values using Camels property placeholder will be resolved
- nested - Properties can be nested using the dot syntax (OGNL and builder pattern using with as prefix), eg foo.bar=123
- map - Properties can lookup in Map's using map syntax, eg foo[bar] where foo is the name of the property that is a Map instance, and bar is the name of the key.
- list - Properties can refer or add to in List's using list syntax, eg foo[0] where foo is the name of the property that is a List instance, and 0 is the index. To refer to the last element, then use last as key.
- reference by bean id - Values can refer to other beans in the registry by prefixing with with # or #bean: eg #myBean or #bean:myBean
- reference by type - Values can refer to singleton beans by their type in the registry by prefixing with #type: syntax, eg #type:com.foo.MyClassType
- autowire by type - Values can refer to singleton beans by auto wiring by setting the value to #autowired
- reference new class - Values can refer to creating new beans by their class name by prefixing with #class, eg #class:com.foo.MyClassType
- value as lookup - The value is used as-is (eg like #value) to lookup in the Registry if there is a bean then its set on the target
- Parameters:
context
- the CamelContexttarget
- the target beanproperties
- the propertiesfailIfNotSet
- whether to fail if an option either does not exists on the target bean or if the option cannot be due no suitable setter methods with the given type- Returns:
- true if at least one option was configured
- Throws:
IllegalArgumentException
- is thrown if an option cannot be configured on the bean because there is no suitable setter method and failOnNoSet is true.
-
getNonNullProperties
public static Map<String,Object> getNonNullProperties(org.apache.camel.CamelContext camelContext, Object target) Gets all the non-null properties from the given object,- Parameters:
camelContext
- the camel contexttarget
- the object- Returns:
- the properties (non-null only)
-