You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2014/09/28 08:18:21 UTC
[1/3] git commit: CAMEL-7848 Added support for registry's encoders
and decoders
Repository: camel
Updated Branches:
refs/heads/master c9e1bc87e -> a3e20778c
CAMEL-7848 Added support for registry's encoders and decoders
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/4b8521fa
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/4b8521fa
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/4b8521fa
Branch: refs/heads/master
Commit: 4b8521fa7b87aadc9d58ef695199c1aa5b8ec591
Parents: c9e1bc8
Author: Willem Jiang <wi...@gmail.com>
Authored: Sun Sep 28 13:59:49 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Sun Sep 28 13:59:49 2014 +0800
----------------------------------------------------------------------
.../netty/http/HttpClientPipelineFactory.java | 24 +++++++++++++++++++-
.../netty/http/HttpServerPipelineFactory.java | 23 +++++++++++++++++++
2 files changed, 46 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/4b8521fa/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpClientPipelineFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpClientPipelineFactory.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpClientPipelineFactory.java
index b5d2d4d..846d690 100644
--- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpClientPipelineFactory.java
+++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpClientPipelineFactory.java
@@ -16,11 +16,13 @@
*/
package org.apache.camel.component.netty.http;
+import java.util.List;
import java.util.concurrent.TimeUnit;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLEngine;
+import org.apache.camel.component.netty.ChannelHandlerFactory;
import org.apache.camel.component.netty.ClientPipelineFactory;
import org.apache.camel.component.netty.NettyComponent;
import org.apache.camel.component.netty.NettyConfiguration;
@@ -79,6 +81,26 @@ public class HttpClientPipelineFactory extends ClientPipelineFactory {
LOG.debug("Client SSL handler configured and added as an interceptor against the ChannelPipeline: {}", sslHandler);
pipeline.addLast("ssl", sslHandler);
}
+
+ List<ChannelHandler> decoders = producer.getConfiguration().getDecoders();
+ for (int x = 0; x < decoders.size(); x++) {
+ ChannelHandler decoder = decoders.get(x);
+ if (decoder instanceof ChannelHandlerFactory) {
+ // use the factory to create a new instance of the channel as it may not be shareable
+ decoder = ((ChannelHandlerFactory) decoder).newChannelHandler();
+ }
+ pipeline.addLast("decoder-" + x, decoder);
+ }
+
+ List<ChannelHandler> encoders = producer.getConfiguration().getEncoders();
+ for (int x = 0; x < encoders.size(); x++) {
+ ChannelHandler encoder = encoders.get(x);
+ if (encoder instanceof ChannelHandlerFactory) {
+ // use the factory to create a new instance of the channel as it may not be shareable
+ encoder = ((ChannelHandlerFactory) encoder).newChannelHandler();
+ }
+ pipeline.addLast("encoder-" + x, encoder);
+ }
pipeline.addLast("http", new HttpClientCodec());
@@ -89,7 +111,7 @@ public class HttpClientPipelineFactory extends ClientPipelineFactory {
ChannelHandler timeout = new ReadTimeoutHandler(NettyComponent.getTimer(), producer.getConfiguration().getRequestTimeout(), TimeUnit.MILLISECONDS);
pipeline.addLast("timeout", timeout);
}
-
+
// handler to route Camel messages
pipeline.addLast("handler", new HttpClientChannelHandler(producer));
http://git-wip-us.apache.org/repos/asf/camel/blob/4b8521fa/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerPipelineFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerPipelineFactory.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerPipelineFactory.java
index 5d705ad..37fc58b 100644
--- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerPipelineFactory.java
+++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerPipelineFactory.java
@@ -16,10 +16,13 @@
*/
package org.apache.camel.component.netty.http;
+import java.util.List;
+
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLEngine;
import org.apache.camel.CamelContext;
+import org.apache.camel.component.netty.ChannelHandlerFactory;
import org.apache.camel.component.netty.NettyConsumer;
import org.apache.camel.component.netty.NettyServerBootstrapConfiguration;
import org.apache.camel.component.netty.ServerPipelineFactory;
@@ -82,6 +85,26 @@ public class HttpServerPipelineFactory extends ServerPipelineFactory {
LOG.debug("Server SSL handler configured and added as an interceptor against the ChannelPipeline: {}", sslHandler);
pipeline.addLast("ssl", sslHandler);
}
+
+ List<ChannelHandler> decoders = consumer.getConfiguration().getDecoders();
+ for (int x = 0; x < decoders.size(); x++) {
+ ChannelHandler decoder = decoders.get(x);
+ if (decoder instanceof ChannelHandlerFactory) {
+ // use the factory to create a new instance of the channel as it may not be shareable
+ decoder = ((ChannelHandlerFactory) decoder).newChannelHandler();
+ }
+ pipeline.addLast("decoder-" + x, decoder);
+ }
+
+ List<ChannelHandler> encoders = consumer.getConfiguration().getEncoders();
+ for (int x = 0; x < encoders.size(); x++) {
+ ChannelHandler encoder = encoders.get(x);
+ if (encoder instanceof ChannelHandlerFactory) {
+ // use the factory to create a new instance of the channel as it may not be shareable
+ encoder = ((ChannelHandlerFactory) encoder).newChannelHandler();
+ }
+ pipeline.addLast("encoder-" + x, encoder);
+ }
pipeline.addLast("decoder", new HttpRequestDecoder());
pipeline.addLast("aggregator", new HttpChunkAggregator(configuration.getChunkedMaxContentLength()));
[3/3] git commit: CAMEL-7876 Fixed the build error and unicode
encoding issue
Posted by ni...@apache.org.
CAMEL-7876 Fixed the build error and unicode encoding issue
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/a3e20778
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/a3e20778
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/a3e20778
Branch: refs/heads/master
Commit: a3e20778c37adcb420f214f34bbdaa28e6c2d10b
Parents: 164d65e
Author: Willem Jiang <wi...@gmail.com>
Authored: Sun Sep 28 14:17:52 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Sun Sep 28 14:17:52 2014 +0800
----------------------------------------------------------------------
.../src/main/java/org/apache/camel/util/GroupIterator.java | 2 +-
.../src/test/java/org/apache/camel/util/GroupIteratorTest.java | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/a3e20778/camel-core/src/main/java/org/apache/camel/util/GroupIterator.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/GroupIterator.java b/camel-core/src/main/java/org/apache/camel/util/GroupIterator.java
index d03e717..b241d18 100644
--- a/camel-core/src/main/java/org/apache/camel/util/GroupIterator.java
+++ b/camel-core/src/main/java/org/apache/camel/util/GroupIterator.java
@@ -155,7 +155,7 @@ public final class GroupIterator implements Iterator<Object>, Closeable {
bos.write(bytes);
} else if (data != null) {
// convert to input stream
- InputStream is = context.getTypeConverter().mandatoryConvertTo(InputStream.class, data);
+ InputStream is = camelContext.getTypeConverter().mandatoryConvertTo(InputStream.class, data);
IOHelper.copy(is, bos);
}
http://git-wip-us.apache.org/repos/asf/camel/blob/a3e20778/camel-core/src/test/java/org/apache/camel/util/GroupIteratorTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/util/GroupIteratorTest.java b/camel-core/src/test/java/org/apache/camel/util/GroupIteratorTest.java
index fb5c5c7..2aeef2f 100644
--- a/camel-core/src/test/java/org/apache/camel/util/GroupIteratorTest.java
+++ b/camel-core/src/test/java/org/apache/camel/util/GroupIteratorTest.java
@@ -72,7 +72,7 @@ public class GroupIteratorTest extends TestSupport {
return;
}
- byte[] buf = "£1\n£2\n".getBytes(StandardCharsets.UTF_8);
+ byte[] buf = "\u00A31\n\u00A32\n".getBytes(StandardCharsets.UTF_8);
ByteArrayInputStream in = new ByteArrayInputStream(buf);
@@ -83,8 +83,8 @@ public class GroupIteratorTest extends TestSupport {
GroupIterator gi = new GroupIterator(exchange, scanner, "\n", 1);
assertTrue(gi.hasNext());
- assertEquals("£1", gi.next());
- assertEquals("£2", gi.next());
+ assertEquals("\u00A31", gi.next());
+ assertEquals("\u00A32", gi.next());
assertFalse(gi.hasNext());
IOHelper.close(gi);
[2/3] git commit: CAMEL-7848 merged the patch to camel-netty4-http
Posted by ni...@apache.org.
CAMEL-7848 merged the patch to camel-netty4-http
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/164d65e7
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/164d65e7
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/164d65e7
Branch: refs/heads/master
Commit: 164d65e7b9ff3952b3c1a5734bef14c94a99a41f
Parents: 4b8521f
Author: Willem Jiang <wi...@gmail.com>
Authored: Sun Sep 28 14:11:33 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Sun Sep 28 14:11:33 2014 +0800
----------------------------------------------------------------------
.../http/HttpClientInitializerFactory.java | 24 +++++++++++++++++-
.../http/HttpServerInitializerFactory.java | 26 ++++++++++++++++++--
2 files changed, 47 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/164d65e7/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpClientInitializerFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpClientInitializerFactory.java b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpClientInitializerFactory.java
index 0cb4742..b19fcf1 100644
--- a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpClientInitializerFactory.java
+++ b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpClientInitializerFactory.java
@@ -16,6 +16,7 @@
*/
package org.apache.camel.component.netty4.http;
+import java.util.List;
import java.util.concurrent.TimeUnit;
import javax.net.ssl.SSLContext;
@@ -28,6 +29,7 @@ import io.netty.handler.codec.http.HttpClientCodec;
import io.netty.handler.codec.http.HttpObjectAggregator;
import io.netty.handler.ssl.SslHandler;
import io.netty.handler.timeout.ReadTimeoutHandler;
+import org.apache.camel.component.netty4.ChannelHandlerFactory;
import org.apache.camel.component.netty4.ClientInitializerFactory;
import org.apache.camel.component.netty4.NettyConfiguration;
import org.apache.camel.component.netty4.NettyProducer;
@@ -82,7 +84,27 @@ public class HttpClientInitializerFactory extends ClientInitializerFactory {
LOG.debug("Client SSL handler configured and added as an interceptor against the ChannelPipeline: {}", sslHandler);
pipeline.addLast("ssl", sslHandler);
}
+
+ List<ChannelHandler> encoders = producer.getConfiguration().getEncoders();
+ for (int x = 0; x < encoders.size(); x++) {
+ ChannelHandler encoder = encoders.get(x);
+ if (encoder instanceof ChannelHandlerFactory) {
+ // use the factory to create a new instance of the channel as it may not be shareable
+ encoder = ((ChannelHandlerFactory) encoder).newChannelHandler();
+ }
+ pipeline.addLast("encoder-" + x, encoder);
+ }
+ List<ChannelHandler> decoders = producer.getConfiguration().getDecoders();
+ for (int x = 0; x < decoders.size(); x++) {
+ ChannelHandler decoder = decoders.get(x);
+ if (decoder instanceof ChannelHandlerFactory) {
+ // use the factory to create a new instance of the channel as it may not be shareable
+ decoder = ((ChannelHandlerFactory) decoder).newChannelHandler();
+ }
+ pipeline.addLast("decoder-" + x, decoder);
+ }
+
pipeline.addLast("http", new HttpClientCodec());
pipeline.addLast("aggregator", new HttpObjectAggregator(configuration.getChunkedMaxContentLength()));
@@ -93,7 +115,7 @@ public class HttpClientInitializerFactory extends ClientInitializerFactory {
ChannelHandler timeout = new ReadTimeoutHandler(producer.getConfiguration().getRequestTimeout(), TimeUnit.MILLISECONDS);
pipeline.addLast("timeout", timeout);
}
-
+
// handler to route Camel messages
pipeline.addLast("handler", new HttpClientChannelHandler(producer));
http://git-wip-us.apache.org/repos/asf/camel/blob/164d65e7/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerInitializerFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerInitializerFactory.java b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerInitializerFactory.java
index a98aef0..6d61945 100644
--- a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerInitializerFactory.java
+++ b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerInitializerFactory.java
@@ -17,6 +17,8 @@
package org.apache.camel.component.netty4.http;
+import java.util.List;
+
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLEngine;
@@ -30,6 +32,7 @@ import io.netty.handler.codec.http.HttpResponseEncoder;
import io.netty.handler.ssl.SslHandler;
import io.netty.util.concurrent.EventExecutorGroup;
import org.apache.camel.CamelContext;
+import org.apache.camel.component.netty4.ChannelHandlerFactory;
import org.apache.camel.component.netty4.NettyConsumer;
import org.apache.camel.component.netty4.NettyServerBootstrapConfiguration;
import org.apache.camel.component.netty4.ServerInitializerFactory;
@@ -83,6 +86,26 @@ public class HttpServerInitializerFactory extends ServerInitializerFactory {
LOG.debug("Server SSL handler configured and added as an interceptor against the ChannelPipeline: {}", sslHandler);
pipeline.addLast("ssl", sslHandler);
}
+
+ List<ChannelHandler> decoders = consumer.getConfiguration().getDecoders();
+ for (int x = 0; x < decoders.size(); x++) {
+ ChannelHandler decoder = decoders.get(x);
+ if (decoder instanceof ChannelHandlerFactory) {
+ // use the factory to create a new instance of the channel as it may not be shareable
+ decoder = ((ChannelHandlerFactory) decoder).newChannelHandler();
+ }
+ pipeline.addLast("decoder-" + x, decoder);
+ }
+
+ List<ChannelHandler> encoders = consumer.getConfiguration().getEncoders();
+ for (int x = 0; x < encoders.size(); x++) {
+ ChannelHandler encoder = encoders.get(x);
+ if (encoder instanceof ChannelHandlerFactory) {
+ // use the factory to create a new instance of the channel as it may not be shareable
+ encoder = ((ChannelHandlerFactory) encoder).newChannelHandler();
+ }
+ pipeline.addLast("encoder-" + x, encoder);
+ }
pipeline.addLast("decoder", new HttpRequestDecoder());
pipeline.addLast("aggregator", new HttpObjectAggregator(configuration.getChunkedMaxContentLength()));
@@ -91,7 +114,7 @@ public class HttpServerInitializerFactory extends ServerInitializerFactory {
if (supportCompressed()) {
pipeline.addLast("deflater", new HttpContentCompressor());
}
-
+
int port = consumer.getConfiguration().getPort();
ChannelHandler handler = consumer.getEndpoint().getComponent().getMultiplexChannelHandler(port).getChannelHandler();
@@ -101,7 +124,6 @@ public class HttpServerInitializerFactory extends ServerInitializerFactory {
} else {
pipeline.addLast("handler", handler);
}
-
}
private SSLContext createSSLContext(CamelContext camelContext, NettyServerBootstrapConfiguration configuration) throws Exception {