activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [3/4] activemq-artemis git commit: Auto-add content-length to STOMP 1.1 frames too, inherit 1.2 from 1.1
Date Mon, 13 Jul 2015 13:37:52 GMT
Auto-add content-length to STOMP 1.1 frames too, inherit 1.2 from 1.1


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/851ac30f
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/851ac30f
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/851ac30f

Branch: refs/heads/master
Commit: 851ac30f326948d4af041cfc96e9e3c588fbcbfd
Parents: 2f6d3dc
Author: Ville Skyttä <ville.skytta@iki.fi>
Authored: Fri Jul 10 14:43:00 2015 +0300
Committer: Ville Skyttä <ville.skytta@iki.fi>
Committed: Fri Jul 10 14:43:00 2015 +0300

----------------------------------------------------------------------
 .../core/protocol/stomp/v11/StompFrameV11.java  | 11 ++-
 .../core/protocol/stomp/v12/StompFrameV12.java  | 76 +-------------------
 2 files changed, 10 insertions(+), 77 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/851ac30f/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/v11/StompFrameV11.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/v11/StompFrameV11.java
b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/v11/StompFrameV11.java
index 991c9b7..e0572c7 100644
--- a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/v11/StompFrameV11.java
+++ b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/v11/StompFrameV11.java
@@ -29,7 +29,7 @@ import org.apache.activemq.artemis.core.protocol.stomp.StompFrame;
 public class StompFrameV11 extends StompFrame
 {
    //stomp 1.1 talks about repetitive headers.
-   private final List<Header> allHeaders = new ArrayList<Header>();
+   protected final List<Header> allHeaders = new ArrayList<Header>();
 
    public StompFrameV11(String command, Map<String, String> headers, byte[] content)
    {
@@ -66,6 +66,13 @@ public class StompFrameV11 extends StompFrame
             head.append(h.getEncodedValue());
             head.append(Stomp.NEWLINE);
          }
+         if (bytesBody != null && bytesBody.length > 0)
+         {
+            head.append(Stomp.Headers.CONTENT_LENGTH);
+            head.append(Stomp.Headers.SEPARATOR);
+            head.append(bytesBody.length);
+            head.append(Stomp.NEWLINE);
+         }
          // Add a newline to separate the headers from the content.
          head.append(Stomp.NEWLINE);
 
@@ -95,6 +102,4 @@ public class StompFrameV11 extends StompFrame
          allHeaders.add(new Header(key, val));
       }
    }
-
-
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/851ac30f/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/v12/StompFrameV12.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/v12/StompFrameV12.java
b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/v12/StompFrameV12.java
index 67d021b..fdf8a70 100644
--- a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/v12/StompFrameV12.java
+++ b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/v12/StompFrameV12.java
@@ -16,21 +16,12 @@
  */
 package org.apache.activemq.artemis.core.protocol.stomp.v12;
 
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.List;
 import java.util.Map;
 
-import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
-import org.apache.activemq.artemis.api.core.ActiveMQBuffers;
-import org.apache.activemq.artemis.core.protocol.stomp.Stomp;
-import org.apache.activemq.artemis.core.protocol.stomp.StompFrame;
+import org.apache.activemq.artemis.core.protocol.stomp.v11.StompFrameV11;
 
-public class StompFrameV12 extends StompFrame
+public class StompFrameV12 extends StompFrameV11
 {
-   //stomp 1.1 talks about repetitive headers.
-   private final List<Header> allHeaders = new ArrayList<Header>();
-
    public StompFrameV12(String command, Map<String, String> headers, byte[] content)
    {
       super(command, headers, content);
@@ -40,67 +31,4 @@ public class StompFrameV12 extends StompFrame
    {
       super(command);
    }
-
-   @Override
-   public ActiveMQBuffer toActiveMQBuffer() throws Exception
-   {
-      if (buffer == null)
-      {
-         if (bytesBody != null)
-         {
-            buffer = ActiveMQBuffers.dynamicBuffer(bytesBody.length + 512);
-         }
-         else
-         {
-            buffer = ActiveMQBuffers.dynamicBuffer(512);
-         }
-
-         StringBuffer head = new StringBuffer();
-         head.append(command);
-         head.append(Stomp.NEWLINE);
-         // Output the headers.
-         for (Header h : allHeaders)
-         {
-            head.append(h.getEncodedKey());
-            head.append(Stomp.Headers.SEPARATOR);
-            head.append(h.getEncodedValue());
-            head.append(Stomp.NEWLINE);
-         }
-
-         if ((bytesBody != null) && (bytesBody.length > 0))
-         {
-            head.append(Stomp.Headers.CONTENT_LENGTH);
-            head.append(Stomp.Headers.SEPARATOR);
-            head.append(bytesBody.length);
-            head.append(Stomp.NEWLINE);
-         }
-         // Add a newline to separate the headers from the content.
-         head.append(Stomp.NEWLINE);
-
-         buffer.writeBytes(head.toString().getBytes(StandardCharsets.UTF_8));
-         if (bytesBody != null)
-         {
-            buffer.writeBytes(bytesBody);
-         }
-
-         buffer.writeBytes(END_OF_FRAME);
-
-         size = buffer.writerIndex();
-      }
-      return buffer;
-   }
-
-   @Override
-   public void addHeader(String key, String val)
-   {
-      if (!headers.containsKey(key))
-      {
-         headers.put(key, val);
-         allHeaders.add(new Header(key, val));
-      }
-      else if (!key.equals(Stomp.Headers.CONTENT_LENGTH))
-      {
-         allHeaders.add(new Header(key, val));
-      }
-   }
 }


Mime
View raw message