camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
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 GMT
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 <freeman.fang@gmail.com>
Authored: Wed Feb 11 15:40:40 2015 +0800
Committer: Freeman Fang <freeman.fang@gmail.com>
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 @@
     <abdera-version>1.1.3</abdera-version>
     <!-- Note that activemq dependency is only used for testing! -->
     <activemq-version>5.11.0</activemq-version>
-    <ahc-version>1.9.0</ahc-version>
+    <ahc-version>1.9.8</ahc-version>
     <ant-bundle-version>1.7.0_6</ant-bundle-version>
     <antlr-bundle-version>3.4_1</antlr-bundle-version>
     <antlr-runtime-bundle-version>3.4_2</antlr-runtime-bundle-version>


Mime
View raw message