[jboss-cvs] JBoss Messaging SVN: r4027 - in trunk: src/main/org/jboss/messaging/core/remoting/impl/codec and 4 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Apr 10 08:53:12 EDT 2008


Author: jmesnil
Date: 2008-04-10 08:53:11 -0400 (Thu, 10 Apr 2008)
New Revision: 4027

Modified:
   trunk/src/main/org/jboss/messaging/core/client/impl/ClientConsumerPacketHandler.java
   trunk/src/main/org/jboss/messaging/core/client/impl/ClientProducerPacketHandler.java
   trunk/src/main/org/jboss/messaging/core/remoting/impl/codec/AbstractPacketCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaDecoder.java
   trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaEncoder.java
   trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/PacketCodecFactory.java
   trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/Packet.java
   trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/PacketImpl.java
   trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/PacketType.java
   trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerPacketHandler.java
   trunk/src/main/org/jboss/messaging/core/server/impl/ServerBrowserImpl.java
   trunk/src/main/org/jboss/messaging/core/server/impl/ServerConnectionPacketHandler.java
   trunk/src/main/org/jboss/messaging/core/server/impl/ServerConsumerPacketHandler.java
   trunk/src/main/org/jboss/messaging/core/server/impl/ServerProducerPacketHandler.java
   trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionPacketHandler.java
   trunk/tests/src/org/jboss/messaging/core/remoting/impl/wireformat/test/unit/PacketTypeTest.java
Log:
* reverted to use Enum to represent PacketType

Modified: trunk/src/main/org/jboss/messaging/core/client/impl/ClientConsumerPacketHandler.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/impl/ClientConsumerPacketHandler.java	2008-04-10 01:27:55 UTC (rev 4026)
+++ trunk/src/main/org/jboss/messaging/core/client/impl/ClientConsumerPacketHandler.java	2008-04-10 12:53:11 UTC (rev 4027)
@@ -7,6 +7,7 @@
 import org.jboss.messaging.core.remoting.PacketSender;
 import org.jboss.messaging.core.remoting.impl.wireformat.ConsumerDeliverMessage;
 import org.jboss.messaging.core.remoting.impl.wireformat.Packet;
+import org.jboss.messaging.core.remoting.impl.wireformat.PacketType;
 
 /**
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
@@ -38,7 +39,7 @@
    {
       try
       {
-         byte type = packet.getType();
+         PacketType type = packet.getType();
          
          if (type == CONS_DELIVER)
          {

Modified: trunk/src/main/org/jboss/messaging/core/client/impl/ClientProducerPacketHandler.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/impl/ClientProducerPacketHandler.java	2008-04-10 01:27:55 UTC (rev 4026)
+++ trunk/src/main/org/jboss/messaging/core/client/impl/ClientProducerPacketHandler.java	2008-04-10 12:53:11 UTC (rev 4027)
@@ -6,6 +6,7 @@
 import org.jboss.messaging.core.remoting.PacketHandler;
 import org.jboss.messaging.core.remoting.PacketSender;
 import org.jboss.messaging.core.remoting.impl.wireformat.Packet;
+import org.jboss.messaging.core.remoting.impl.wireformat.PacketType;
 import org.jboss.messaging.core.remoting.impl.wireformat.ProducerReceiveTokensMessage;
 
 /**
@@ -39,7 +40,7 @@
    {
       try
       {
-         byte type = packet.getType();
+         PacketType type = packet.getType();
          
          if (type == PROD_RECEIVETOKENS)
          {

Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/codec/AbstractPacketCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/codec/AbstractPacketCodec.java	2008-04-10 01:27:55 UTC (rev 4026)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/codec/AbstractPacketCodec.java	2008-04-10 12:53:11 UTC (rev 4027)
@@ -17,6 +17,7 @@
 
 import org.jboss.messaging.core.logging.Logger;
 import org.jboss.messaging.core.remoting.impl.wireformat.Packet;
+import org.jboss.messaging.core.remoting.impl.wireformat.PacketType;
 import org.jboss.messaging.core.transaction.impl.XidImpl;
 
 /**
@@ -42,14 +43,16 @@
 
    // Attributes ----------------------------------------------------
 
-   protected final byte type;
+   protected final PacketType type;
 
    // Static --------------------------------------------------------
    
    // Constructors --------------------------------------------------
    
-   protected AbstractPacketCodec(byte type)
+   protected AbstractPacketCodec(PacketType type)
    {
+      assert type != null;
+      
       this.type = type;
    }
 
@@ -81,7 +84,7 @@
       }
       int headerLength = LONG_LENGTH + sizeof(targetID) + sizeof(callbackID) + sizeof(executorID) + BOOLEAN_LENGTH;
 
-      buf.put(packet.getType());
+      buf.put(packet.getType().byteValue());
       buf.putInt(headerLength);
       buf.putLong(correlationID);
       buf.putNullableString(targetID);

Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaDecoder.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaDecoder.java	2008-04-10 01:27:55 UTC (rev 4026)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaDecoder.java	2008-04-10 12:53:11 UTC (rev 4027)
@@ -18,6 +18,7 @@
 import org.jboss.messaging.core.remoting.impl.codec.DecoderStatus;
 import org.jboss.messaging.core.remoting.impl.codec.RemotingBuffer;
 import org.jboss.messaging.core.remoting.impl.wireformat.Packet;
+import org.jboss.messaging.core.remoting.impl.wireformat.PacketType;
 
 /**
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
@@ -31,7 +32,7 @@
 
    // Attributes ----------------------------------------------------
 
-   private final Map<Byte, AbstractPacketCodec> codecs;
+   private final Map<PacketType, AbstractPacketCodec> codecs;
 
    // Static --------------------------------------------------------
 
@@ -39,12 +40,12 @@
 
    public MinaDecoder()
    {
-      codecs = new HashMap<Byte, AbstractPacketCodec>();
+      codecs = new HashMap<PacketType, AbstractPacketCodec>();
    }
 
    // Public --------------------------------------------------------
 
-   public void put(byte type, AbstractPacketCodec codec)
+   public void put(PacketType type, AbstractPacketCodec codec)
    {
       codecs.put(type, codec);
    }
@@ -53,7 +54,8 @@
 
    public MessageDecoderResult decodable(IoSession session, IoBuffer in)
    {
-      byte type = in.get();
+      byte byteValue = in.get();
+      PacketType type = PacketType.from(byteValue);
       if (!codecs.containsKey(type))
          return MessageDecoderResult.NOT_OK;
 
@@ -67,7 +69,8 @@
    public MessageDecoderResult decode(IoSession session, IoBuffer in,
          ProtocolDecoderOutput out) throws Exception
    {
-      byte type = in.get();
+      byte byteValue = in.get();
+      PacketType type = PacketType.from(byteValue);
       AbstractPacketCodec codec = codecs.get(type);
       // rewind from 1
       in.position(in.position() -1);

Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaEncoder.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaEncoder.java	2008-04-10 01:27:55 UTC (rev 4026)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaEncoder.java	2008-04-10 12:53:11 UTC (rev 4027)
@@ -30,7 +30,7 @@
 
    // Attributes ----------------------------------------------------
 
-   private final Map<Byte, AbstractPacketCodec> codecs;
+   private final Map<PacketType, AbstractPacketCodec> codecs;
 
    // Static --------------------------------------------------------
 
@@ -38,11 +38,11 @@
 
     MinaEncoder()
    {
-      codecs = new HashMap<Byte, AbstractPacketCodec>();
+      codecs = new HashMap<PacketType, AbstractPacketCodec>();
    }
    // Public --------------------------------------------------------
 
-   public void put(byte type, AbstractPacketCodec codec)
+   public void put(PacketType type, AbstractPacketCodec codec)
    {
       codecs.put(type, codec);
    }

Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/PacketCodecFactory.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/PacketCodecFactory.java	2008-04-10 01:27:55 UTC (rev 4026)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/PacketCodecFactory.java	2008-04-10 12:53:11 UTC (rev 4027)
@@ -118,6 +118,7 @@
 import org.jboss.messaging.core.remoting.impl.codec.TextPacketCodec;
 import org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl;
 import org.jboss.messaging.core.remoting.impl.wireformat.Packet;
+import org.jboss.messaging.core.remoting.impl.wireformat.PacketType;
 
 /**
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
@@ -304,7 +305,7 @@
    // Public --------------------------------------------------------
 
    public static AbstractPacketCodec<Packet> createCodecForEmptyPacket(
-         final byte type)
+         final PacketType type)
    {
       return new CodecForEmptyPacket<Packet>(type);
    }
@@ -317,7 +318,7 @@
 
    // FIXME generics definition should be in term of <P>...
    private void addCodec(MinaEncoder encoder, MinaDecoder decoder,
-         byte type, AbstractPacketCodec<? extends Packet> codec)
+         PacketType type, AbstractPacketCodec<? extends Packet> codec)
    {
       try
       {
@@ -330,7 +331,7 @@
    }
    
    private void addCodecForEmptyPacket(MinaEncoder encoder,
-         MinaDecoder decoder, byte type)
+         MinaDecoder decoder, PacketType type)
    {
       AbstractPacketCodec<Packet> codec = createCodecForEmptyPacket(
             type);
@@ -343,7 +344,7 @@
          AbstractPacketCodec<P>
    {
 
-      public CodecForEmptyPacket(byte type)
+      public CodecForEmptyPacket(PacketType type)
       {
          super(type);
       }

Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/Packet.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/Packet.java	2008-04-10 01:27:55 UTC (rev 4026)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/Packet.java	2008-04-10 12:53:11 UTC (rev 4027)
@@ -16,7 +16,7 @@
 
    long getCorrelationID();
 
-   byte getType();
+   PacketType getType();
 
    String getTargetID();
 

Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/PacketImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/PacketImpl.java	2008-04-10 01:27:55 UTC (rev 4026)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/PacketImpl.java	2008-04-10 12:53:11 UTC (rev 4027)
@@ -33,7 +33,7 @@
 
    String executorID = NO_ID_SET;
 
-   private final byte type;
+   private final PacketType type;
 
    /**
     * <code>oneWay</code> is <code>true</code> when the packet is sent "one way"
@@ -47,14 +47,16 @@
 
    // Constructors --------------------------------------------------
 
-   public PacketImpl(byte type)
+   public PacketImpl(PacketType type)
    {
+      assert type != null;
+      
       this.type = type;
    }
 
    // Public --------------------------------------------------------
 
-   public byte getType()
+   public PacketType getType()
    {
       return type;
    }

Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/PacketType.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/PacketType.java	2008-04-10 01:27:55 UTC (rev 4026)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/PacketType.java	2008-04-10 12:53:11 UTC (rev 4027)
@@ -6,83 +6,120 @@
  */
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
+import java.util.HashMap;
+import java.util.Map;
+
 /**
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
  * 
  * @version <tt>$Revision$</tt>
  */
-public class PacketType
+public enum PacketType
 {
    // System
-   public static final byte NULL                               = 1;
-   public static final byte TEXT                               = 2;
-   public static final byte BYTES                              = 3;
-   public static final byte PING                               = 4;
-   public static final byte PONG                               = 5;
+   NULL                                ((byte)1),
+   TEXT                                ((byte)2),
+   BYTES                               ((byte)3),
+   PING                                ((byte)4),
+   PONG                                ((byte)5),
+   
+   // Miscellaneous   
+   EXCEPTION                           ((byte)10),
+   CLOSE                               ((byte)11),
+   
+   // Server
+   CREATECONNECTION                    ((byte)20),
+   CREATECONNECTION_RESP               ((byte)21),    
+   
+   // Connection
+   CONN_CREATESESSION                  ((byte)30),
+   CONN_CREATESESSION_RESP             ((byte)31),
+   CONN_START                          ((byte)32),
+   CONN_STOP                           ((byte)33),
 
-   // Miscellaneous
-   public static final byte EXCEPTION                          = 10;
-   public static final byte CLOSE                              = 11;
+   // Session   
+   SESS_CREATECONSUMER                 ((byte)40),
+   SESS_CREATECONSUMER_RESP            ((byte)41),
+   SESS_CREATEPRODUCER                 ((byte)42),
+   SESS_CREATEPRODUCER_RESP            ((byte)43),
+   SESS_CREATEBROWSER                  ((byte)44),
+   SESS_CREATEBROWSER_RESP             ((byte)45),      
+   SESS_ACKNOWLEDGE                    ((byte)46),
+   SESS_RECOVER                        ((byte)47),
+   SESS_COMMIT                         ((byte)48),
+   SESS_ROLLBACK                       ((byte)49),
+   SESS_CANCEL                         ((byte)50),
+   SESS_QUEUEQUERY                     ((byte)51),
+   SESS_QUEUEQUERY_RESP                ((byte)52),
+   SESS_CREATEQUEUE                    ((byte)53),
+   SESS_DELETE_QUEUE                   ((byte)54),   
+   SESS_ADD_DESTINATION                ((byte)55),
+   SESS_REMOVE_DESTINATION             ((byte)56),
+   SESS_BINDINGQUERY                   ((byte)57),
+   SESS_BINDINGQUERY_RESP              ((byte)58),  
+   SESS_BROWSER_RESET                  ((byte)59),
+   SESS_BROWSER_HASNEXTMESSAGE         ((byte)60),
+   SESS_BROWSER_HASNEXTMESSAGE_RESP    ((byte)61),
+   SESS_BROWSER_NEXTMESSAGEBLOCK       ((byte)62),
+   SESS_BROWSER_NEXTMESSAGEBLOCK_RESP  ((byte)63),
+   SESS_BROWSER_NEXTMESSAGE            ((byte)64),
+   SESS_BROWSER_NEXTMESSAGE_RESP       ((byte)65),      
+   SESS_XA_START                       ((byte)66),
+   SESS_XA_END                         ((byte)67),
+   SESS_XA_COMMIT                      ((byte)68),
+   SESS_XA_PREPARE                     ((byte)69),
+   SESS_XA_RESP                        ((byte)70),
+   SESS_XA_ROLLBACK                    ((byte)71),
+   SESS_XA_JOIN                        ((byte)72),
+   SESS_XA_SUSPEND                     ((byte)73),
+   SESS_XA_RESUME                      ((byte)74),
+   SESS_XA_FORGET                      ((byte)75),
+   SESS_XA_INDOUBT_XIDS                ((byte)76),
+   SESS_XA_INDOUBT_XIDS_RESP           ((byte)77),
+   SESS_XA_SET_TIMEOUT                 ((byte)78),
+   SESS_XA_SET_TIMEOUT_RESP            ((byte)79),
+   SESS_XA_GET_TIMEOUT                 ((byte)80),
+   SESS_XA_GET_TIMEOUT_RESP            ((byte)81),
+       
+   // Consumer 
+   CONS_FLOWTOKEN                      ((byte)90),
+   CONS_DELIVER                        ((byte)91),
+   
+   //Producer
+   PROD_SEND                           ((byte)100),
+   PROD_RECEIVETOKENS                  ((byte)101);
+   
+   // the ALL_TYPES map is used to find the PacketType corresponding to a given byte
+   // by using the static method from(byte)
+   private static final Map<Byte, PacketType> ALL_TYPES = new HashMap<Byte, PacketType>();
 
-   // Server
-   public static final byte CREATECONNECTION                   = 20;
-   public static final byte CREATECONNECTION_RESP              = 21;
+   static {
+      PacketType[] types = PacketType.values();
+      for (int i = 0; i < types.length; i++)
+      {  
+         PacketType type = types[i];
+         ALL_TYPES.put(type.byteValue(), type);         
+      }
+   }
 
-   // Connection
-   public static final byte CONN_CREATESESSION                 = 30;
-   public static final byte CONN_CREATESESSION_RESP            = 31;
-   public static final byte CONN_START                         = 32;
-   public static final byte CONN_STOP                          = 33;
+   private final byte type;
 
-   // Session
-   public static final byte SESS_CREATECONSUMER                = 40;
-   public static final byte SESS_CREATECONSUMER_RESP           = 41;
-   public static final byte SESS_CREATEPRODUCER                = 42;
-   public static final byte SESS_CREATEPRODUCER_RESP           = 43;
-   public static final byte SESS_CREATEBROWSER                 = 44;
-   public static final byte SESS_CREATEBROWSER_RESP            = 45;
-   public static final byte SESS_ACKNOWLEDGE                   = 46;
-   public static final byte SESS_RECOVER                       = 47;
-   public static final byte SESS_COMMIT                        = 48;
-   public static final byte SESS_ROLLBACK                      = 49;
-   public static final byte SESS_CANCEL                        = 50;
-   public static final byte SESS_QUEUEQUERY                    = 51;
-   public static final byte SESS_QUEUEQUERY_RESP               = 52;
-   public static final byte SESS_CREATEQUEUE                   = 53;
-   public static final byte SESS_DELETE_QUEUE                  = 54;
-   public static final byte SESS_ADD_DESTINATION               = 55;
-   public static final byte SESS_REMOVE_DESTINATION            = 56;
-   public static final byte SESS_BINDINGQUERY                  = 57;
-   public static final byte SESS_BINDINGQUERY_RESP             = 58;
-   public static final byte SESS_BROWSER_RESET                 = 59;
-   public static final byte SESS_BROWSER_HASNEXTMESSAGE        = 60;
-   public static final byte SESS_BROWSER_HASNEXTMESSAGE_RESP   = 61;
-   public static final byte SESS_BROWSER_NEXTMESSAGEBLOCK      = 62;
-   public static final byte SESS_BROWSER_NEXTMESSAGEBLOCK_RESP = 63;
-   public static final byte SESS_BROWSER_NEXTMESSAGE           = 64;
-   public static final byte SESS_BROWSER_NEXTMESSAGE_RESP      = 65;
-   public static final byte SESS_XA_START                      = 66;
-   public static final byte SESS_XA_END                        = 67;
-   public static final byte SESS_XA_COMMIT                     = 68;
-   public static final byte SESS_XA_PREPARE                    = 69;
-   public static final byte SESS_XA_RESP                       = 70;
-   public static final byte SESS_XA_ROLLBACK                   = 71;
-   public static final byte SESS_XA_JOIN                       = 72;
-   public static final byte SESS_XA_SUSPEND                    = 73;
-   public static final byte SESS_XA_RESUME                     = 74;
-   public static final byte SESS_XA_FORGET                     = 75;
-   public static final byte SESS_XA_INDOUBT_XIDS               = 76;
-   public static final byte SESS_XA_INDOUBT_XIDS_RESP          = 77;
-   public static final byte SESS_XA_SET_TIMEOUT                = 78;
-   public static final byte SESS_XA_SET_TIMEOUT_RESP           = 79;
-   public static final byte SESS_XA_GET_TIMEOUT                = 80;
-   public static final byte SESS_XA_GET_TIMEOUT_RESP           = 81;
+   PacketType(byte type)
+   {
+      this.type = type;
+   }
 
-   // Consumer
-   public static final byte CONS_FLOWTOKEN                     = 90;
-   public static final byte CONS_DELIVER                       = 91;
+   public byte byteValue()
+   {
+      return type;
+   }
 
-   // Producer
-   public static final byte PROD_SEND                          = 100;
-   public static final byte PROD_RECEIVETOKENS                 = 101;
+   public static PacketType from(byte typeByte)
+   {
+      PacketType type = ALL_TYPES.get(typeByte);
+      if (type != null)
+         return type;
+      else
+         throw new IllegalArgumentException(typeByte + " is not a valid PacketType byte.");
+   }
 }

Modified: trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerPacketHandler.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerPacketHandler.java	2008-04-10 01:27:55 UTC (rev 4026)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerPacketHandler.java	2008-04-10 12:53:11 UTC (rev 4027)
@@ -29,6 +29,7 @@
 import org.jboss.messaging.core.remoting.PacketSender;
 import org.jboss.messaging.core.remoting.impl.wireformat.CreateConnectionRequest;
 import org.jboss.messaging.core.remoting.impl.wireformat.Packet;
+import org.jboss.messaging.core.remoting.impl.wireformat.PacketType;
 import org.jboss.messaging.core.server.MessagingServer;
 
 /**
@@ -66,7 +67,7 @@
    {
       Packet response = null;
      
-      byte type = packet.getType();
+      PacketType type = packet.getType();
       
       if (type == CREATECONNECTION)
       {

Modified: trunk/src/main/org/jboss/messaging/core/server/impl/ServerBrowserImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/ServerBrowserImpl.java	2008-04-10 01:27:55 UTC (rev 4026)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/ServerBrowserImpl.java	2008-04-10 12:53:11 UTC (rev 4027)
@@ -42,6 +42,7 @@
 import org.jboss.messaging.core.remoting.PacketSender;
 import org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl;
 import org.jboss.messaging.core.remoting.impl.wireformat.Packet;
+import org.jboss.messaging.core.remoting.impl.wireformat.PacketType;
 import org.jboss.messaging.core.remoting.impl.wireformat.SessionBrowserHasNextMessageResponseMessage;
 import org.jboss.messaging.core.remoting.impl.wireformat.SessionBrowserNextMessageResponseMessage;
 import org.jboss.messaging.core.server.Queue;
@@ -212,7 +213,7 @@
       {
          Packet response = null;
 
-         byte type = packet.getType();
+         PacketType type = packet.getType();
          switch (type)
          {
          case SESS_BROWSER_HASNEXTMESSAGE:

Modified: trunk/src/main/org/jboss/messaging/core/server/impl/ServerConnectionPacketHandler.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/ServerConnectionPacketHandler.java	2008-04-10 01:27:55 UTC (rev 4026)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/ServerConnectionPacketHandler.java	2008-04-10 12:53:11 UTC (rev 4027)
@@ -32,6 +32,7 @@
 import org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl;
 import org.jboss.messaging.core.remoting.impl.wireformat.ConnectionCreateSessionMessage;
 import org.jboss.messaging.core.remoting.impl.wireformat.Packet;
+import org.jboss.messaging.core.remoting.impl.wireformat.PacketType;
 import org.jboss.messaging.core.server.ServerConnection;
 
 /**
@@ -60,7 +61,7 @@
    {
       Packet response = null;
 
-      byte type = packet.getType();
+      PacketType type = packet.getType();
       
       switch (type)
       {

Modified: trunk/src/main/org/jboss/messaging/core/server/impl/ServerConsumerPacketHandler.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/ServerConsumerPacketHandler.java	2008-04-10 01:27:55 UTC (rev 4026)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/ServerConsumerPacketHandler.java	2008-04-10 12:53:11 UTC (rev 4027)
@@ -30,6 +30,7 @@
 import org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl;
 import org.jboss.messaging.core.remoting.impl.wireformat.ConsumerFlowTokenMessage;
 import org.jboss.messaging.core.remoting.impl.wireformat.Packet;
+import org.jboss.messaging.core.remoting.impl.wireformat.PacketType;
 import org.jboss.messaging.core.server.ServerConsumer;
 
 /**
@@ -58,7 +59,7 @@
    {
       Packet response = null;
 
-      byte type = packet.getType();
+      PacketType type = packet.getType();
       switch (type)
       {
       case CONS_FLOWTOKEN:

Modified: trunk/src/main/org/jboss/messaging/core/server/impl/ServerProducerPacketHandler.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/ServerProducerPacketHandler.java	2008-04-10 01:27:55 UTC (rev 4026)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/ServerProducerPacketHandler.java	2008-04-10 12:53:11 UTC (rev 4027)
@@ -29,6 +29,7 @@
 import org.jboss.messaging.core.remoting.PacketSender;
 import org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl;
 import org.jboss.messaging.core.remoting.impl.wireformat.Packet;
+import org.jboss.messaging.core.remoting.impl.wireformat.PacketType;
 import org.jboss.messaging.core.remoting.impl.wireformat.ProducerSendMessage;
 import org.jboss.messaging.core.server.ServerProducer;
 
@@ -57,7 +58,7 @@
    {
       Packet response = null;
 
-      byte type = packet.getType();
+      PacketType type = packet.getType();
       switch (type)
       {
       case PROD_SEND:

Modified: trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionPacketHandler.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionPacketHandler.java	2008-04-10 01:27:55 UTC (rev 4026)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionPacketHandler.java	2008-04-10 12:53:11 UTC (rev 4027)
@@ -21,33 +21,7 @@
   */
 package org.jboss.messaging.core.server.impl;
 
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.CLOSE;
 import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.NULL;
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_ACKNOWLEDGE;
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_ADD_DESTINATION;
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_BINDINGQUERY;
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_CANCEL;
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_COMMIT;
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_CREATEBROWSER;
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_CREATECONSUMER;
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_CREATEPRODUCER;
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_CREATEQUEUE;
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_DELETE_QUEUE;
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_QUEUEQUERY;
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_REMOVE_DESTINATION;
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_ROLLBACK;
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_XA_COMMIT;
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_XA_END;
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_XA_FORGET;
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_XA_GET_TIMEOUT;
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_XA_INDOUBT_XIDS;
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_XA_JOIN;
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_XA_PREPARE;
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_XA_RESUME;
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_XA_ROLLBACK;
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_XA_SET_TIMEOUT;
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_XA_START;
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.SESS_XA_SUSPEND;
 
 import java.util.List;
 
@@ -58,6 +32,7 @@
 import org.jboss.messaging.core.remoting.PacketSender;
 import org.jboss.messaging.core.remoting.impl.wireformat.Packet;
 import org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl;
+import org.jboss.messaging.core.remoting.impl.wireformat.PacketType;
 import org.jboss.messaging.core.remoting.impl.wireformat.SessionAcknowledgeMessage;
 import org.jboss.messaging.core.remoting.impl.wireformat.SessionAddDestinationMessage;
 import org.jboss.messaging.core.remoting.impl.wireformat.SessionBindingQueryMessage;
@@ -111,7 +86,7 @@
    {
       Packet response = null;
 
-      byte type = packet.getType();
+      PacketType type = packet.getType();
       
       switch (type)
       {

Modified: trunk/tests/src/org/jboss/messaging/core/remoting/impl/wireformat/test/unit/PacketTypeTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/core/remoting/impl/wireformat/test/unit/PacketTypeTest.java	2008-04-10 01:27:55 UTC (rev 4026)
+++ trunk/tests/src/org/jboss/messaging/core/remoting/impl/wireformat/test/unit/PacketTypeTest.java	2008-04-10 12:53:11 UTC (rev 4027)
@@ -272,7 +272,7 @@
    {
       checkHeaderBytes(packet, buffer.buffer().buf());
 
-      assertEquals(buffer.get(), packet.getType());
+      assertEquals(buffer.get(), packet.getType().byteValue());
 
       String targetID = (packet.getTargetID().equals(NO_ID_SET) ? null : packet
             .getTargetID());
@@ -316,7 +316,7 @@
             + BOOLEAN_LENGTH;
       ByteBuffer expected = ByteBuffer.allocate(1 + 1 + INT_LENGTH
             + headerLength);
-      expected.put(packet.getType());
+      expected.put(packet.getType().byteValue());
 
       expected.putInt(headerLength);
       expected.putLong(packet.getCorrelationID());




More information about the jboss-cvs-commits mailing list