This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch CAMEL-13947
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 9a86a6355876ca91a1f92e8aeac82c71bf0e6342
Author: Claus Ibsen <[email protected]>
AuthorDate: Thu Sep 26 06:25:54 2019 +0200

    CAMEL-13947: PropertiesComponent should be a static service and resolved 
like other similar features.
---
 .../component/properties/SpringPropertiesComponent3Test.xml      | 4 ++--
 .../camel/component/properties/SpringPropertiesComponentTest.xml | 4 ++--
 .../camel/test/spring/junit5/CamelSpringTestContextLoader.java   | 9 ++++-----
 .../camel/test/spring/CamelSpringActiveProfileTest-context.xml   | 2 +-
 .../apache/camel/test/spring/CamelSpringTestContextLoader.java   | 9 ++++-----
 .../camel/test/spring/CamelSpringActiveProfileTest-context.xml   | 2 +-
 components/readme.adoc                                           | 7 ++-----
 .../apache/camel/core/xml/AbstractCamelContextFactoryBean.java   | 7 +++++++
 .../org/apache/camel/main/DefaultConfigurationConfigurer.java    | 5 +++++
 9 files changed, 28 insertions(+), 21 deletions(-)

diff --git 
a/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertiesComponent3Test.xml
 
b/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertiesComponent3Test.xml
index 4bfd8bc..2bde5e2 100644
--- 
a/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertiesComponent3Test.xml
+++ 
b/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertiesComponent3Test.xml
@@ -31,12 +31,12 @@
 
         <route>
             <from uri="direct:start"/>
-            <to uri="properties:{{cool.end}}"/>
+            <to uri="{{cool.end}}"/>
         </route>
 
         <route>
             <from uri="direct:bar"/>
-            <to uri="properties:mock:{{cool.bar}}"/>
+            <to uri="mock:{{cool.bar}}"/>
         </route>
 
         <route>
diff --git 
a/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertiesComponentTest.xml
 
b/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertiesComponentTest.xml
index b07e314..fcbc478 100644
--- 
a/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertiesComponentTest.xml
+++ 
b/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertiesComponentTest.xml
@@ -35,12 +35,12 @@
 
         <route>
             <from uri="direct:start"/>
-            <to uri="properties:{{cool.end}}"/>
+            <to uri="{{cool.end}}"/>
         </route>
 
         <route>
             <from uri="direct:bar"/>
-            <to uri="properties:mock:{{cool.bar}}"/>
+            <to uri="mock:{{cool.bar}}"/>
         </route>
 
         <route>
diff --git 
a/components/camel-test-spring-junit5/src/main/java/org/apache/camel/test/spring/junit5/CamelSpringTestContextLoader.java
 
b/components/camel-test-spring-junit5/src/main/java/org/apache/camel/test/spring/junit5/CamelSpringTestContextLoader.java
index 32f0644..727d23c 100644
--- 
a/components/camel-test-spring-junit5/src/main/java/org/apache/camel/test/spring/junit5/CamelSpringTestContextLoader.java
+++ 
b/components/camel-test-spring-junit5/src/main/java/org/apache/camel/test/spring/junit5/CamelSpringTestContextLoader.java
@@ -484,11 +484,10 @@ public class CamelSpringTestContextLoader extends 
AbstractContextLoader {
         if (!extra.isEmpty()) {
             context.addBeanFactoryPostProcessor(beanFactory -> 
beanFactory.addBeanPostProcessor(new BeanPostProcessor() {
                 @Override
-                public Object postProcessAfterInitialization(Object bean, 
String beanName) {
-                    if (bean instanceof CamelContext) {
-                        CamelContext camelContext = (CamelContext) bean;
-                        PropertiesComponent pc = 
camelContext.getPropertiesComponent();
-                        LOG.info("Using {} properties to override any existing 
properties on the PropertiesComponent on CamelContext with name [{}].", 
extra.size(), camelContext.getName());
+                public Object postProcessBeforeInitialization(Object bean, 
String beanName) {
+                    if (bean instanceof PropertiesComponent) {
+                        PropertiesComponent pc = (PropertiesComponent) bean;
+                        LOG.info("Using {} properties to override any existing 
properties on the PropertiesComponent", extra.size());
                         pc.setOverrideProperties(extra);
                     }
                     return bean;
diff --git 
a/components/camel-test-spring-junit5/src/test/resources/org/apache/camel/test/spring/CamelSpringActiveProfileTest-context.xml
 
b/components/camel-test-spring-junit5/src/test/resources/org/apache/camel/test/spring/CamelSpringActiveProfileTest-context.xml
index d05491a..6f5a9e6 100644
--- 
a/components/camel-test-spring-junit5/src/test/resources/org/apache/camel/test/spring/CamelSpringActiveProfileTest-context.xml
+++ 
b/components/camel-test-spring-junit5/src/test/resources/org/apache/camel/test/spring/CamelSpringActiveProfileTest-context.xml
@@ -31,7 +31,7 @@
                        <transform>
                                <simple>Hello ${body}</simple>
                        </transform>
-                       <to uri="properties:{{cool.end}}" />
+                       <to uri="{{cool.end}}" />
                </route>
        </camelContext>
 
diff --git 
a/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoader.java
 
b/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoader.java
index 7c286b9..841d182 100644
--- 
a/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoader.java
+++ 
b/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoader.java
@@ -482,11 +482,10 @@ public class CamelSpringTestContextLoader extends 
AbstractContextLoader {
         if (!extra.isEmpty()) {
             context.addBeanFactoryPostProcessor(beanFactory -> 
beanFactory.addBeanPostProcessor(new BeanPostProcessor() {
                 @Override
-                public Object postProcessAfterInitialization(Object bean, 
String beanName) {
-                    if (bean instanceof CamelContext) {
-                        CamelContext camelContext = (CamelContext) bean;
-                        PropertiesComponent pc = 
camelContext.getPropertiesComponent();
-                        LOG.info("Using {} properties to override any existing 
properties on the PropertiesComponent on CamelContext with name [{}].", 
extra.size(), camelContext.getName());
+                public Object postProcessBeforeInitialization(Object bean, 
String beanName) {
+                    if (bean instanceof PropertiesComponent) {
+                        PropertiesComponent pc = (PropertiesComponent) bean;
+                        LOG.info("Using {} properties to override any existing 
properties on the PropertiesComponent", extra.size());
                         pc.setOverrideProperties(extra);
                     }
                     return bean;
diff --git 
a/components/camel-test-spring/src/test/resources/org/apache/camel/test/spring/CamelSpringActiveProfileTest-context.xml
 
b/components/camel-test-spring/src/test/resources/org/apache/camel/test/spring/CamelSpringActiveProfileTest-context.xml
index 8d264e1..bc3856e 100644
--- 
a/components/camel-test-spring/src/test/resources/org/apache/camel/test/spring/CamelSpringActiveProfileTest-context.xml
+++ 
b/components/camel-test-spring/src/test/resources/org/apache/camel/test/spring/CamelSpringActiveProfileTest-context.xml
@@ -30,7 +30,7 @@
       <transform>
         <simple>Hello ${body}</simple>
       </transform>
-      <to uri="properties:{{cool.end}}" />
+      <to uri="{{cool.end}}" />
     </route>
   </camelContext>
   
diff --git a/components/readme.adoc b/components/readme.adoc
index 324d5e2..659a63a 100644
--- a/components/readme.adoc
+++ b/components/readme.adoc
@@ -1,7 +1,7 @@
 = Components
 
 // components: START
-Number of Components: 301 in 239 JAR artifacts (0 deprecated)
+Number of Components: 300 in 238 JAR artifacts (0 deprecated)
 
 [width="100%",cols="4,1,5",options="header"]
 |===
@@ -682,9 +682,6 @@ Number of Components: 301 in 239 JAR artifacts (0 
deprecated)
 | link:camel-printer/src/main/docs/lpr-component.adoc[Printer] (camel-printer) 
+
 `lpr:hostname:port/printername` | 2.1 | The printer component is used for 
sending messages to printers as print jobs.
 
-| link:@@@ARTIFACTID@@@/src/main/docs/properties-component.adoc[Properties] 
(@@@ARTIFACTID@@@) +
-`properties:key` | 2.3 | The properties component is used for using property 
placeholders in endpoint uris.
-
 | link:camel-pubnub/src/main/docs/pubnub-component.adoc[PubNub] (camel-pubnub) 
+
 `pubnub:channel` | 2.19 | To send and receive messages to PubNub data stream 
network for connected devices.
 
@@ -1093,7 +1090,7 @@ Number of Miscellaneous Components: 36 in 36 JAR 
artifacts (0 deprecated)
 
 | link:camel-opentracing/src/main/docs/opentracing.adoc[OpenTracing] 
(camel-opentracing) | 2.19 | Distributed tracing using OpenTracing
 
-| link:camel-properties/src/main/docs/properties.adoc[Properties] 
(camel-properties) |  | Camel Properties component
+| link:camel-properties/src/main/docs/properties.adoc[Properties] 
(camel-properties) | 2.3 | Camel Properties component
 
 | 
link:camel-reactive-executor-vertx/src/main/docs/reactive-executor-vertx.adoc[Reactive
 Executor Vertx] (camel-reactive-executor-vertx) | 3.0 | Reactive Executor for 
camel-core using Vert X
 
diff --git 
a/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
 
b/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
index 04ea832..9590014 100644
--- 
a/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
+++ 
b/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
@@ -175,6 +175,13 @@ public abstract class AbstractCamelContextFactoryBean<T 
extends ModelCamelContex
             getContext().setTypeConverterRegistry(tcr);
         }
 
+        // then properties component
+        PropertiesComponent pc = getBeanForType(PropertiesComponent.class);
+        if (pc != null) {
+            LOG.debug("Using PropertiesComponent: {}", pc);
+            getContext().setPropertiesComponent(pc);
+        }
+
         // then set custom properties
         Map<String, String> mergedOptions = new HashMap<>();
         if (getGlobalOptions() != null) {
diff --git 
a/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationConfigurer.java
 
b/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationConfigurer.java
index caafea8..d0b889d 100644
--- 
a/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationConfigurer.java
+++ 
b/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationConfigurer.java
@@ -51,6 +51,7 @@ import org.apache.camel.spi.MessageHistoryFactory;
 import org.apache.camel.spi.ModelJAXBContextFactory;
 import org.apache.camel.spi.NodeIdFactory;
 import org.apache.camel.spi.ProcessorFactory;
+import org.apache.camel.spi.PropertiesComponent;
 import org.apache.camel.spi.ReactiveExecutor;
 import org.apache.camel.spi.Registry;
 import org.apache.camel.spi.RouteController;
@@ -180,6 +181,10 @@ public final class DefaultConfigurationConfigurer {
         final ManagementStrategy managementStrategy = 
camelContext.getManagementStrategy();
         final ExtendedCamelContext ecc = 
camelContext.adapt(ExtendedCamelContext.class);
 
+        PropertiesComponent pc = getSingleBeanOfType(registry, 
PropertiesComponent.class);
+        if (pc != null) {
+            ecc.setPropertiesComponent(pc);
+        }
         BacklogTracer bt = getSingleBeanOfType(registry, BacklogTracer.class);
         if (bt != null) {
             ecc.setExtension(BacklogTracer.class, bt);

Reply via email to