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 2015/03/31 11:44:24 UTC
[2/4] camel git commit: CAMEL-8576 Added a option to let camel netty
take the message body as byte buffer
CAMEL-8576 Added a option to let camel netty take the message body as byte buffer
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/277aa22f
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/277aa22f
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/277aa22f
Branch: refs/heads/master
Commit: 277aa22f9a600a423e6316dc2ff97190bce04931
Parents: b046a67
Author: Willem Jiang <wi...@gmail.com>
Authored: Tue Mar 31 17:40:49 2015 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Tue Mar 31 17:42:44 2015 +0800
----------------------------------------------------------------------
.../camel/component/netty/NettyConfiguration.java | 12 +++++++++++-
.../camel/component/netty/NettyPayloadHelper.java | 10 ++++++++--
2 files changed, 19 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/277aa22f/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConfiguration.java b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConfiguration.java
index 847ca45..8b9d983 100644
--- a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConfiguration.java
+++ b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConfiguration.java
@@ -94,7 +94,9 @@ public class NettyConfiguration extends NettyServerBootstrapConfiguration implem
private boolean udpConnectionlessSending;
@UriParam(defaultValue = "false")
private boolean clientMode;
-
+ @UriParam(defaultValue = "false")
+ private boolean useChannelBuffer;
+
/**
* Returns a copy of this configuration
*/
@@ -466,6 +468,14 @@ public class NettyConfiguration extends NettyServerBootstrapConfiguration implem
this.clientMode = clientMode;
}
+ public boolean isUseChannelBuffer() {
+ return useChannelBuffer;
+ }
+
+ public void setUseChannelBuffer(boolean useChannelBuffer) {
+ this.useChannelBuffer = useChannelBuffer;
+ }
+
private static <T> void addToHandlersList(List<T> configured, List<T> handlers, Class<T> handlerType) {
if (handlers != null) {
for (T handler : handlers) {
http://git-wip-us.apache.org/repos/asf/camel/blob/277aa22f/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyPayloadHelper.java
----------------------------------------------------------------------
diff --git a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyPayloadHelper.java b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyPayloadHelper.java
index c0839ee..b1dc812 100644
--- a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyPayloadHelper.java
+++ b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyPayloadHelper.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.netty;
import org.apache.camel.Exchange;
import org.apache.camel.impl.DefaultExchangeHolder;
+import org.jboss.netty.buffer.ChannelBuffer;
/**
* Helper to get and set the correct payload when transferring data using camel-netty.
@@ -39,8 +40,13 @@ public final class NettyPayloadHelper {
// we should transfer the entire exchange over the wire (includes in/out)
return DefaultExchangeHolder.marshal(exchange);
} else {
- // normal transfer using the body only
- return exchange.getIn().getBody();
+ if (endpoint.getConfiguration().isUseChannelBuffer()) {
+ // The NettyConverter could help us for it
+ return exchange.getIn().getBody(ChannelBuffer.class);
+ } else {
+ // normal transfer using the body only
+ return exchange.getIn().getBody();
+ }
}
}