lburgazzoli commented on a change in pull request #119: chore: replace custom
properties binding implementation with PropertyBindingSupport from camel support
URL: https://github.com/apache/camel-quarkus/pull/119#discussion_r312242553
##########
File path:
extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/runtime/support/FastCamelContext.java
##########
@@ -331,26 +331,27 @@ protected ReactiveExecutor createReactiveExecutor() {
return new ReactiveExecutorResolver().resolve(this);
}
- public AsyncProcessor createMulticast(Collection<Processor> processors,
ExecutorService executor,
- boolean shutdownExecutorService) {
- return new MulticastProcessor(this, processors, (AggregationStrategy)
null, true, executor, shutdownExecutorService,
- false, false, 0L, (Processor) null, false, false);
+ @Override
+ public AsyncProcessor createMulticast(Collection<Processor> processors,
ExecutorService executor, boolean shutdownExecutorService) {
+ return new MulticastProcessor(this, processors, null, true, executor,
shutdownExecutorService,
+ false, false, 0L, null, false, false);
}
+ @SuppressWarnings("unchecked")
protected <T> T resolve(Class<T> clazz, String type, String name,
CamelContext context) {
T result = context.getRegistry().lookupByNameAndType(name, clazz);
- if (result instanceof CamelContextAware) {
- ((CamelContextAware) result).setCamelContext(context);
- }
- PropertiesComponent comp = getPropertiesComponent();
- if (comp instanceof
org.apache.camel.component.properties.PropertiesComponent) {
- Properties props =
((org.apache.camel.component.properties.PropertiesComponent)
comp).getInitialProperties();
- if (props != null) {
- String pfx = CamelRuntime.PFX_CAMEL + type + "." + name;
- log.debug("Binding {} {} with prefix {}", type, name, pfx);
- RuntimeSupport.bindProperties(this, props, result, pfx);
- }
+
+ CamelContextAware.trySetCamelContext(result, context);
+
+ Properties props = getPropertiesComponent().loadProperties();
+ if (props != null && !props.isEmpty()) {
+ PropertyBindingSupport.bindProperties(
+ this,
+ result,
+ new HashMap<String, Object>((Map) props),
Review comment:
@ppalaga
ah no sorry, now I recall the reason:
`PropertyBindingSupport.bindProperties` consumes the map so it removes every
element that has been bound to the target leading to unexpected results.
pushed a new version that restores hash map, I need to work on the camel
side to have a better solution but in the meantime I would merge the PR as it
is because `PropertyBindingSupport` supports OGNL like property setting and it
quite needed in particular for camel-k.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services