[jboss-cvs] JBoss Messaging SVN: r3389 - in branches/Branch_JBMESSAGING-544: src/main/org/jboss/messaging/core/remoting/internal and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Nov 30 12:46:35 EST 2007


Author: jmesnil
Date: 2007-11-30 12:46:34 -0500 (Fri, 30 Nov 2007)
New Revision: 3389

Modified:
   branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/codec/AbstractPacketCodec.java
   branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/codec/RemotingBuffer.java
   branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/internal/MinaPacketCodec.java
   branches/Branch_JBMESSAGING-544/tests/src/org/jboss/test/messaging/core/remoting/internal/MinaRemotingBuffer.java
   branches/Branch_JBMESSAGING-544/tests/src/org/jboss/test/messaging/core/remoting/wireformat/PacketTypeTest.java
Log:
http://jira.jboss.org/jira/browse/JBMESSAGING-544 Replace client-server transport with NIO based transport
* remove put/getString() methods from RemotingBuffer: all Strings encoding/decoding now use uniformly put/getNullableString() method instead

Modified: branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/codec/AbstractPacketCodec.java
===================================================================
--- branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/codec/AbstractPacketCodec.java	2007-11-30 17:32:51 UTC (rev 3388)
+++ branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/codec/AbstractPacketCodec.java	2007-11-30 17:46:34 UTC (rev 3389)
@@ -14,9 +14,6 @@
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.nio.charset.CharacterCodingException;
-import java.nio.charset.Charset;
-import java.nio.charset.CharsetDecoder;
-import java.nio.charset.CharsetEncoder;
 
 import org.jboss.jms.destination.JBossDestination;
 import org.jboss.messaging.core.contract.Message;
@@ -39,12 +36,6 @@
 
    protected static final int LONG_LENGTH = 8;
 
-   public static final CharsetEncoder UTF_8_ENCODER = Charset.forName("UTF-8")
-   .newEncoder();
-
-   public static final CharsetDecoder UTF_8_DECODER = Charset.forName("UTF-8")
-   .newDecoder();
-
    // Attributes ----------------------------------------------------
 
    private PacketType type;
@@ -115,14 +106,14 @@
       buffer.getLong(); // correlation ID
       try
       {
-         buffer.getString(UTF_8_DECODER);
+         buffer.getNullableString();
       } catch (CharacterCodingException e)
       {
          return DecoderStatus.NOT_OK;
       }
       try
       {
-         buffer.getString(UTF_8_DECODER);
+         buffer.getNullableString();
       } catch (CharacterCodingException e)
       {
          return DecoderStatus.NOT_OK;

Modified: branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/codec/RemotingBuffer.java
===================================================================
--- branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/codec/RemotingBuffer.java	2007-11-30 17:32:51 UTC (rev 3388)
+++ branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/codec/RemotingBuffer.java	2007-11-30 17:46:34 UTC (rev 3389)
@@ -28,13 +28,8 @@
 
    void putFloat(float floatValue);
 
-   void putString(String string, CharsetEncoder encoder)
-         throws CharacterCodingException;
-
    byte get();
 
-   String getString(CharsetDecoder decoder) throws CharacterCodingException;
-
    int remaining();
 
    int getInt();

Modified: branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/internal/MinaPacketCodec.java
===================================================================
--- branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/internal/MinaPacketCodec.java	2007-11-30 17:32:51 UTC (rev 3388)
+++ branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/internal/MinaPacketCodec.java	2007-11-30 17:46:34 UTC (rev 3389)
@@ -6,10 +6,8 @@
  */
 package org.jboss.messaging.core.remoting.internal;
 
-import static org.jboss.messaging.core.remoting.codec.AbstractPacketCodec.UTF_8_DECODER;
-import static org.jboss.messaging.core.remoting.codec.AbstractPacketCodec.UTF_8_ENCODER;
-
 import java.nio.charset.CharacterCodingException;
+import java.nio.charset.Charset;
 import java.nio.charset.CharsetDecoder;
 import java.nio.charset.CharsetEncoder;
 
@@ -41,13 +39,18 @@
    private static final byte FALSE = (byte) 1;
 
    // used to terminate encoded Strings
-   public static final byte NULL_BYTE = (byte) 0;
+   private static final byte NULL_BYTE = (byte) 0;
 
-   public static final byte NULL_STRING = (byte) 0;
+   private static final byte NULL_STRING = (byte) 0;
 
-   public static final byte NOT_NULL_STRING = (byte) 1;
+   private static final byte NOT_NULL_STRING = (byte) 1;
 
+   private static final CharsetEncoder UTF_8_ENCODER = Charset.forName("UTF-8")
+         .newEncoder();
 
+   private static final CharsetDecoder UTF_8_DECODER = Charset.forName("UTF-8")
+         .newDecoder();
+
    // Attributes ----------------------------------------------------
 
    // Static --------------------------------------------------------
@@ -139,7 +142,8 @@
 
    // Inner classes -------------------------------------------------
 
-   public static String getString(RemotingBuffer in) throws CharacterCodingException
+   public static String getString(RemotingBuffer in)
+         throws CharacterCodingException
    {
       return in.getNullableString();
    }
@@ -185,12 +189,6 @@
          buffer.putFloat(floatValue);
       }
 
-      public void putString(String string, CharsetEncoder encoder)
-            throws CharacterCodingException
-      {
-         buffer.putString(string, encoder);
-      }
-      
       public byte get()
       {
          return buffer.get();
@@ -216,12 +214,6 @@
          return buffer.getFloat();
       }
 
-      public String getString(CharsetDecoder decoder)
-            throws CharacterCodingException
-      {
-         return buffer.getString(decoder);
-      }
-
       public void putBoolean(boolean b)
       {
          if (b)
@@ -238,10 +230,11 @@
          byte b = buffer.get();
          return (b == TRUE);
       }
-      
-      public void putNullableString(String nullableString) throws CharacterCodingException
+
+      public void putNullableString(String nullableString)
+            throws CharacterCodingException
       {
-         
+
          if (nullableString == null)
          {
             buffer.put(NULL_STRING);
@@ -262,7 +255,7 @@
          } else
          {
             assert check == NOT_NULL_STRING;
-      
+
             return buffer.getString(UTF_8_DECODER);
          }
       }

Modified: branches/Branch_JBMESSAGING-544/tests/src/org/jboss/test/messaging/core/remoting/internal/MinaRemotingBuffer.java
===================================================================
--- branches/Branch_JBMESSAGING-544/tests/src/org/jboss/test/messaging/core/remoting/internal/MinaRemotingBuffer.java	2007-11-30 17:32:51 UTC (rev 3388)
+++ branches/Branch_JBMESSAGING-544/tests/src/org/jboss/test/messaging/core/remoting/internal/MinaRemotingBuffer.java	2007-11-30 17:46:34 UTC (rev 3389)
@@ -10,7 +10,6 @@
 import junit.framework.TestCase;
 
 import org.apache.mina.common.IoBuffer;
-import org.jboss.messaging.core.remoting.codec.AbstractPacketCodec;
 import org.jboss.messaging.core.remoting.codec.RemotingBuffer;
 import org.jboss.messaging.core.remoting.internal.MinaPacketCodec;
 
@@ -50,18 +49,6 @@
 
    }
 
-   public void testNullStringNotAllowedByPutString() throws Exception
-   {
-      try
-      {
-         wrapper.putString(null, AbstractPacketCodec.UTF_8_ENCODER);
-         fail("putString(String, CharsetEncoder) does not allow null String");
-      } catch (Exception e)
-      {
-
-      }
-   }
-
    public void testNullString() throws Exception
    {
       assertNull(putAndGetNullableString(null));

Modified: branches/Branch_JBMESSAGING-544/tests/src/org/jboss/test/messaging/core/remoting/wireformat/PacketTypeTest.java
===================================================================
--- branches/Branch_JBMESSAGING-544/tests/src/org/jboss/test/messaging/core/remoting/wireformat/PacketTypeTest.java	2007-11-30 17:32:51 UTC (rev 3388)
+++ branches/Branch_JBMESSAGING-544/tests/src/org/jboss/test/messaging/core/remoting/wireformat/PacketTypeTest.java	2007-11-30 17:46:34 UTC (rev 3389)
@@ -63,8 +63,6 @@
 import java.io.DataOutputStream;
 import java.io.IOException;
 import java.nio.charset.CharacterCodingException;
-import java.nio.charset.CharsetDecoder;
-import java.nio.charset.CharsetEncoder;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -1227,19 +1225,12 @@
          AbstractPacketCodec codec) throws Exception
    {
       SimpleRemotingBuffer buf = new SimpleRemotingBuffer();
-      codec.encode(packet, buf);
       
+      codec.encode(packet, buf);      
       buf.flip();
-
-      return decode(buf, codec);
+      return codec.decode(buf);
    }
 
-   private AbstractPacket decode(SimpleRemotingBuffer buffer,
-         AbstractPacketCodec codec) throws Exception
-   {
-      return codec.decode(buffer);
-   }
-
    // Inner classes -------------------------------------------------
 
    private final class SimpleRemotingBuffer implements RemotingBuffer
@@ -1352,19 +1343,6 @@
          }
       }
 
-      public String getString(CharsetDecoder decoder)
-            throws CharacterCodingException
-      {
-         try
-         {
-            return dais.readUTF();
-         } catch (IOException e)
-         {
-            fail();
-            return null;
-         }
-      }
-
       public void put(byte byteValue)
       {
          try
@@ -1450,18 +1428,6 @@
          }
       }
 
-      public void putString(String string, CharsetEncoder encoder)
-            throws CharacterCodingException
-      {
-         try
-         {
-            dos.writeUTF(string);
-         } catch (IOException e)
-         {
-            fail();
-         }
-      }
-
       public int remaining()
       {
          try




More information about the jboss-cvs-commits mailing list