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 2016/02/27 16:25:20 UTC

[2/4] camel git commit: CAMEL-9652: camel-spark-rest - Add support for hosting swagger api

CAMEL-9652: camel-spark-rest - Add support for hosting swagger api


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

Branch: refs/heads/master
Commit: d2a23a484fe61337d9d1e8d3e2c511e5a5c8f744
Parents: f22d484
Author: Claus Ibsen <da...@apache.org>
Authored: Sat Feb 27 14:16:49 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Feb 27 16:25:10 2016 +0100

----------------------------------------------------------------------
 .../component/sparkrest/SparkComponent.java     |  5 ++-
 .../component/sparkrest/SparkConfiguration.java | 35 +++++++++++++++++---
 .../component/sparkrest/SparkConsumer.java      |  8 ++---
 .../component/sparkrest/SparkEndpoint.java      | 15 +--------
 4 files changed, 40 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/d2a23a48/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkComponent.java b/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkComponent.java
index 5484fd7..10db4eb 100644
--- a/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkComponent.java
+++ b/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkComponent.java
@@ -181,8 +181,11 @@ public class SparkComponent extends UriEndpointComponent implements RestConsumer
 
     @Override
     protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
+        SparkConfiguration config = getSparkConfiguration().copy();
+        setProperties(config, parameters);
+
         SparkEndpoint answer = new SparkEndpoint(uri, this);
-        answer.setSparkConfiguration(getSparkConfiguration());
+        answer.setSparkConfiguration(config);
         answer.setSparkBinding(getSparkBinding());
         setProperties(answer, parameters);
 

http://git-wip-us.apache.org/repos/asf/camel/blob/d2a23a48/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkConfiguration.java b/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkConfiguration.java
index ef795bc..4ed3574 100644
--- a/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkConfiguration.java
+++ b/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkConfiguration.java
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,11 +16,12 @@
  */
 package org.apache.camel.component.sparkrest;
 
+import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriParams;
 
 @UriParams
-public class SparkConfiguration {
+public class SparkConfiguration implements Cloneable {
 
     @UriParam(defaultValue = "true")
     private boolean mapHeaders = true;
@@ -30,12 +31,26 @@ public class SparkConfiguration {
     private boolean urlDecodeHeaders;
     @UriParam
     private boolean transferException;
+    @UriParam(label = "advanced")
+    private boolean matchOnUriPrefix;
 
     public boolean isMapHeaders() {
         return mapHeaders;
     }
 
     /**
+     * Returns a copy of this configuration
+     */
+    public SparkConfiguration copy() {
+        try {
+            SparkConfiguration copy = (SparkConfiguration) clone();
+            return copy;
+        } catch (CloneNotSupportedException e) {
+            throw new RuntimeCamelException(e);
+        }
+    }
+
+    /**
      * If this option is enabled, then during binding from Spark to Camel Message then the headers will be mapped as well
      * (eg added as header to the Camel Message as well). You can turn off this option to disable this.
      * The headers can still be accessed from the org.apache.camel.component.sparkrest.SparkMessage message with the
@@ -87,4 +102,16 @@ public class SparkConfiguration {
     public void setTransferException(boolean transferException) {
         this.transferException = transferException;
     }
+
+    public boolean isMatchOnUriPrefix() {
+        return matchOnUriPrefix;
+    }
+
+    /**
+     * Whether or not the consumer should try to find a target consumer by matching the URI prefix if no exact match is found.
+     */
+    public void setMatchOnUriPrefix(boolean matchOnUriPrefix) {
+        this.matchOnUriPrefix = matchOnUriPrefix;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/d2a23a48/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkConsumer.java b/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkConsumer.java
index d3191f2..5419d99 100644
--- a/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkConsumer.java
+++ b/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkConsumer.java
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -41,7 +41,7 @@ public class SparkConsumer extends DefaultConsumer {
         String verb = getEndpoint().getVerb();
         String path = getEndpoint().getPath();
         String accept = getEndpoint().getAccept();
-        boolean matchOnUriPrefix = getEndpoint().isMatchOnUriPrefix();
+        boolean matchOnUriPrefix = getEndpoint().getSparkConfiguration().isMatchOnUriPrefix();
 
         if (accept != null) {
             log.debug("Spark-rest: {}({}) accepting: {}", new Object[]{verb, path, accept});

http://git-wip-us.apache.org/repos/asf/camel/blob/d2a23a48/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkEndpoint.java b/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkEndpoint.java
index 3e8df90..c33712f 100644
--- a/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkEndpoint.java
+++ b/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkEndpoint.java
@@ -41,10 +41,8 @@ public class SparkEndpoint extends DefaultEndpoint {
     private String accept;
     @UriParam
     private SparkConfiguration sparkConfiguration;
-    @UriParam
+    @UriParam(label = "advanced")
     private SparkBinding sparkBinding;
-    @UriParam
-    private boolean matchOnUriPrefix;
 
     public SparkEndpoint(String endpointUri, Component component) {
         super(endpointUri, component);
@@ -105,17 +103,6 @@ public class SparkEndpoint extends DefaultEndpoint {
         this.accept = accept;
     }
 
-    public boolean isMatchOnUriPrefix() {
-        return matchOnUriPrefix;
-    }
-
-    /**
-     * Whether or not the consumer should try to find a target consumer by matching the URI prefix if no exact match is found.
-     */
-    public void setMatchOnUriPrefix(boolean matchOnUriPrefix) {
-        this.matchOnUriPrefix = matchOnUriPrefix;
-    }
-
     @Override
     public Producer createProducer() throws Exception {
         throw new UnsupportedOperationException("Producer not supported");