You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2010/03/10 07:37:50 UTC

svn commit: r921233 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/impl/DefaultCamelContext.java test/java/org/apache/camel/component/properties/PropertiesComponentEndpointTest.java

Author: davsclaus
Date: Wed Mar 10 06:37:50 2010
New Revision: 921233

URL: http://svn.apache.org/viewvc?rev=921233&view=rev
Log:
Fixed properties component being auto loaded when needed. eg. when you define it as a Spring bean and CamelContext must be able to look it up and use it.

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/properties/PropertiesComponentEndpointTest.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java?rev=921233&r1=921232&r2=921233&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java Wed Mar 10 06:37:50 2010
@@ -729,12 +729,17 @@ public class DefaultCamelContext extends
         // do not parse uris that are designated for the properties component as it will handle that itself
         if (uri != null && !uri.startsWith("properties:") && uri.contains("#{")) {
             // the uri contains property placeholders so lookup mandatory properties component and let it parse it
-            Component component = getComponent("properties");
+            Component component = hasComponent("properties");
+            if (component == null) {
+                // then fallback to lookup the component
+                component = getRegistry().lookup("properties", Component.class);
+            }
             if (component == null) {
                 throw new IllegalArgumentException("PropertiesComponent with name properties must be defined"
                         + " in CamelContext to support property placeholders in endpoint URIs");
             }
-            PropertiesComponent pc = getTypeConverter().mandatoryConvertTo(PropertiesComponent.class, component);
+            // force component to be created and registered as a component
+            PropertiesComponent pc = getComponent("properties", PropertiesComponent.class);
             // the parser will throw exception if property key was not found
             String answer = pc.parseUri(uri);
             if (LOG.isDebugEnabled()) {

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/component/properties/PropertiesComponentEndpointTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/properties/PropertiesComponentEndpointTest.java?rev=921233&r1=921232&r2=921233&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/properties/PropertiesComponentEndpointTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/properties/PropertiesComponentEndpointTest.java Wed Mar 10 06:37:50 2010
@@ -68,15 +68,15 @@ public class PropertiesComponentEndpoint
 
     public void testPropertiesComponentMandatory() throws Exception {
         context.removeComponent("properties");
-        context.addRoutes(new RouteBuilder() {
-            @Override
-            public void configure() throws Exception {
-                from("#{cool.start}")
-                    .to("log:#{cool.start}?showBodyType=false&showExchangeId=#{cool.showid}")
-                    .to("mock:#{cool.result}");
-            }
-        });
         try {
+            context.addRoutes(new RouteBuilder() {
+                @Override
+                public void configure() throws Exception {
+                    from("#{cool.start}")
+                        .to("log:#{cool.start}?showBodyType=false&showExchangeId=#{cool.showid}")
+                        .to("mock:#{cool.result}");
+                }
+            });
             context.start();
             fail("Should throw exception");
         } catch (FailedToCreateRouteException e) {