camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [5/5] git commit: CAMEL-7354: renamed camel-spark to camel-spark-rest to aovid ppl mistaking it for Apache Spark integration.
Date Tue, 01 Jul 2014 06:41:28 GMT
CAMEL-7354: renamed camel-spark to camel-spark-rest to aovid ppl mistaking it for Apache Spark integration.


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

Branch: refs/heads/master
Commit: 3c2252aa592b54e8084db93be2428da7d9e43fcc
Parents: 689147e
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Tue Jul 1 08:40:16 2014 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Tue Jul 1 08:40:16 2014 +0200

----------------------------------------------------------------------
 apache-camel/pom.xml                            |   2 +-
 .../src/main/descriptors/common-bin.xml         |   2 +-
 components/camel-spark-rest/pom.xml             | 136 ++++++++++++
 .../camel/component/sparkrest/CamelSpark.java   |  84 +++++++
 .../component/sparkrest/CamelSparkRoute.java    |  65 ++++++
 .../sparkrest/DefaultSparkBinding.java          | 218 +++++++++++++++++++
 .../sparkrest/ServletSparkApplication.java      |  37 ++++
 .../camel/component/sparkrest/SparkBinding.java |  60 +++++
 .../component/sparkrest/SparkComponent.java     |  95 ++++++++
 .../component/sparkrest/SparkConfiguration.java |  65 ++++++
 .../component/sparkrest/SparkConstants.java     |  26 +++
 .../component/sparkrest/SparkConsumer.java      |  53 +++++
 .../component/sparkrest/SparkConverter.java     |  79 +++++++
 .../component/sparkrest/SparkEndpoint.java      | 115 ++++++++++
 .../sparkrest/SparkHeaderFilterStrategy.java    |  57 +++++
 .../camel/component/sparkrest/SparkHelper.java  |  56 +++++
 .../camel/component/sparkrest/SparkMessage.java |  51 +++++
 .../component/sparkrest/SparkRouteBuilder.java  |  91 ++++++++
 .../sparkrest/SparkServletContextListener.java  |  46 ++++
 .../src/main/resources/META-INF/LICENSE.txt     | 203 +++++++++++++++++
 .../src/main/resources/META-INF/NOTICE.txt      |  11 +
 .../services/org/apache/camel/TypeConverter     |  18 ++
 .../org/apache/camel/component/spark-rest       |  17 ++
 .../component/sparkrest/BaseSparkTest.java      |  46 ++++
 .../sparkrest/CamelSparkAcceptTest.java         |  55 +++++
 .../sparkrest/CamelSparkParamTest.java          |  46 ++++
 .../sparkrest/CamelSparkRequestBeanTest.java    |  50 +++++
 .../CamelSparkRouteBuilderPostTest.java         |  45 ++++
 .../sparkrest/CamelSparkRouteBuilderTest.java   |  45 ++++
 .../sparkrest/CamelSparkSplatTest.java          |  45 ++++
 .../component/sparkrest/CamelSparkTest.java     |  45 ++++
 .../src/test/resources/log4j.properties         |  36 +++
 components/camel-spark/pom.xml                  | 136 ------------
 .../camel/component/spark/CamelSpark.java       |  84 -------
 .../camel/component/spark/CamelSparkRoute.java  |  65 ------
 .../component/spark/DefaultSparkBinding.java    | 218 -------------------
 .../spark/ServletSparkApplication.java          |  37 ----
 .../camel/component/spark/SparkBinding.java     |  60 -----
 .../camel/component/spark/SparkComponent.java   |  95 --------
 .../component/spark/SparkConfiguration.java     |  65 ------
 .../camel/component/spark/SparkConstants.java   |  26 ---
 .../camel/component/spark/SparkConsumer.java    |  53 -----
 .../camel/component/spark/SparkConverter.java   |  79 -------
 .../camel/component/spark/SparkEndpoint.java    | 115 ----------
 .../spark/SparkHeaderFilterStrategy.java        |  57 -----
 .../camel/component/spark/SparkHelper.java      |  56 -----
 .../camel/component/spark/SparkMessage.java     |  51 -----
 .../component/spark/SparkRouteBuilder.java      |  91 --------
 .../spark/SparkServletContextListener.java      |  46 ----
 .../src/main/resources/META-INF/LICENSE.txt     | 203 -----------------
 .../src/main/resources/META-INF/NOTICE.txt      |  11 -
 .../services/org/apache/camel/TypeConverter     |  18 --
 .../services/org/apache/camel/component/spark   |  17 --
 .../camel/component/spark/BaseSparkTest.java    |  46 ----
 .../component/spark/CamelSparkAcceptTest.java   |  55 -----
 .../component/spark/CamelSparkParamTest.java    |  46 ----
 .../spark/CamelSparkRequestBeanTest.java        |  50 -----
 .../spark/CamelSparkRouteBuilderPostTest.java   |  45 ----
 .../spark/CamelSparkRouteBuilderTest.java       |  45 ----
 .../component/spark/CamelSparkSplatTest.java    |  45 ----
 .../camel/component/spark/CamelSparkTest.java   |  45 ----
 .../src/test/resources/log4j.properties         |  36 ---
 components/pom.xml                              |   2 +-
 .../camel-example-spark-rest-tomcat/README.txt  |  25 +++
 .../camel-example-spark-rest-tomcat/pom.xml     |  85 ++++++++
 .../example/spark/MySparkRouteBuilder.java      |  44 ++++
 .../src/main/resources/META-INF/LICENSE.txt     | 203 +++++++++++++++++
 .../src/main/resources/META-INF/NOTICE.txt      |  11 +
 .../src/main/resources/camel-config.xml         |  34 +++
 .../src/main/resources/log4j.properties         |  28 +++
 .../src/main/webapp/WEB-INF/web.xml             |  59 +++++
 .../src/main/webapp/index.html                  |  70 ++++++
 examples/camel-example-spark-tomcat/README.txt  |  25 ---
 examples/camel-example-spark-tomcat/pom.xml     |  85 --------
 .../example/spark/MySparkRouteBuilder.java      |  44 ----
 .../src/main/resources/META-INF/LICENSE.txt     | 203 -----------------
 .../src/main/resources/META-INF/NOTICE.txt      |  11 -
 .../src/main/resources/camel-config.xml         |  34 ---
 .../src/main/resources/log4j.properties         |  29 ---
 .../src/main/webapp/WEB-INF/web.xml             |  59 -----
 .../src/main/webapp/index.html                  |  70 ------
 examples/pom.xml                                |   2 +-
 parent/pom.xml                                  |   6 +-
 83 files changed, 2562 insertions(+), 2563 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/3c2252aa/apache-camel/pom.xml
----------------------------------------------------------------------
diff --git a/apache-camel/pom.xml b/apache-camel/pom.xml
index 025a263..f0881df 100644
--- a/apache-camel/pom.xml
+++ b/apache-camel/pom.xml
@@ -564,7 +564,7 @@
     </dependency>
     <dependency>
       <groupId>org.apache.camel</groupId>
-      <artifactId>camel-spark</artifactId>
+      <artifactId>camel-spark-rest</artifactId>
     </dependency>
     <dependency>
       <groupId>org.apache.camel</groupId>

http://git-wip-us.apache.org/repos/asf/camel/blob/3c2252aa/apache-camel/src/main/descriptors/common-bin.xml
----------------------------------------------------------------------
diff --git a/apache-camel/src/main/descriptors/common-bin.xml b/apache-camel/src/main/descriptors/common-bin.xml
index 4ffcd58..466ec25 100644
--- a/apache-camel/src/main/descriptors/common-bin.xml
+++ b/apache-camel/src/main/descriptors/common-bin.xml
@@ -152,7 +152,7 @@
         <include>org.apache.camel:camel-snmp</include>
         <include>org.apache.camel:camel-soap</include>
         <include>org.apache.camel:camel-solr</include>
-        <include>org.apache.camel:camel-spark</include>  
+        <include>org.apache.camel:camel-spark-rest</include>  
         <include>org.apache.camel:camel-splunk</include>        
         <include>org.apache.camel:camel-spring</include>
         <include>org.apache.camel:camel-spring-batch</include>

http://git-wip-us.apache.org/repos/asf/camel/blob/3c2252aa/components/camel-spark-rest/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-spark-rest/pom.xml b/components/camel-spark-rest/pom.xml
new file mode 100644
index 0000000..db5b05e
--- /dev/null
+++ b/components/camel-spark-rest/pom.xml
@@ -0,0 +1,136 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  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
+
+  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.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.camel</groupId>
+    <artifactId>components</artifactId>
+    <version>2.14-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>camel-spark-rest</artifactId>
+  <packaging>bundle</packaging>
+  <name>Camel :: Spark REST</name>
+  <description>Camel Spark (REST DSL) support</description>
+
+  <properties>
+    <camel.osgi.export.pkg>org.apache.camel.component.sparkrest.*</camel.osgi.export.pkg>
+  </properties>
+
+  <dependencies>
+
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-core</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>com.sparkjava</groupId>
+      <artifactId>spark-core</artifactId>
+      <version>${spark-rest-version}</version>
+    </dependency>
+
+    <!-- avoid mixed versions of jetty as spark-rest requires jetty 9 -->
+    <dependency>
+      <groupId>org.eclipse.jetty</groupId>
+      <artifactId>jetty-server</artifactId>
+      <version>${jetty9-version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.jetty</groupId>
+      <artifactId>jetty-util</artifactId>
+      <version>${jetty9-version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.jetty</groupId>
+      <artifactId>jetty-io</artifactId>
+      <version>${jetty9-version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.jetty</groupId>
+      <artifactId>jetty-servlet</artifactId>
+      <version>${jetty9-version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.jetty</groupId>
+      <artifactId>jetty-security</artifactId>
+      <version>${jetty9-version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.jetty</groupId>
+      <artifactId>jetty-webapp</artifactId>
+      <version>${jetty9-version}</version>
+    </dependency>
+
+    <!-- test dependencies -->
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-test</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-http</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <!-- unit testing requires java 8 -->
+  <profiles>
+    <profile>
+      <id>jdk8-test</id>
+      <activation>
+        <jdk>1.8</jdk>
+      </activation>
+      <build>
+        <plugins>
+          <plugin>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <configuration>
+              <skipTests>false</skipTests>
+              <forkedProcessTimeoutInSeconds>300</forkedProcessTimeoutInSeconds>
+            </configuration>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+  </profiles>
+
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <skipTests>true</skipTests>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>

http://git-wip-us.apache.org/repos/asf/camel/blob/3c2252aa/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/CamelSpark.java
----------------------------------------------------------------------
diff --git a/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/CamelSpark.java b/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/CamelSpark.java
new file mode 100644
index 0000000..533ce3c
--- /dev/null
+++ b/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/CamelSpark.java
@@ -0,0 +1,84 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.sparkrest;
+
+import spark.Route;
+import spark.Spark;
+
+public final class CamelSpark {
+
+    private CamelSpark() {
+    }
+
+    public static void spark(String verb, String path, String accept, Route route) {
+        if ("get".equals(verb)) {
+            if (accept != null) {
+                Spark.get(path, accept, route);
+            } else {
+                Spark.get(path, route);
+            }
+        } else if ("post".equals(verb)) {
+            if (accept != null) {
+                Spark.post(path, accept, route);
+            } else {
+                Spark.post(path, route);
+            }
+        } else if ("put".equals(verb)) {
+            if (accept != null) {
+                Spark.put(path, accept, route);
+            } else {
+                Spark.put(path, route);
+            }
+        } else if ("patch".equals(verb)) {
+            if (accept != null) {
+                Spark.patch(path, accept, route);
+            } else {
+                Spark.patch(path, route);
+            }
+        } else if ("delete".equals(verb)) {
+            if (accept != null) {
+                Spark.delete(path, accept, route);
+            } else {
+                Spark.delete(path, route);
+            }
+        } else if ("head".equals(verb)) {
+            if (accept != null) {
+                Spark.head(path, accept, route);
+            } else {
+                Spark.head(path, route);
+            }
+        } else if ("trace".equals(verb)) {
+            if (accept != null) {
+                Spark.trace(path, accept, route);
+            } else {
+                Spark.trace(path, route);
+            }
+        } else if ("connect".equals(verb)) {
+            if (accept != null) {
+                Spark.connect(path, accept, route);
+            } else {
+                Spark.connect(path, route);
+            }
+        } else if ("options".equals(verb)) {
+            if (accept != null) {
+                Spark.options(path, accept, route);
+            } else {
+                Spark.options(path, route);
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/3c2252aa/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/CamelSparkRoute.java
----------------------------------------------------------------------
diff --git a/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/CamelSparkRoute.java b/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/CamelSparkRoute.java
new file mode 100644
index 0000000..82fce75
--- /dev/null
+++ b/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/CamelSparkRoute.java
@@ -0,0 +1,65 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.sparkrest;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.ExchangePattern;
+import org.apache.camel.Message;
+import org.apache.camel.Processor;
+import org.apache.camel.util.ObjectHelper;
+import spark.Request;
+import spark.Response;
+import spark.Route;
+
+public class CamelSparkRoute implements Route {
+
+    private final SparkEndpoint endpoint;
+    private final Processor processor;
+
+    public CamelSparkRoute(SparkEndpoint endpoint, Processor processor) {
+        this.endpoint = endpoint;
+        this.processor = processor;
+    }
+
+    @Override
+    public Object handle(Request request, Response response) {
+        Exchange exchange = endpoint.createExchange(ExchangePattern.InOut);
+
+        try {
+            Message in = endpoint.getSparkBinding().toCamelMessage(request, exchange, endpoint.getSparkConfiguration());
+            exchange.setIn(in);
+
+            processor.process(exchange);
+        } catch (Exception e) {
+            exchange.setException(e);
+        }
+
+        Message msg = exchange.hasOut() ? exchange.getOut() : exchange.getIn();
+
+        try {
+            endpoint.getSparkBinding().toSparkResponse(msg, response, endpoint.getSparkConfiguration());
+        } catch (Exception e) {
+            throw ObjectHelper.wrapRuntimeCamelException(e);
+        }
+
+        if (exchange.hasOut()) {
+            return exchange.getOut().getBody();
+        } else {
+            return exchange.getIn().getBody();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/3c2252aa/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/DefaultSparkBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/DefaultSparkBinding.java b/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/DefaultSparkBinding.java
new file mode 100644
index 0000000..7b43be1
--- /dev/null
+++ b/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/DefaultSparkBinding.java
@@ -0,0 +1,218 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.sparkrest;
+
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectOutputStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.TypeConverter;
+import org.apache.camel.spi.HeaderFilterStrategy;
+import org.apache.camel.util.ExchangeHelper;
+import org.apache.camel.util.IOHelper;
+import org.apache.camel.util.MessageHelper;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import spark.Request;
+import spark.Response;
+
+public class DefaultSparkBinding implements SparkBinding {
+
+    private static final Logger LOG = LoggerFactory.getLogger(DefaultSparkBinding.class);
+    private HeaderFilterStrategy headerFilterStrategy = new SparkHeaderFilterStrategy();
+
+    @Override
+    public Message toCamelMessage(Request request, Exchange exchange, SparkConfiguration configuration) throws Exception {
+        LOG.trace("toCamelMessage: {}", request);
+
+        SparkMessage answer = new SparkMessage(request, null);
+        answer.setExchange(exchange);
+        if (configuration.isMapHeaders()) {
+            populateCamelHeaders(request, answer.getHeaders(), exchange, configuration);
+        }
+
+        if (configuration.isDisableStreamCache()) {
+            // keep the body as a input stream
+            answer.setBody(request.raw().getInputStream());
+        } else {
+            answer.setBody(request.body());
+        }
+        return answer;
+    }
+
+    @Override
+    public void populateCamelHeaders(Request request, Map<String, Object> headers, Exchange exchange, SparkConfiguration configuration) throws Exception {
+        // store the method and query and other info in headers as String types
+        headers.put(Exchange.HTTP_METHOD, request.raw().getMethod());
+        headers.put(Exchange.HTTP_QUERY, request.raw().getQueryString());
+        headers.put(Exchange.HTTP_URL, request.raw().getRequestURL().toString());
+        headers.put(Exchange.HTTP_URI, request.raw().getRequestURI());
+        headers.put(Exchange.HTTP_PATH, request.raw().getPathInfo());
+        headers.put(Exchange.CONTENT_TYPE, request.raw().getContentType());
+
+        for (String key : request.attributes()) {
+            Object value = request.attribute(key);
+            Object decoded = shouldUrlDecodeHeader(configuration, key, value, "UTF-8");
+            if (headerFilterStrategy != null
+                    && !headerFilterStrategy.applyFilterToExternalHeaders(key, decoded, exchange)) {
+                SparkHelper.appendHeader(headers, key, decoded);
+            }
+        }
+
+        for (String key : request.headers()) {
+            Object value = request.headers(key);
+            Object decoded = shouldUrlDecodeHeader(configuration, key, value, "UTF-8");
+            if (headerFilterStrategy != null
+                    && !headerFilterStrategy.applyFilterToExternalHeaders(key, decoded, exchange)) {
+                SparkHelper.appendHeader(headers, key, decoded);
+            }
+        }
+
+        for (Map.Entry<String, String> entry : request.params().entrySet()) {
+            String key = mapKey(entry.getKey());
+            String value = entry.getValue();
+            Object decoded = shouldUrlDecodeHeader(configuration, key, value, "UTF-8");
+            if (headerFilterStrategy != null
+                    && !headerFilterStrategy.applyFilterToExternalHeaders(key, decoded, exchange)) {
+                SparkHelper.appendHeader(headers, key, decoded);
+            }
+        }
+
+        String[] splat = request.splat();
+        String key = SparkConstants.SPLAT;
+        if (headerFilterStrategy != null
+                && !headerFilterStrategy.applyFilterToExternalHeaders(key, splat, exchange)) {
+            SparkHelper.appendHeader(headers, key, splat);
+        }
+    }
+
+    @Override
+    public void toSparkResponse(Message message, Response response, SparkConfiguration configuration) throws Exception {
+        LOG.trace("toSparkResponse: {}", message);
+
+        // the response code is 200 for OK and 500 for failed
+        boolean failed = message.getExchange().isFailed();
+        int defaultCode = failed ? 500 : 200;
+
+        int code = message.getHeader(Exchange.HTTP_RESPONSE_CODE, defaultCode, int.class);
+        response.status(code);
+        LOG.trace("HTTP Status Code: {}", code);
+
+        TypeConverter tc = message.getExchange().getContext().getTypeConverter();
+
+        // append headers
+        // must use entrySet to ensure case of keys is preserved
+        for (Map.Entry<String, Object> entry : message.getHeaders().entrySet()) {
+            String key = entry.getKey();
+            Object value = entry.getValue();
+            // use an iterator as there can be multiple values. (must not use a delimiter)
+            final Iterator<?> it = ObjectHelper.createIterator(value, null);
+            while (it.hasNext()) {
+                String headerValue = tc.convertTo(String.class, it.next());
+                if (headerValue != null && headerFilterStrategy != null
+                        && !headerFilterStrategy.applyFilterToCamelHeaders(key, headerValue, message.getExchange())) {
+                    LOG.trace("HTTP-Header: {}={}", key, headerValue);
+                    response.header(key, headerValue);
+                }
+            }
+        }
+
+        // set the content type in the response.
+        String contentType = MessageHelper.getContentType(message);
+        if (contentType != null) {
+            // set content-type
+            response.header(Exchange.CONTENT_TYPE, contentType);
+            LOG.trace("Content-Type: {}", contentType);
+        }
+
+        Object body = message.getBody();
+        Exception cause = message.getExchange().getException();
+
+        // if there was an exception then use that as body
+        if (cause != null) {
+            if (configuration.isTransferException()) {
+                // we failed due an exception, and transfer it as java serialized object
+                ByteArrayOutputStream bos = new ByteArrayOutputStream();
+                ObjectOutputStream oos = new ObjectOutputStream(bos);
+                oos.writeObject(cause);
+                oos.flush();
+                IOHelper.close(oos, bos);
+
+                body = bos.toByteArray();
+                // force content type to be serialized java object
+                message.setHeader(Exchange.CONTENT_TYPE, SparkConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT);
+            } else {
+                // we failed due an exception so print it as plain text
+                StringWriter sw = new StringWriter();
+                PrintWriter pw = new PrintWriter(sw);
+                cause.printStackTrace(pw);
+
+                // the body should then be the stacktrace
+                body = sw.toString().getBytes();
+                // force content type to be text/plain as that is what the stacktrace is
+                message.setHeader(Exchange.CONTENT_TYPE, "text/plain");
+            }
+
+            // and mark the exception as failure handled, as we handled it by returning it as the response
+            ExchangeHelper.setFailureHandled(message.getExchange());
+        }
+
+        if (body != null) {
+            String str = tc.mandatoryConvertTo(String.class, message.getExchange(), body);
+            response.body(str);
+        }
+    }
+
+    /**
+     * Decodes the header if needed to, or returns the header value as is.
+     *
+     * @param configuration the configuration
+     * @param headerName    the header name
+     * @param value         the current header value
+     * @param charset       the charset to use for decoding
+     * @return the decoded value (if decoded was needed) or a <tt>toString</tt> representation of the value.
+     * @throws java.io.UnsupportedEncodingException is thrown if error decoding.
+     */
+    protected String shouldUrlDecodeHeader(SparkConfiguration configuration, String headerName, Object value, String charset) throws
+            UnsupportedEncodingException {
+        // do not decode Content-Type
+        if (Exchange.CONTENT_TYPE.equals(headerName)) {
+            return value.toString();
+        } else if (configuration.isUrlDecodeHeaders()) {
+            return URLDecoder.decode(value.toString(), charset);
+        } else {
+            return value.toString();
+        }
+    }
+
+    protected String mapKey(String key) {
+        if (key.startsWith(":")) {
+            return key.substring(1);
+        } else {
+            return key;
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/3c2252aa/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/ServletSparkApplication.java
----------------------------------------------------------------------
diff --git a/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/ServletSparkApplication.java b/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/ServletSparkApplication.java
new file mode 100644
index 0000000..5df4cd0
--- /dev/null
+++ b/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/ServletSparkApplication.java
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.sparkrest;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import spark.Access;
+import spark.servlet.SparkApplication;
+
+/**
+ * A {@link spark.servlet.SparkApplication} to run in servlet mode.
+ */
+public class ServletSparkApplication implements SparkApplication {
+
+    private static final Logger LOG = LoggerFactory.getLogger(ServletSparkApplication.class);
+
+    @Override
+    public void init() {
+        LOG.info("init");
+        // force spark to be in Servlet mode
+        Access.runFromServlet();
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/3c2252aa/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkBinding.java b/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkBinding.java
new file mode 100644
index 0000000..0fcd497
--- /dev/null
+++ b/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkBinding.java
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.sparkrest;
+
+import java.util.Map;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import spark.Request;
+import spark.Response;
+
+public interface SparkBinding {
+
+    /**
+     * Binds from Spark {@link Request} to Camel {@link org.apache.camel.Message}.
+     *
+     * @param request       the Spark request
+     * @param exchange      the exchange that should contain the returned message.
+     * @param configuration configuration
+     * @return the message to store on the given exchange
+     * @throws Exception is thrown if error during binding
+     */
+    Message toCamelMessage(Request request, Exchange exchange, SparkConfiguration configuration) throws Exception;
+
+    /**
+     * Binds from Spark {@link Request} to Camel headers as a {@link Map}.
+     *
+     * @param request       the Spark request
+     * @param headers       the Camel headers that should be populated
+     * @param exchange      the exchange that should contain the returned message.
+     * @param configuration the endpoint configuration
+     * @throws Exception is thrown if error during binding
+     */
+    void populateCamelHeaders(Request request, Map<String, Object> headers, Exchange exchange, SparkConfiguration configuration) throws Exception;
+
+    /**
+     * Binds from Camel {@link Message} to Spark {@link Response}.
+     *
+     * @param message       the Camel message
+     * @param response      the Spark response to bind to
+     * @param configuration the endpoint configuration
+     * @throws Exception is thrown if error during binding
+     */
+    void toSparkResponse(Message message, Response response, SparkConfiguration configuration) throws Exception;
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/3c2252aa/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
new file mode 100644
index 0000000..2cf1548
--- /dev/null
+++ b/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkComponent.java
@@ -0,0 +1,95 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.sparkrest;
+
+import java.util.Map;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.impl.UriEndpointComponent;
+import org.apache.camel.util.ObjectHelper;
+import spark.Spark;
+import spark.SparkBase;
+
+public class SparkComponent extends UriEndpointComponent {
+
+    private int port = SparkBase.SPARK_DEFAULT_PORT;
+    private SparkConfiguration sparkConfiguration = new SparkConfiguration();
+    private SparkBinding sparkBinding = new DefaultSparkBinding();
+
+    public SparkComponent() {
+        super(SparkEndpoint.class);
+    }
+
+    public int getPort() {
+        return port;
+    }
+
+    public void setPort(int port) {
+        this.port = port;
+    }
+
+    public SparkConfiguration getSparkConfiguration() {
+        return sparkConfiguration;
+    }
+
+    public void setSparkConfiguration(SparkConfiguration sparkConfiguration) {
+        this.sparkConfiguration = sparkConfiguration;
+    }
+
+    public SparkBinding getSparkBinding() {
+        return sparkBinding;
+    }
+
+    public void setSparkBinding(SparkBinding sparkBinding) {
+        this.sparkBinding = sparkBinding;
+    }
+
+    @Override
+    protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
+        SparkEndpoint answer = new SparkEndpoint(uri, this);
+        answer.setSparkConfiguration(getSparkConfiguration());
+        answer.setSparkBinding(getSparkBinding());
+        setProperties(answer, parameters);
+
+        if (!remaining.contains(":")) {
+            throw new IllegalArgumentException("Invalid syntax. Must be spark-rest:verb:path");
+        }
+
+        String verb = ObjectHelper.before(remaining, ":");
+        String path = ObjectHelper.after(remaining, ":");
+
+        answer.setVerb(verb);
+        answer.setPath(path);
+
+        return answer;
+    }
+
+    @Override
+    protected void doStart() throws Exception {
+        super.doStart();
+
+        if (getPort() != SparkBase.SPARK_DEFAULT_PORT) {
+            Spark.setPort(getPort());
+        }
+    }
+
+    @Override
+    protected void doShutdown() throws Exception {
+        super.doShutdown();
+        Spark.stop();
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/3c2252aa/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
new file mode 100644
index 0000000..a6a72a7
--- /dev/null
+++ b/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkConfiguration.java
@@ -0,0 +1,65 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.sparkrest;
+
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriParams;
+
+@UriParams
+public class SparkConfiguration {
+
+    @UriParam
+    private boolean mapHeaders = true;
+    @UriParam
+    private boolean disableStreamCache;
+    @UriParam
+    private boolean urlDecodeHeaders;
+    @UriParam
+    private boolean transferException;
+
+    public boolean isMapHeaders() {
+        return mapHeaders;
+    }
+
+    public void setMapHeaders(boolean mapHeaders) {
+        this.mapHeaders = mapHeaders;
+    }
+
+    public boolean isDisableStreamCache() {
+        return disableStreamCache;
+    }
+
+    public void setDisableStreamCache(boolean disableStreamCache) {
+        this.disableStreamCache = disableStreamCache;
+    }
+
+    public boolean isUrlDecodeHeaders() {
+        return urlDecodeHeaders;
+    }
+
+    public void setUrlDecodeHeaders(boolean urlDecodeHeaders) {
+        this.urlDecodeHeaders = urlDecodeHeaders;
+    }
+
+    public boolean isTransferException() {
+        return transferException;
+    }
+
+    public void setTransferException(boolean transferException) {
+        this.transferException = transferException;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/3c2252aa/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkConstants.java
----------------------------------------------------------------------
diff --git a/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkConstants.java b/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkConstants.java
new file mode 100644
index 0000000..96aa5ea
--- /dev/null
+++ b/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkConstants.java
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.sparkrest;
+
+public final class SparkConstants {
+
+    public static final String CONTENT_TYPE_JAVA_SERIALIZED_OBJECT = "application/x-java-serialized-object";
+    public static final String SPLAT = "splat";
+
+    private SparkConstants() {
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/3c2252aa/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
new file mode 100644
index 0000000..1786700
--- /dev/null
+++ b/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkConsumer.java
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.sparkrest;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Processor;
+import org.apache.camel.impl.DefaultConsumer;
+
+public class SparkConsumer extends DefaultConsumer {
+
+    private final CamelSparkRoute route;
+
+    public SparkConsumer(Endpoint endpoint, Processor processor, CamelSparkRoute route) {
+        super(endpoint, processor);
+        this.route = route;
+    }
+
+    @Override
+    public SparkEndpoint getEndpoint() {
+        return (SparkEndpoint) super.getEndpoint();
+    }
+
+    @Override
+    protected void doStart() throws Exception {
+        super.doStart();
+
+        String verb = getEndpoint().getVerb();
+        String path = getEndpoint().getPath();
+        String accept = getEndpoint().getAccept();
+
+        if (accept != null) {
+            log.debug("Spark-rest: {}({}) accepting: {}", new Object[]{verb, path, accept});
+        } else {
+            log.debug("Spark-rest: {}({})", verb, path);
+        }
+        CamelSpark.spark(verb, path, accept, route);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/3c2252aa/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkConverter.java
----------------------------------------------------------------------
diff --git a/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkConverter.java b/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkConverter.java
new file mode 100644
index 0000000..1d977a0
--- /dev/null
+++ b/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkConverter.java
@@ -0,0 +1,79 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.sparkrest;
+
+import org.apache.camel.Converter;
+import org.apache.camel.Exchange;
+import org.apache.camel.FallbackConverter;
+import org.apache.camel.spi.TypeConverterRegistry;
+import spark.Request;
+import spark.Response;
+
+@Converter
+public final class SparkConverter {
+
+    /**
+     * A fallback converter that allows us to easily call Java beans and use the raw Spark {@link Request} as parameter types.
+     */
+    @FallbackConverter
+    public static Object convertToRequest(Class<?> type, Exchange exchange, Object value, TypeConverterRegistry registry) {
+        // if we want to covert to Request
+        if (value != null && Request.class.isAssignableFrom(type)) {
+
+            // okay we may need to cheat a bit when we want to grab the HttpRequest as its stored on the NettyHttpMessage
+            // so if the message instance is a NettyHttpMessage and its body is the value, then we can grab the
+            // HttpRequest from the NettyHttpMessage
+            SparkMessage msg;
+            if (exchange.hasOut()) {
+                msg = exchange.getOut(SparkMessage.class);
+            } else {
+                msg = exchange.getIn(SparkMessage.class);
+            }
+            if (msg != null) {
+                return msg.getRequest();
+            }
+        }
+
+        return null;
+    }
+
+    /**
+     * A fallback converter that allows us to easily call Java beans and use the raw Spark {@link Response} as parameter types.
+     */
+    @FallbackConverter
+    public static Object convertToResponse(Class<?> type, Exchange exchange, Object value, TypeConverterRegistry registry) {
+        // if we want to covert to Response
+        if (value != null && Response.class.isAssignableFrom(type)) {
+
+            // okay we may need to cheat a bit when we want to grab the HttpRequest as its stored on the NettyHttpMessage
+            // so if the message instance is a NettyHttpMessage and its body is the value, then we can grab the
+            // HttpRequest from the NettyHttpMessage
+            SparkMessage msg;
+            if (exchange.hasOut()) {
+                msg = exchange.getOut(SparkMessage.class);
+            } else {
+                msg = exchange.getIn(SparkMessage.class);
+            }
+            if (msg != null) {
+                return msg.getResponse();
+            }
+        }
+
+        return null;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/3c2252aa/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
new file mode 100644
index 0000000..63a3b1f
--- /dev/null
+++ b/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkEndpoint.java
@@ -0,0 +1,115 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.sparkrest;
+
+import org.apache.camel.Component;
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.impl.DefaultEndpoint;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.util.ObjectHelper;
+import spark.route.HttpMethod;
+
+@UriEndpoint(scheme = "spark", consumerClass =  SparkConsumer.class)
+public class SparkEndpoint extends DefaultEndpoint {
+
+    @UriParam
+    SparkConfiguration sparkConfiguration;
+    @UriParam
+    private SparkBinding sparkBinding;
+    @UriParam
+    private String verb;
+    @UriParam
+    private String path;
+    @UriParam
+    private String accept;
+
+    public SparkEndpoint(String endpointUri, Component component) {
+        super(endpointUri, component);
+    }
+
+    public SparkConfiguration getSparkConfiguration() {
+        return sparkConfiguration;
+    }
+
+    public void setSparkConfiguration(SparkConfiguration sparkConfiguration) {
+        this.sparkConfiguration = sparkConfiguration;
+    }
+
+    public SparkBinding getSparkBinding() {
+        return sparkBinding;
+    }
+
+    public void setSparkBinding(SparkBinding sparkBinding) {
+        this.sparkBinding = sparkBinding;
+    }
+
+    public String getVerb() {
+        return verb;
+    }
+
+    public void setVerb(String verb) {
+        this.verb = verb;
+    }
+
+    public String getPath() {
+        return path;
+    }
+
+    public void setPath(String path) {
+        this.path = path;
+    }
+
+    public String getAccept() {
+        return accept;
+    }
+
+    public void setAccept(String accept) {
+        this.accept = accept;
+    }
+
+    @Override
+    public Producer createProducer() throws Exception {
+        throw new UnsupportedOperationException("Producer not supported");
+    }
+
+    @Override
+    public Consumer createConsumer(Processor processor) throws Exception {
+        CamelSparkRoute route = new CamelSparkRoute(this, processor);
+        Consumer consumer = new SparkConsumer(this, processor, route);
+        configureConsumer(consumer);
+        return consumer;
+    }
+
+    @Override
+    public boolean isSingleton() {
+        return true;
+    }
+
+    @Override
+    protected void doStart() throws Exception {
+        super.doStart();
+
+        ObjectHelper.notEmpty(verb, "verb", this);
+        ObjectHelper.notEmpty(path, "path", this);
+
+        // verb must be supported by Spark
+        HttpMethod.valueOf(verb);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/3c2252aa/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkHeaderFilterStrategy.java
----------------------------------------------------------------------
diff --git a/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkHeaderFilterStrategy.java b/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkHeaderFilterStrategy.java
new file mode 100644
index 0000000..8776612
--- /dev/null
+++ b/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkHeaderFilterStrategy.java
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.sparkrest;
+
+import org.apache.camel.impl.DefaultHeaderFilterStrategy;
+
+/**
+ * Default Spark {@link org.apache.camel.spi.HeaderFilterStrategy} used when binding with {@link org.apache.camel.component.sparkrest.SparkBinding}.
+ */
+public class SparkHeaderFilterStrategy extends DefaultHeaderFilterStrategy {
+
+    public SparkHeaderFilterStrategy() {
+        initialize();
+    }
+
+    protected void initialize() {
+        getOutFilter().add("content-length");
+        getOutFilter().add("content-type");
+        getOutFilter().add("host");
+        getOutFilter().add("user-agent");
+        // Add the filter for the Generic Message header
+        // http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.5
+        getOutFilter().add("cache-control");
+        getOutFilter().add("connection");
+        getOutFilter().add("date");
+        getOutFilter().add("pragma");
+        getOutFilter().add("trailer");
+        getOutFilter().add("transfer-encoding");
+        getOutFilter().add("upgrade");
+        getOutFilter().add("via");
+        getOutFilter().add("warning");
+
+        setLowerCase(true);
+
+        // filter headers begin with "Camel" or "org.apache.camel"
+        // must ignore case for Http based transports
+        setOutFilterPattern("(?i)(Camel|org\\.apache\\.camel)[\\.|a-z|A-z|0-9]*");
+
+        // filter out splat as its an internal header
+        getOutFilter().add(SparkConstants.SPLAT);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/3c2252aa/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkHelper.java
----------------------------------------------------------------------
diff --git a/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkHelper.java b/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkHelper.java
new file mode 100644
index 0000000..686b98c
--- /dev/null
+++ b/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkHelper.java
@@ -0,0 +1,56 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.sparkrest;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public final class SparkHelper {
+
+    private SparkHelper() {
+    }
+
+    /**
+     * Appends the key/value to the headers.
+     * <p/>
+     * This implementation supports keys with multiple values. In such situations the value
+     * will be a {@link java.util.List} that contains the multiple values.
+     *
+     * @param headers  headers
+     * @param key      the key
+     * @param value    the value
+     */
+    @SuppressWarnings("unchecked")
+    public static void appendHeader(Map<String, Object> headers, String key, Object value) {
+        if (headers.containsKey(key)) {
+            Object existing = headers.get(key);
+            List<Object> list;
+            if (existing instanceof List) {
+                list = (List<Object>) existing;
+            } else {
+                list = new ArrayList<Object>();
+                list.add(existing);
+            }
+            list.add(value);
+            value = list;
+        }
+
+        headers.put(key, value);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/3c2252aa/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkMessage.java
----------------------------------------------------------------------
diff --git a/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkMessage.java b/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkMessage.java
new file mode 100644
index 0000000..d38cb5e
--- /dev/null
+++ b/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkMessage.java
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.sparkrest;
+
+import org.apache.camel.impl.DefaultMessage;
+import spark.Request;
+import spark.Response;
+
+/**
+ * Spark based {@link org.apache.camel.Message}.
+ * <p/>
+ * This implementation allows direct access to the Spark {@link Request} using
+ * the {@link #getRequest()} method.
+ */
+public class SparkMessage extends DefaultMessage {
+
+    private final transient Request request;
+    private final transient Response response;
+
+    public SparkMessage(Request request, Response response) {
+        this.request = request;
+        this.response = response;
+    }
+
+    public Request getRequest() {
+        return request;
+    }
+
+    public Response getResponse() {
+        return response;
+    }
+
+    @Override
+    public DefaultMessage newInstance() {
+        return new SparkMessage(request, response);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/3c2252aa/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkRouteBuilder.java
----------------------------------------------------------------------
diff --git a/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkRouteBuilder.java b/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkRouteBuilder.java
new file mode 100644
index 0000000..2265da8
--- /dev/null
+++ b/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkRouteBuilder.java
@@ -0,0 +1,91 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.sparkrest;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.model.RouteDefinition;
+
+/**
+ * A Spark extended {@link org.apache.camel.builder.RouteBuilder} which allows to define routes using the Spark DSL.
+ */
+public abstract class SparkRouteBuilder extends RouteBuilder {
+
+    public RouteDefinition get(String path) {
+        return from("spark-rest:get:" + path);
+    }
+
+    public RouteDefinition get(String path, String accept) {
+        return from("spark-rest:get:" + path + "?accept=" + accept);
+    }
+
+    public RouteDefinition post(String path) {
+        return from("spark-rest:post:" + path);
+    }
+
+    public RouteDefinition post(String path, String accept) {
+        return from("spark-rest:post:" + path + "?accept=" + accept);
+    }
+
+    public RouteDefinition put(String path) {
+        return from("spark-rest:post:" + path);
+    }
+
+    public RouteDefinition put(String path, String accept) {
+        return from("spark-rest:post:" + path + "?accept=" + accept);
+    }
+
+    public RouteDefinition delete(String path) {
+        return from("spark-rest:delete:" + path);
+    }
+
+    public RouteDefinition delete(String path, String accept) {
+        return from("spark-rest:delete:" + path + "?accept=" + accept);
+    }
+
+    public RouteDefinition head(String path) {
+        return from("spark-rest:head:" + path);
+    }
+
+    public RouteDefinition head(String path, String accept) {
+        return from("spark-rest:head:" + path + "?accept=" + accept);
+    }
+
+    public RouteDefinition trace(String path) {
+        return from("spark-rest:trace:" + path);
+    }
+
+    public RouteDefinition trace(String path, String accept) {
+        return from("spark-rest:trace:" + path + "?accept=" + accept);
+    }
+
+    public RouteDefinition connect(String path) {
+        return from("spark-rest:connect:" + path);
+    }
+
+    public RouteDefinition connect(String path, String accept) {
+        return from("spark-rest:connect:" + path + "?accept=" + accept);
+    }
+
+    public RouteDefinition options(String path) {
+        return from("spark-rest:options:" + path);
+    }
+
+    public RouteDefinition options(String path, String accept) {
+        return from("spark-rest:options:" + path + "?accept=" + accept);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/3c2252aa/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkServletContextListener.java
----------------------------------------------------------------------
diff --git a/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkServletContextListener.java b/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkServletContextListener.java
new file mode 100644
index 0000000..1d1987a
--- /dev/null
+++ b/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkServletContextListener.java
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.sparkrest;
+
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import spark.Access;
+
+/**
+ * A {@link javax.servlet.ServletContextListener} to ensure we initialize Spark in servlet mode.
+ */
+public class SparkServletContextListener implements ServletContextListener {
+
+    private static final Logger LOG = LoggerFactory.getLogger(ServletSparkApplication.class);
+
+    @Override
+    public void contextInitialized(ServletContextEvent event) {
+        LOG.info("contextInitialized");
+        // force spark to be in Servlet mode
+        Access.runFromServlet();
+    }
+
+    @Override
+    public void contextDestroyed(ServletContextEvent event) {
+        LOG.info("contextDestroyed");
+        // noop
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/3c2252aa/components/camel-spark-rest/src/main/resources/META-INF/LICENSE.txt
----------------------------------------------------------------------
diff --git a/components/camel-spark-rest/src/main/resources/META-INF/LICENSE.txt b/components/camel-spark-rest/src/main/resources/META-INF/LICENSE.txt
new file mode 100755
index 0000000..6b0b127
--- /dev/null
+++ b/components/camel-spark-rest/src/main/resources/META-INF/LICENSE.txt
@@ -0,0 +1,203 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed 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
+
+   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.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+

http://git-wip-us.apache.org/repos/asf/camel/blob/3c2252aa/components/camel-spark-rest/src/main/resources/META-INF/NOTICE.txt
----------------------------------------------------------------------
diff --git a/components/camel-spark-rest/src/main/resources/META-INF/NOTICE.txt b/components/camel-spark-rest/src/main/resources/META-INF/NOTICE.txt
new file mode 100644
index 0000000..2e215bf
--- /dev/null
+++ b/components/camel-spark-rest/src/main/resources/META-INF/NOTICE.txt
@@ -0,0 +1,11 @@
+   =========================================================================
+   ==  NOTICE file corresponding to the section 4 d of                    ==
+   ==  the Apache License, Version 2.0,                                   ==
+   ==  in this case for the Apache Camel distribution.                    ==
+   =========================================================================
+
+   This product includes software developed by
+   The Apache Software Foundation (http://www.apache.org/).
+
+   Please read the different LICENSE files present in the licenses directory of
+   this distribution.

http://git-wip-us.apache.org/repos/asf/camel/blob/3c2252aa/components/camel-spark-rest/src/main/resources/META-INF/services/org/apache/camel/TypeConverter
----------------------------------------------------------------------
diff --git a/components/camel-spark-rest/src/main/resources/META-INF/services/org/apache/camel/TypeConverter b/components/camel-spark-rest/src/main/resources/META-INF/services/org/apache/camel/TypeConverter
new file mode 100644
index 0000000..e22750f
--- /dev/null
+++ b/components/camel-spark-rest/src/main/resources/META-INF/services/org/apache/camel/TypeConverter
@@ -0,0 +1,18 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# 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
+#
+# 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.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+org.apache.camel.component.sparkrest.SparkConverter
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/3c2252aa/components/camel-spark-rest/src/main/resources/META-INF/services/org/apache/camel/component/spark-rest
----------------------------------------------------------------------
diff --git a/components/camel-spark-rest/src/main/resources/META-INF/services/org/apache/camel/component/spark-rest b/components/camel-spark-rest/src/main/resources/META-INF/services/org/apache/camel/component/spark-rest
new file mode 100644
index 0000000..e23e98b
--- /dev/null
+++ b/components/camel-spark-rest/src/main/resources/META-INF/services/org/apache/camel/component/spark-rest
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# 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
+#
+# 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.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+class=org.apache.camel.component.sparkrest.SparkComponent

http://git-wip-us.apache.org/repos/asf/camel/blob/3c2252aa/components/camel-spark-rest/src/test/java/org/apache/camel/component/sparkrest/BaseSparkTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spark-rest/src/test/java/org/apache/camel/component/sparkrest/BaseSparkTest.java b/components/camel-spark-rest/src/test/java/org/apache/camel/component/sparkrest/BaseSparkTest.java
new file mode 100644
index 0000000..2edf49a1
--- /dev/null
+++ b/components/camel-spark-rest/src/test/java/org/apache/camel/component/sparkrest/BaseSparkTest.java
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.sparkrest;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.test.AvailablePortFinder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+
+public abstract class BaseSparkTest extends CamelTestSupport {
+
+    protected int port;
+
+    public int getPort() {
+        return port;
+    }
+
+    @Override
+    public void setUp() throws Exception {
+        port = AvailablePortFinder.getNextAvailable(24500);
+        super.setUp();
+    }
+
+    @Override
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext context = super.createCamelContext();
+
+        SparkComponent spark = context.getComponent("spark-rest", SparkComponent.class);
+        spark.setPort(port);
+
+        return context;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/3c2252aa/components/camel-spark-rest/src/test/java/org/apache/camel/component/sparkrest/CamelSparkAcceptTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spark-rest/src/test/java/org/apache/camel/component/sparkrest/CamelSparkAcceptTest.java b/components/camel-spark-rest/src/test/java/org/apache/camel/component/sparkrest/CamelSparkAcceptTest.java
new file mode 100644
index 0000000..e68785b
--- /dev/null
+++ b/components/camel-spark-rest/src/test/java/org/apache/camel/component/sparkrest/CamelSparkAcceptTest.java
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.sparkrest;
+
+import org.apache.camel.CamelExecutionException;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.http.HttpOperationFailedException;
+import org.junit.Test;
+
+public class CamelSparkAcceptTest extends BaseSparkTest {
+
+    @Test
+    public void testSparkGet() throws Exception {
+        getMockEndpoint("mock:foo").expectedMessageCount(1);
+
+        try {
+            template.requestBodyAndHeader("http://0.0.0.0:" + getPort() + "/hello", null, "Accept", "text/plain", String.class);
+            fail("Should fail");
+        } catch (CamelExecutionException e) {
+            HttpOperationFailedException cause = assertIsInstanceOf(HttpOperationFailedException.class, e.getCause());
+            assertEquals(404, cause.getStatusCode());
+        }
+
+        String out2 = template.requestBodyAndHeader("http://0.0.0.0:" + getPort() + "/hello", null, "Accept", "application/json", String.class);
+        assertEquals("{ \"reply\": \"Bye World\" }", out2);
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("spark-rest:get:hello?accept=application/json")
+                        .to("mock:foo")
+                        .transform().constant("{ \"reply\": \"Bye World\" }");
+            }
+        };
+    }
+}


Mime
View raw message