[infinispan-commits] Infinispan SVN: r1813 - trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/netty.

infinispan-commits at lists.jboss.org infinispan-commits at lists.jboss.org
Tue May 18 12:16:24 EDT 2010


Author: mircea.markus
Date: 2010-05-18 12:16:23 -0400 (Tue, 18 May 2010)
New Revision: 1813

Added:
   trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/netty/HotRodClientEncoder.java
Removed:
   trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/netty/HotrodClientEncoder.java
Log:
updated

Copied: trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/netty/HotRodClientEncoder.java (from rev 1812, trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/netty/HotrodClientEncoder.java)
===================================================================
--- trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/netty/HotRodClientEncoder.java	                        (rev 0)
+++ trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/netty/HotRodClientEncoder.java	2010-05-18 16:16:23 UTC (rev 1813)
@@ -0,0 +1,51 @@
+package org.infinispan.client.hotrod.impl.transport.netty;
+
+import org.infinispan.client.hotrod.exceptions.TransportException;
+import org.infinispan.client.hotrod.impl.transport.VHelper;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.jboss.netty.channel.Channel;
+import org.jboss.netty.channel.ChannelHandlerContext;
+import org.jboss.netty.handler.codec.oneone.OneToOneEncoder;
+
+import static org.jboss.netty.buffer.ChannelBuffers.*;
+
+/**
+ * @author Mircea.Markus at jboss.com
+ * @since 4.1
+ */
+public class HotrodClientEncoder extends OneToOneEncoder {
+
+   private OutputStreamAdapter osa = new OutputStreamAdapter();
+
+   @Override
+   protected Object encode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception {
+      if (msg instanceof byte[]) {
+         return wrappedBuffer((byte[])msg);
+      } else if (msg instanceof Integer) {
+         int intMsg = (Integer) msg;
+         ChannelBuffer buffer = getBuffer(channel);
+         VHelper.writeVInt(intMsg, osa);
+         return buffer;
+      } else if (msg instanceof Long) {
+         ChannelBuffer buffer = getBuffer(channel);
+         long longMsg = (Long) msg;
+         VHelper.writeVLong(longMsg, osa);
+         return buffer;
+      } else if (msg instanceof Short) {
+         ChannelBuffer buffer = getBuffer(channel);
+         short byteMsg =  (Short) msg;
+         buffer.writeByte(byteMsg);
+         return buffer;
+      } else {
+         throw new TransportException("Unknown msg type: " + msg.getClass());
+      }
+   }
+
+
+   private ChannelBuffer getBuffer(Channel channel) {
+      ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(channel.getConfig().getBufferFactory());
+      osa.setBuffer(buffer);
+      return buffer;
+   }
+}

Deleted: trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/netty/HotrodClientEncoder.java
===================================================================
--- trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/netty/HotrodClientEncoder.java	2010-05-18 16:15:08 UTC (rev 1812)
+++ trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/netty/HotrodClientEncoder.java	2010-05-18 16:16:23 UTC (rev 1813)
@@ -1,51 +0,0 @@
-package org.infinispan.client.hotrod.impl.transport.netty;
-
-import org.infinispan.client.hotrod.exceptions.TransportException;
-import org.infinispan.client.hotrod.impl.transport.VHelper;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.oneone.OneToOneEncoder;
-
-import static org.jboss.netty.buffer.ChannelBuffers.*;
-
-/**
- * @author Mircea.Markus at jboss.com
- * @since 4.1
- */
-public class HotrodClientEncoder extends OneToOneEncoder {
-
-   private OutputStreamAdapter osa = new OutputStreamAdapter();
-
-   @Override
-   protected Object encode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception {
-      if (msg instanceof byte[]) {
-         return wrappedBuffer((byte[])msg);
-      } else if (msg instanceof Integer) {
-         int intMsg = (Integer) msg;
-         ChannelBuffer buffer = getBuffer(channel);
-         VHelper.writeVInt(intMsg, osa);
-         return buffer;
-      } else if (msg instanceof Long) {
-         ChannelBuffer buffer = getBuffer(channel);
-         long longMsg = (Long) msg;
-         VHelper.writeVLong(longMsg, osa);
-         return buffer;
-      } else if (msg instanceof Short) {
-         ChannelBuffer buffer = getBuffer(channel);
-         short byteMsg =  (Short) msg;
-         buffer.writeByte(byteMsg);
-         return buffer;
-      } else {
-         throw new TransportException("Unknown msg type: " + msg.getClass());
-      }
-   }
-
-
-   private ChannelBuffer getBuffer(Channel channel) {
-      ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(channel.getConfig().getBufferFactory());
-      osa.setBuffer(buffer);
-      return buffer;
-   }
-}



More information about the infinispan-commits mailing list