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 2015/12/25 14:00:25 UTC

[1/2] camel git commit: CAMEL-9450: rest-dsl - Configuration allow to use # to refer to beans to be looked up

Repository: camel
Updated Branches:
  refs/heads/master e4b2eb8b5 -> 3d47d04b9


CAMEL-9450: rest-dsl - Configuration allow to use # to refer to beans to be looked up


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/2c5264c5
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/2c5264c5
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/2c5264c5

Branch: refs/heads/master
Commit: 2c5264c5db1169c5dcf7d463c1fd084e772bb2db
Parents: e4b2eb8
Author: Claus Ibsen <da...@apache.org>
Authored: Fri Dec 25 12:28:30 2015 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Fri Dec 25 12:40:14 2015 +0100

----------------------------------------------------------------------
 .../camel/model/rest/RestBindingDefinition.java |  7 +++++--
 .../model/rest/RestConfigurationDefinition.java |  8 ++++++++
 .../rest/DummyRestConsumerFactory.java          | 20 ++++++++++++++++++++
 .../rest/FromRestConfigurationTest.java         | 19 +++++++++++++++++--
 4 files changed, 50 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/2c5264c5/camel-core/src/main/java/org/apache/camel/model/rest/RestBindingDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/rest/RestBindingDefinition.java b/camel-core/src/main/java/org/apache/camel/model/rest/RestBindingDefinition.java
index d2936de..dec6006 100644
--- a/camel-core/src/main/java/org/apache/camel/model/rest/RestBindingDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/rest/RestBindingDefinition.java
@@ -18,7 +18,6 @@ package org.apache.camel.model.rest;
 
 import java.util.HashMap;
 import java.util.Map;
-
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
@@ -33,6 +32,7 @@ import org.apache.camel.spi.DataFormat;
 import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.RestConfiguration;
 import org.apache.camel.spi.RouteContext;
+import org.apache.camel.util.EndpointHelper;
 import org.apache.camel.util.IntrospectionSupport;
 
 /**
@@ -223,7 +223,9 @@ public class RestBindingDefinition extends NoOutputDefinition<RestBindingDefinit
                 }
             }
 
-            IntrospectionSupport.setProperties(context.getTypeConverter(), dataFormat, copy);
+            // set reference properties first as they use # syntax that fools the regular properties setter
+            EndpointHelper.setReferenceProperties(context, dataFormat, copy);
+            EndpointHelper.setProperties(context, dataFormat, copy);
         }
     }
 
@@ -241,6 +243,7 @@ public class RestBindingDefinition extends NoOutputDefinition<RestBindingDefinit
     public void setComponent(String component) {
         this.component = component;
     }
+
     public String getComponent() {
         return component;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/2c5264c5/camel-core/src/main/java/org/apache/camel/model/rest/RestConfigurationDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/rest/RestConfigurationDefinition.java b/camel-core/src/main/java/org/apache/camel/model/rest/RestConfigurationDefinition.java
index 5dc4804..fb03ef5 100644
--- a/camel-core/src/main/java/org/apache/camel/model/rest/RestConfigurationDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/rest/RestConfigurationDefinition.java
@@ -557,6 +557,8 @@ public class RestConfigurationDefinition {
 
     /**
      * For additional configuration options on component level
+     * <p/>
+     * The value can use <tt>#</tt> to refer to a bean to lookup in the registry.
      */
     public RestConfigurationDefinition componentProperty(String key, String value) {
         RestPropertyDefinition prop = new RestPropertyDefinition();
@@ -568,6 +570,8 @@ public class RestConfigurationDefinition {
 
     /**
      * For additional configuration options on endpoint level
+     * <p/>
+     * The value can use <tt>#</tt> to refer to a bean to lookup in the registry.
      */
     public RestConfigurationDefinition endpointProperty(String key, String value) {
         RestPropertyDefinition prop = new RestPropertyDefinition();
@@ -579,6 +583,8 @@ public class RestConfigurationDefinition {
 
     /**
      * For additional configuration options on consumer level
+     * <p/>
+     * The value can use <tt>#</tt> to refer to a bean to lookup in the registry.
      */
     public RestConfigurationDefinition consumerProperty(String key, String value) {
         RestPropertyDefinition prop = new RestPropertyDefinition();
@@ -590,6 +596,8 @@ public class RestConfigurationDefinition {
 
     /**
      * For additional configuration options on data format level
+     * <p/>
+     * The value can use <tt>#</tt> to refer to a bean to lookup in the registry.
      */
     public RestConfigurationDefinition dataFormatProperty(String key, String value) {
         RestPropertyDefinition prop = new RestPropertyDefinition();

http://git-wip-us.apache.org/repos/asf/camel/blob/2c5264c5/camel-core/src/test/java/org/apache/camel/component/rest/DummyRestConsumerFactory.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/rest/DummyRestConsumerFactory.java b/camel-core/src/test/java/org/apache/camel/component/rest/DummyRestConsumerFactory.java
index 46572c8..c0d8496 100644
--- a/camel-core/src/test/java/org/apache/camel/component/rest/DummyRestConsumerFactory.java
+++ b/camel-core/src/test/java/org/apache/camel/component/rest/DummyRestConsumerFactory.java
@@ -26,9 +26,21 @@ import org.apache.camel.impl.ActiveMQUuidGenerator;
 import org.apache.camel.spi.RestApiConsumerFactory;
 import org.apache.camel.spi.RestConfiguration;
 import org.apache.camel.spi.RestConsumerFactory;
+import org.apache.camel.util.CamelContextHelper;
+import org.apache.camel.util.EndpointHelper;
 
 public class DummyRestConsumerFactory implements RestConsumerFactory, RestApiConsumerFactory {
 
+    private Object dummy;
+
+    public Object getDummy() {
+        return dummy;
+    }
+
+    public void setDummy(Object dummy) {
+        this.dummy = dummy;
+    }
+
     @Override
     public Consumer createConsumer(CamelContext camelContext, Processor processor, String verb, String basePath, String uriTemplate,
                                    String consumes, String produces, RestConfiguration configuration, Map<String, Object> parameters) throws Exception {
@@ -43,6 +55,14 @@ public class DummyRestConsumerFactory implements RestConsumerFactory, RestApiCon
         if (id.startsWith("-")) {
             id = id.substring(1);
         }
+
+        if (configuration.getConsumerProperties() != null) {
+            String ref = (String) configuration.getConsumerProperties().get("dummy");
+            if (ref != null) {
+                dummy = CamelContextHelper.mandatoryLookup(camelContext, ref.substring(1));
+            }
+        }
+
         SedaEndpoint seda = camelContext.getEndpoint("seda:" + verb + "-" + id, SedaEndpoint.class);
         return seda.createConsumer(processor);
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/2c5264c5/camel-core/src/test/java/org/apache/camel/component/rest/FromRestConfigurationTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/rest/FromRestConfigurationTest.java b/camel-core/src/test/java/org/apache/camel/component/rest/FromRestConfigurationTest.java
index 59e5e93..4930f16 100644
--- a/camel-core/src/test/java/org/apache/camel/component/rest/FromRestConfigurationTest.java
+++ b/camel-core/src/test/java/org/apache/camel/component/rest/FromRestConfigurationTest.java
@@ -17,9 +17,20 @@
 package org.apache.camel.component.rest;
 
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.FooBar;
+import org.apache.camel.impl.JndiRegistry;
 
 public class FromRestConfigurationTest extends FromRestGetTest {
 
+    private Object myDummy = new FooBar();
+
+    @Override
+    protected JndiRegistry createRegistry() throws Exception {
+        JndiRegistry jndi = super.createRegistry();
+        jndi.bind("myDummy", myDummy);
+        return jndi;
+    }
+
     @Override
     public void testFromRestModel() throws Exception {
         super.testFromRestModel();
@@ -31,6 +42,10 @@ public class FromRestConfigurationTest extends FromRestGetTest {
         assertEquals("stuff", context.getRestConfiguration().getComponentProperties().get("other"));
         assertEquals("200", context.getRestConfiguration().getEndpointProperties().get("size"));
         assertEquals("1000", context.getRestConfiguration().getConsumerProperties().get("pollTimeout"));
+        assertEquals("#myDummy", context.getRestConfiguration().getConsumerProperties().get("dummy"));
+
+        DummyRestConsumerFactory factory = (DummyRestConsumerFactory) context.getRegistry().lookupByName("dummy-rest");
+        assertSame(myDummy, factory.getDummy());
     }
 
     @Override
@@ -43,10 +58,10 @@ public class FromRestConfigurationTest extends FromRestGetTest {
                     .componentProperty("foo", "bar")
                     .componentProperty("other", "stuff")
                     .endpointProperty("size", "200")
-                    .consumerProperty("pollTimeout", "1000");
+                    .consumerProperty("pollTimeout", "1000")
+                    .consumerProperty("dummy", "#myDummy");
 
                 includeRoutes(lowerR);
-
             }
         };
     }


[2/2] camel git commit: rest-dsl - Add missing component configuration from rest config.

Posted by da...@apache.org.
rest-dsl - Add missing component configuration from rest config.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/3d47d04b
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/3d47d04b
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/3d47d04b

Branch: refs/heads/master
Commit: 3d47d04b9d461c0492f2c135abe8644f43555530
Parents: 2c5264c
Author: Claus Ibsen <da...@apache.org>
Authored: Fri Dec 25 12:40:28 2015 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Fri Dec 25 12:40:28 2015 +0100

----------------------------------------------------------------------
 .../apache/camel/component/jetty/JettyHttpComponent.java |  7 +++++++
 .../camel/component/netty/http/NettyHttpComponent.java   | 11 +++++++++++
 .../camel/component/netty4/http/NettyHttpComponent.java  | 11 +++++++++++
 .../apache/camel/component/servlet/ServletComponent.java | 11 +++++++++++
 .../camel/component/undertow/UndertowComponent.java      |  6 ++++++
 5 files changed, 46 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/3d47d04b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
index 6ecc9b5..4224e89 100644
--- a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
+++ b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
@@ -1274,6 +1274,13 @@ public abstract class JettyHttpComponent extends HttpCommonComponent implements
     @Override
     protected void doStart() throws Exception {
         super.doStart();
+
+        RestConfiguration config = getCamelContext().getRestConfiguration("jetty", true);
+        // configure additional options on jetty configuration
+        if (config.getComponentProperties() != null && !config.getComponentProperties().isEmpty()) {
+            setProperties(this, config.getComponentProperties());
+        }
+
         startMbContainer();
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/3d47d04b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java
index 8bc0aea..b0a1b1e 100644
--- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java
+++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java
@@ -364,6 +364,17 @@ public class NettyHttpComponent extends NettyComponent implements HeaderFilterSt
     }
 
     @Override
+    protected void doStart() throws Exception {
+        super.doStart();
+
+        RestConfiguration config = getCamelContext().getRestConfiguration("netty-http", true);
+        // configure additional options on netty-http configuration
+        if (config.getComponentProperties() != null && !config.getComponentProperties().isEmpty()) {
+            setProperties(this, config.getComponentProperties());
+        }
+    }
+
+    @Override
     protected void doStop() throws Exception {
         super.doStop();
 

http://git-wip-us.apache.org/repos/asf/camel/blob/3d47d04b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java
index 42e4792..fc15a25 100644
--- a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java
+++ b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java
@@ -370,6 +370,17 @@ public class NettyHttpComponent extends NettyComponent implements HeaderFilterSt
     }
 
     @Override
+    protected void doStart() throws Exception {
+        super.doStart();
+
+        RestConfiguration config = getCamelContext().getRestConfiguration("netty4-http", true);
+        // configure additional options on netty4-http configuration
+        if (config.getComponentProperties() != null && !config.getComponentProperties().isEmpty()) {
+            setProperties(this, config.getComponentProperties());
+        }
+    }
+
+    @Override
     protected void doStop() throws Exception {
         super.doStop();
 

http://git-wip-us.apache.org/repos/asf/camel/blob/3d47d04b/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletComponent.java b/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletComponent.java
index 25a1b1b..92dd398 100644
--- a/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletComponent.java
+++ b/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletComponent.java
@@ -255,4 +255,15 @@ public class ServletComponent extends HttpCommonComponent implements RestConsume
 
         return consumer;
     }
+
+    @Override
+    protected void doStart() throws Exception {
+        super.doStart();
+
+        RestConfiguration config = getCamelContext().getRestConfiguration("servlet", true);
+        // configure additional options on jetty configuration
+        if (config.getComponentProperties() != null && !config.getComponentProperties().isEmpty()) {
+            setProperties(this, config.getComponentProperties());
+        }
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/3d47d04b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowComponent.java b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowComponent.java
index 062a6c9..e736aff 100644
--- a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowComponent.java
+++ b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowComponent.java
@@ -195,6 +195,12 @@ public class UndertowComponent extends UriEndpointComponent implements RestConsu
     @Override
     protected void doStart() throws Exception {
         super.doStart();
+
+        RestConfiguration config = getCamelContext().getRestConfiguration("undertow", true);
+        // configure additional options on undertow configuration
+        if (config.getComponentProperties() != null && !config.getComponentProperties().isEmpty()) {
+            setProperties(this, config.getComponentProperties());
+        }
     }
 
     @Override