Return-Path: X-Original-To: apmail-camel-commits-archive@www.apache.org Delivered-To: apmail-camel-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 137C310016 for ; Wed, 11 Feb 2015 07:41:31 +0000 (UTC) Received: (qmail 94235 invoked by uid 500); 11 Feb 2015 07:41:31 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 94183 invoked by uid 500); 11 Feb 2015 07:41:31 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 94174 invoked by uid 99); 11 Feb 2015 07:41:31 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 Feb 2015 07:41:31 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id D1F58E01CB; Wed, 11 Feb 2015 07:41:30 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ffang@apache.org To: commits@camel.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: camel git commit: [CAMEL-8333]upgrade to 1.9.8 instead of 1.9.0 and fix compilation error in camel-ahc-ws component Date: Wed, 11 Feb 2015 07:41:30 +0000 (UTC) Repository: camel Updated Branches: refs/heads/master 5b4ac7886 -> fee91e7b0 [CAMEL-8333]upgrade to 1.9.8 instead of 1.9.0 and fix compilation error in camel-ahc-ws component Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/fee91e7b Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/fee91e7b Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/fee91e7b Branch: refs/heads/master Commit: fee91e7b01b1bf737a709f245db1f556188a8f4c Parents: 5b4ac78 Author: Freeman Fang Authored: Wed Feb 11 15:40:40 2015 +0800 Committer: Freeman Fang Committed: Wed Feb 11 15:40:40 2015 +0800 ---------------------------------------------------------------------- .../camel/component/ahc/ws/WsEndpoint.java | 60 ++------------------ .../camel/component/ahc/ws/WsProducer.java | 10 ++-- parent/pom.xml | 2 +- 3 files changed, 12 insertions(+), 60 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/fee91e7b/components/camel-ahc-ws/src/main/java/org/apache/camel/component/ahc/ws/WsEndpoint.java ---------------------------------------------------------------------- diff --git a/components/camel-ahc-ws/src/main/java/org/apache/camel/component/ahc/ws/WsEndpoint.java b/components/camel-ahc-ws/src/main/java/org/apache/camel/component/ahc/ws/WsEndpoint.java index 79ca966..32c0203 100644 --- a/components/camel-ahc-ws/src/main/java/org/apache/camel/component/ahc/ws/WsEndpoint.java +++ b/components/camel-ahc-ws/src/main/java/org/apache/camel/component/ahc/ws/WsEndpoint.java @@ -16,9 +16,6 @@ */ package org.apache.camel.component.ahc.ws; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.CharArrayReader; import java.io.IOException; import java.util.HashSet; import java.util.Set; @@ -28,10 +25,10 @@ import com.ning.http.client.AsyncHttpClient; import com.ning.http.client.AsyncHttpClientConfig; import com.ning.http.client.AsyncHttpProvider; import com.ning.http.client.providers.grizzly.GrizzlyAsyncHttpProvider; -import com.ning.http.client.websocket.WebSocket; -import com.ning.http.client.websocket.WebSocketByteListener; -import com.ning.http.client.websocket.WebSocketTextListener; -import com.ning.http.client.websocket.WebSocketUpgradeHandler; +import com.ning.http.client.ws.WebSocket; +import com.ning.http.client.ws.WebSocketByteListener; +import com.ning.http.client.ws.WebSocketTextListener; +import com.ning.http.client.ws.WebSocketUpgradeHandler; import org.apache.camel.Consumer; import org.apache.camel.Processor; import org.apache.camel.Producer; @@ -153,9 +150,7 @@ public class WsEndpoint extends AhcEndpoint { } class WsListener implements WebSocketTextListener, WebSocketByteListener { - private ByteArrayOutputStream byteBuffer = new ByteArrayOutputStream(); - private StringBuffer textBuffer = new StringBuffer(); - + @Override public void onOpen(WebSocket websocket) { LOG.debug("websocket opened"); @@ -179,30 +174,7 @@ public class WsEndpoint extends AhcEndpoint { } } - @Override - public void onFragment(byte[] fragment, boolean last) { - if (LOG.isDebugEnabled()) { - LOG.debug("received fragment({}) --> {}", last, fragment); - } - // for now, construct a memory based stream. In future, we provide a fragmented stream that can - // be consumed before the final fragment is added. - synchronized (byteBuffer) { - try { - byteBuffer.write(fragment); - } catch (IOException e) { - //ignore - } - if (last) { - //REVIST avoid using baos/bais that waste memory - byte[] msg = byteBuffer.toByteArray(); - for (WsConsumer consumer : consumers) { - consumer.sendMessage(new ByteArrayInputStream(msg)); - } - byteBuffer.reset(); - } - } - } - + @Override public void onMessage(String message) { @@ -212,26 +184,6 @@ public class WsEndpoint extends AhcEndpoint { } } - @Override - public void onFragment(String fragment, boolean last) { - if (LOG.isDebugEnabled()) { - LOG.debug("received fragment({}) --> {}", last, fragment); - } - // for now, construct a memory based stream. In future, we provide a fragmented stream that can - // be consumed before the final fragment is added. - synchronized (textBuffer) { - textBuffer.append(fragment); - if (last) { - //REVIST avoid using sb/car that waste memory - char[] msg = new char[textBuffer.length()]; - textBuffer.getChars(0, msg.length, msg, 0); - for (WsConsumer consumer : consumers) { - consumer.sendMessage(new CharArrayReader(msg)); - } - textBuffer.setLength(0); - } - } - } } http://git-wip-us.apache.org/repos/asf/camel/blob/fee91e7b/components/camel-ahc-ws/src/main/java/org/apache/camel/component/ahc/ws/WsProducer.java ---------------------------------------------------------------------- diff --git a/components/camel-ahc-ws/src/main/java/org/apache/camel/component/ahc/ws/WsProducer.java b/components/camel-ahc-ws/src/main/java/org/apache/camel/component/ahc/ws/WsProducer.java index fe00b93..47a3939 100644 --- a/components/camel-ahc-ws/src/main/java/org/apache/camel/component/ahc/ws/WsProducer.java +++ b/components/camel-ahc-ws/src/main/java/org/apache/camel/component/ahc/ws/WsProducer.java @@ -19,7 +19,7 @@ package org.apache.camel.component.ahc.ws; import java.io.IOException; import java.io.InputStream; -import com.ning.http.client.websocket.WebSocket; +import com.ning.http.client.ws.WebSocket; import org.apache.camel.Exchange; import org.apache.camel.Message; @@ -56,7 +56,7 @@ public class WsProducer extends DefaultProducer { sendStreamMessage(getWebSocket(), (InputStream)message); } else { //TODO provide other binding option, for now use the converted string - getWebSocket().sendTextMessage(in.getMandatoryBody(String.class)); + getWebSocket().sendMessage(in.getMandatoryBody(String.class)); } } } @@ -66,15 +66,15 @@ public class WsProducer extends DefaultProducer { int p = 0; while (p < msg.length()) { if (msg.length() - p < streamBufferSize) { - webSocket.streamText(msg.substring(p), true); + webSocket.stream(msg.substring(p), true); p = msg.length(); } else { - webSocket.streamText(msg.substring(p, streamBufferSize), false); + webSocket.stream(msg.substring(p, streamBufferSize), false); p += streamBufferSize; } } } else { - webSocket.sendTextMessage(msg); + webSocket.sendMessage(msg); } } http://git-wip-us.apache.org/repos/asf/camel/blob/fee91e7b/parent/pom.xml ---------------------------------------------------------------------- diff --git a/parent/pom.xml b/parent/pom.xml index 17062b6..245e734 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -36,7 +36,7 @@ 1.1.3 5.11.0 - 1.9.0 + 1.9.8 1.7.0_6 3.4_1 3.4_2