camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [10/24] camel git commit: camel-http-common - as a common module
Date Thu, 23 Jul 2015 12:58:12 GMT
camel-http-common - as a common module


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

Branch: refs/heads/master
Commit: d1f6348bddb471d6ca656c834fcb86690249e04c
Parents: 617b196
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Thu Jul 23 10:10:59 2015 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Thu Jul 23 15:04:32 2015 +0200

----------------------------------------------------------------------
 components/camel-undertow/pom.xml               |  9 ++--
 .../undertow/DefaultUndertowHttpBinding.java    |  5 +-
 .../component/undertow/UndertowComponent.java   | 40 ++--------------
 .../undertow/UndertowHeaderFilterStrategy.java  | 49 ++++++++++++++++++++
 .../undertow/UndertowPrefixMatchingTest.java    |  2 +-
 5 files changed, 60 insertions(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/d1f6348b/components/camel-undertow/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-undertow/pom.xml b/components/camel-undertow/pom.xml
index 960a2fe..4f56a50 100644
--- a/components/camel-undertow/pom.xml
+++ b/components/camel-undertow/pom.xml
@@ -42,10 +42,6 @@
       <artifactId>camel-core</artifactId>
     </dependency>
     <dependency>
-      <groupId>org.apache.camel</groupId>
-      <artifactId>camel-http</artifactId>
-    </dependency>
-    <dependency>
       <groupId>io.undertow</groupId>
       <artifactId>undertow-core</artifactId>
       <version>${undertow-version}</version>
@@ -63,6 +59,11 @@
       <scope>test</scope>
     </dependency>
     <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-http</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
       <scope>test</scope>

http://git-wip-us.apache.org/repos/asf/camel/blob/d1f6348b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/DefaultUndertowHttpBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/DefaultUndertowHttpBinding.java
b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/DefaultUndertowHttpBinding.java
index 1be1700..e1d6c7e 100644
--- a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/DefaultUndertowHttpBinding.java
+++ b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/DefaultUndertowHttpBinding.java
@@ -36,7 +36,6 @@ import io.undertow.util.MimeMappings;
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.TypeConverter;
-import org.apache.camel.component.http.HttpHeaderFilterStrategy;
 import org.apache.camel.impl.DefaultMessage;
 import org.apache.camel.spi.HeaderFilterStrategy;
 import org.apache.camel.util.ExchangeHelper;
@@ -48,7 +47,7 @@ import org.xnio.Pooled;
 
 /**
  * DefaultUndertowHttpBinding represent binding used by default, if user doesn't provide
any.
- * By default {@link HttpHeaderFilterStrategy} is also used.
+ * By default {@link UndertowHeaderFilterStrategy} is also used.
  */
 public class DefaultUndertowHttpBinding implements UndertowHttpBinding {
 
@@ -58,7 +57,7 @@ public class DefaultUndertowHttpBinding implements UndertowHttpBinding {
     private HeaderFilterStrategy headerFilterStrategy;
 
     public DefaultUndertowHttpBinding() {
-        this.headerFilterStrategy = new HttpHeaderFilterStrategy();
+        this.headerFilterStrategy = new UndertowHeaderFilterStrategy();
     }
 
     public DefaultUndertowHttpBinding(HeaderFilterStrategy headerFilterStrategy) {

http://git-wip-us.apache.org/repos/asf/camel/blob/d1f6348b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowComponent.java
b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowComponent.java
index 8d08000..e1ffb30 100644
--- a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowComponent.java
+++ b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowComponent.java
@@ -28,12 +28,9 @@ import org.apache.camel.CamelContext;
 import org.apache.camel.Consumer;
 import org.apache.camel.Endpoint;
 import org.apache.camel.Processor;
-import org.apache.camel.component.http.HttpBinding;
-import org.apache.camel.component.http.HttpClientConfigurer;
-import org.apache.camel.component.http.HttpComponent;
-import org.apache.camel.component.http.HttpConfiguration;
 import org.apache.camel.component.undertow.handlers.HttpCamelHandler;
 import org.apache.camel.component.undertow.handlers.NotFoundHandler;
+import org.apache.camel.impl.UriEndpointComponent;
 import org.apache.camel.spi.HeaderFilterStrategy;
 import org.apache.camel.spi.RestConfiguration;
 import org.apache.camel.spi.RestConsumerFactory;
@@ -41,20 +38,20 @@ import org.apache.camel.util.FileUtil;
 import org.apache.camel.util.URISupport;
 import org.apache.camel.util.UnsafeUriCharactersEncoder;
 import org.apache.camel.util.jsse.SSLContextParameters;
-import org.apache.commons.httpclient.HttpConnectionManager;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
  * Represents the component that manages {@link UndertowEndpoint}.
  */
-public class UndertowComponent extends HttpComponent implements RestConsumerFactory {
+public class UndertowComponent extends UriEndpointComponent implements RestConsumerFactory
{
     private static final Logger LOG = LoggerFactory.getLogger(UndertowEndpoint.class);
 
     private UndertowHttpBinding undertowHttpBinding;
     private Map<Integer, UndertowRegistry> serversRegistry = new HashMap<Integer,
UndertowRegistry>();
 
     public UndertowComponent() {
+        super(UndertowEndpoint.class);
         this.undertowHttpBinding = new DefaultUndertowHttpBinding();
     }
 
@@ -233,22 +230,6 @@ public class UndertowComponent extends HttpComponent implements RestConsumerFact
         undertowRegistry.setServer(newServer);
     }
 
-    /**
-     * To use the custom HttpClientConfigurer to perform configuration of the HttpClient
that will be used.
-     */
-    @Override
-    public void setHttpClientConfigurer(HttpClientConfigurer httpClientConfigurer) {
-        super.setHttpClientConfigurer(httpClientConfigurer);
-    }
-
-    /**
-     * To use a custom HttpConnectionManager to manage connections
-     */
-    @Override
-    public void setHttpConnectionManager(HttpConnectionManager httpConnectionManager) {
-        super.setHttpConnectionManager(httpConnectionManager);
-    }
-
     public UndertowHttpBinding getUndertowHttpBinding() {
         return undertowHttpBinding;
     }
@@ -260,19 +241,4 @@ public class UndertowComponent extends HttpComponent implements RestConsumerFact
         this.undertowHttpBinding = undertowHttpBinding;
     }
 
-    /**
-     * To use a custom HttpBinding to control the mapping between Camel message and HttpClient.
-     */
-    @Override
-    public void setHttpBinding(HttpBinding httpBinding) {
-        super.setHttpBinding(httpBinding);
-    }
-
-    /**
-     * To use the shared HttpConfiguration as base configuration.
-     */
-    @Override
-    public void setHttpConfiguration(HttpConfiguration httpConfiguration) {
-        super.setHttpConfiguration(httpConfiguration);
-    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/d1f6348b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowHeaderFilterStrategy.java
----------------------------------------------------------------------
diff --git a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowHeaderFilterStrategy.java
b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowHeaderFilterStrategy.java
new file mode 100644
index 0000000..b16824e
--- /dev/null
+++ b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowHeaderFilterStrategy.java
@@ -0,0 +1,49 @@
+/**
+ * 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.undertow;
+
+import org.apache.camel.impl.DefaultHeaderFilterStrategy;
+
+public class UndertowHeaderFilterStrategy extends DefaultHeaderFilterStrategy {
+    
+    public UndertowHeaderFilterStrategy() {
+        initialize();  
+    }
+
+    protected void initialize() {
+        getOutFilter().add("content-length");
+        getOutFilter().add("content-type");
+        getOutFilter().add("host");
+        // 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]*");
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/d1f6348b/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowPrefixMatchingTest.java
----------------------------------------------------------------------
diff --git a/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowPrefixMatchingTest.java
b/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowPrefixMatchingTest.java
index 34f1b62..dd227d8 100644
--- a/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowPrefixMatchingTest.java
+++ b/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowPrefixMatchingTest.java
@@ -19,7 +19,7 @@ package org.apache.camel.component.undertow;
 import org.apache.camel.CamelExecutionException;
 import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.http.HttpOperationFailedException;
+import org.apache.camel.http.common.HttpOperationFailedException;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;


Mime
View raw message