[hornetq-commits] JBoss hornetq SVN: r10739 - in trunk: hornetq-commons/src/main/java/org/hornetq/api and 10 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Thu May 26 08:50:51 EDT 2011


Author: borges
Date: 2011-05-26 08:50:50 -0400 (Thu, 26 May 2011)
New Revision: 10739

Added:
   trunk/hornetq-commons/src/main/java/org/hornetq/api/
   trunk/hornetq-commons/src/main/java/org/hornetq/api/core/
   trunk/hornetq-commons/src/main/java/org/hornetq/api/core/HornetQBuffer.java
   trunk/hornetq-commons/src/main/java/org/hornetq/api/core/HornetQBuffers.java
   trunk/hornetq-commons/src/main/java/org/hornetq/api/core/HornetQException.java
   trunk/hornetq-commons/src/main/java/org/hornetq/api/core/Pair.java
   trunk/hornetq-commons/src/main/java/org/hornetq/api/core/SimpleString.java
   trunk/hornetq-commons/src/main/java/org/hornetq/core/buffers/
   trunk/hornetq-commons/src/main/java/org/hornetq/core/buffers/impl/
   trunk/hornetq-commons/src/main/java/org/hornetq/core/buffers/impl/ChannelBufferWrapper.java
   trunk/hornetq-commons/src/main/java/org/hornetq/core/server/
   trunk/hornetq-commons/src/main/java/org/hornetq/core/server/HornetQComponent.java
   trunk/hornetq-commons/src/main/java/org/hornetq/utils/
   trunk/hornetq-commons/src/main/java/org/hornetq/utils/DataConstants.java
   trunk/hornetq-commons/src/main/java/org/hornetq/utils/UTF8Util.java
Removed:
   trunk/hornetq-core/src/main/java/org/hornetq/api/core/HornetQBuffer.java
   trunk/hornetq-core/src/main/java/org/hornetq/api/core/HornetQBuffers.java
   trunk/hornetq-core/src/main/java/org/hornetq/api/core/HornetQException.java
   trunk/hornetq-core/src/main/java/org/hornetq/api/core/Pair.java
   trunk/hornetq-core/src/main/java/org/hornetq/api/core/SimpleString.java
   trunk/hornetq-core/src/main/java/org/hornetq/core/buffers/impl/ChannelBufferWrapper.java
   trunk/hornetq-core/src/main/java/org/hornetq/core/server/HornetQComponent.java
   trunk/hornetq-core/src/main/java/org/hornetq/utils/DataConstants.java
   trunk/hornetq-core/src/main/java/org/hornetq/utils/UTF8Util.java
Log:
HORNETQ-698 Move other necessary classes for hq-journal into hq-commons

Copied: trunk/hornetq-commons/src/main/java/org/hornetq/api/core/HornetQBuffer.java (from rev 10738, trunk/hornetq-core/src/main/java/org/hornetq/api/core/HornetQBuffer.java)
===================================================================
--- trunk/hornetq-commons/src/main/java/org/hornetq/api/core/HornetQBuffer.java	                        (rev 0)
+++ trunk/hornetq-commons/src/main/java/org/hornetq/api/core/HornetQBuffer.java	2011-05-26 12:50:50 UTC (rev 10739)
@@ -0,0 +1,1086 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.api.core;
+
+import java.nio.ByteBuffer;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+
+/**
+ *
+ * A HornetQBuffer wraps a Netty's ChannelBuffer and is used throughout HornetQ code base.
+ * 
+ * Much of it derived from Netty ChannelBuffer by Trustin Lee
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * 
+ * @see HornetQBuffers
+ *
+ */
+public interface HornetQBuffer
+{
+   /**
+    * Returns the underlying Netty's ChannelBuffer
+    * 
+    * @return the underlying Netty's ChannelBuffer
+    */
+   ChannelBuffer channelBuffer();
+
+   /**
+    * Returns the number of bytes this buffer can contain.
+    */
+   int capacity();
+
+   /**
+    * Returns the {@code readerIndex} of this buffer.
+    */
+   int readerIndex();
+
+   /**
+    * Sets the {@code readerIndex} of this buffer.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if the specified {@code readerIndex} is
+    *            less than {@code 0} or
+    *            greater than {@code this.writerIndex}
+    */
+   void readerIndex(int readerIndex);
+
+   /**
+    * Returns the {@code writerIndex} of this buffer.
+    */
+   int writerIndex();
+
+   /**
+    * Sets the {@code writerIndex} of this buffer.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if the specified {@code writerIndex} is
+    *            less than {@code this.readerIndex} or
+    *            greater than {@code this.capacity}
+    */
+   void writerIndex(int writerIndex);
+
+   /**
+    * Sets the {@code readerIndex} and {@code writerIndex} of this buffer
+    * in one shot.  This method is useful when you have to worry about the
+    * invocation order of {@link #readerIndex(int)} and {@link #writerIndex(int)}
+    * methods.  For example, the following code will fail:
+    *
+    * <pre>
+    * // Create a buffer whose readerIndex, writerIndex and capacity are
+    * // 0, 0 and 8 respectively.
+    * ChannelBuffer buf = ChannelBuffers.buffer(8);
+    *
+    * // IndexOutOfBoundsException is thrown because the specified
+    * // readerIndex (2) cannot be greater than the current writerIndex (0).
+    * buf.readerIndex(2);
+    * buf.writerIndex(4);
+    * </pre>
+    *
+    * The following code will also fail:
+    *
+    * <pre>
+    * // Create a buffer whose readerIndex, writerIndex and capacity are
+    * // 0, 8 and 8 respectively.
+    * ChannelBuffer buf = ChannelBuffers.wrappedBuffer(new byte[8]);
+    *
+    * // readerIndex becomes 8.
+    * buf.readLong();
+    *
+    * // IndexOutOfBoundsException is thrown because the specified
+    * // writerIndex (4) cannot be less than the current readerIndex (8).
+    * buf.writerIndex(4);
+    * buf.readerIndex(2);
+    * </pre>
+    *
+    * By contrast, {@link #setIndex(int, int)} guarantees that it never
+    * throws an {@link IndexOutOfBoundsException} as long as the specified
+    * indexes meet basic constraints, regardless what the current index
+    * values of the buffer are:
+    *
+    * <pre>
+    * // No matter what the current state of the buffer is, the following
+    * // call always succeeds as long as the capacity of the buffer is not
+    * // less than 4.
+    * buf.setIndex(2, 4);
+    * </pre>
+    *
+    * @throws IndexOutOfBoundsException
+    *         if the specified {@code readerIndex} is less than 0,
+    *         if the specified {@code writerIndex} is less than the specified
+    *         {@code readerIndex} or if the specified {@code writerIndex} is
+    *         greater than {@code this.capacity}
+    */
+   void setIndex(int readerIndex, int writerIndex);
+
+   /**
+    * Returns the number of readable bytes which is equal to
+    * {@code (this.writerIndex - this.readerIndex)}.
+    */
+   int readableBytes();
+
+   /**
+    * Returns the number of writable bytes which is equal to
+    * {@code (this.capacity - this.writerIndex)}.
+    */
+   int writableBytes();
+
+   /**
+    * Returns {@code true}
+    * if and only if {@code (this.writerIndex - this.readerIndex)} is greater
+    * than {@code 0}.
+    */
+   boolean readable();
+
+   /**
+    * Returns {@code true}
+    * if and only if {@code (this.capacity - this.writerIndex)} is greater
+    * than {@code 0}.
+    */
+   boolean writable();
+
+   /**
+    * Sets the {@code readerIndex} and {@code writerIndex} of this buffer to
+    * {@code 0}.
+    * This method is identical to {@link #setIndex(int, int) setIndex(0, 0)}.
+    * <p>
+    * Please note that the behavior of this method is different
+    * from that of NIO buffer, which sets the {@code limit} to
+    * the {@code capacity} of the buffer.
+    */
+   void clear();
+
+   /**
+    * Marks the current {@code readerIndex} in this buffer.  You can
+    * reposition the current {@code readerIndex} to the marked
+    * {@code readerIndex} by calling {@link #resetReaderIndex()}.
+    * The initial value of the marked {@code readerIndex} is {@code 0}.
+    */
+   void markReaderIndex();
+
+   /**
+    * Repositions the current {@code readerIndex} to the marked
+    * {@code readerIndex} in this buffer.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if the current {@code writerIndex} is less than the marked
+    *         {@code readerIndex}
+    */
+   void resetReaderIndex();
+
+   /**
+    * Marks the current {@code writerIndex} in this buffer.  You can
+    * reposition the current {@code writerIndex} to the marked
+    * {@code writerIndex} by calling {@link #resetWriterIndex()}.
+    * The initial value of the marked {@code writerIndex} is {@code 0}.
+    */
+   void markWriterIndex();
+
+   /**
+    * Repositions the current {@code writerIndex} to the marked
+    * {@code writerIndex} in this buffer.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if the current {@code readerIndex} is greater than the marked
+    *         {@code writerIndex}
+    */
+   void resetWriterIndex();
+
+   /**
+    * Discards the bytes between the 0th index and {@code readerIndex}.
+    * It moves the bytes between {@code readerIndex} and {@code writerIndex}
+    * to the 0th index, and sets {@code readerIndex} and {@code writerIndex}
+    * to {@code 0} and {@code oldWriterIndex - oldReaderIndex} respectively.
+    * <p>
+    * Please refer to the class documentation for more detailed explanation.
+    */
+   void discardReadBytes();
+
+   /**
+    * Gets a byte at the specified absolute {@code index} in this buffer.
+    * This method does not modify {@code readerIndex} or {@code writerIndex} of
+    * this buffer.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if the specified {@code index} is less than {@code 0} or
+    *         {@code index + 1} is greater than {@code this.capacity}
+    */
+   byte  getByte(int index);
+
+   /**
+    * Gets an unsigned byte at the specified absolute {@code index} in this
+    * buffer.  This method does not modify {@code readerIndex} or
+    * {@code writerIndex} of this buffer.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if the specified {@code index} is less than {@code 0} or
+    *         {@code index + 1} is greater than {@code this.capacity}
+    */
+   short getUnsignedByte(int index);
+
+   /**
+    * Gets a 16-bit short integer at the specified absolute {@code index} in
+    * this buffer.  This method does not modify {@code readerIndex} or
+    * {@code writerIndex} of this buffer.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if the specified {@code index} is less than {@code 0} or
+    *         {@code index + 2} is greater than {@code this.capacity}
+    */
+   short getShort(int index);
+
+   /**
+    * Gets an unsigned 16-bit short integer at the specified absolute
+    * {@code index} in this buffer.  This method does not modify
+    * {@code readerIndex} or {@code writerIndex} of this buffer.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if the specified {@code index} is less than {@code 0} or
+    *         {@code index + 2} is greater than {@code this.capacity}
+    */
+   int getUnsignedShort(int index);
+
+   /**
+    * Gets a 32-bit integer at the specified absolute {@code index} in
+    * this buffer.  This method does not modify {@code readerIndex} or
+    * {@code writerIndex} of this buffer.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if the specified {@code index} is less than {@code 0} or
+    *         {@code index + 4} is greater than {@code this.capacity}
+    */
+   int   getInt(int index);
+
+   /**
+    * Gets an unsigned 32-bit integer at the specified absolute {@code index}
+    * in this buffer.  This method does not modify {@code readerIndex} or
+    * {@code writerIndex} of this buffer.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if the specified {@code index} is less than {@code 0} or
+    *         {@code index + 4} is greater than {@code this.capacity}
+    */
+   long  getUnsignedInt(int index);
+
+   /**
+    * Gets a 64-bit long integer at the specified absolute {@code index} in
+    * this buffer.  This method does not modify {@code readerIndex} or
+    * {@code writerIndex} of this buffer.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if the specified {@code index} is less than {@code 0} or
+    *         {@code index + 8} is greater than {@code this.capacity}
+    */
+   long  getLong(int index);
+
+   /**
+    * Transfers this buffer's data to the specified destination starting at
+    * the specified absolute {@code index} until the destination becomes
+    * non-writable.  This method is basically same with
+    * {@link #getBytes(int, HornetQBuffer, int, int)}, except that this
+    * method increases the {@code writerIndex} of the destination by the
+    * number of the transferred bytes while
+    * {@link #getBytes(int, HornetQBuffer, int, int)} does not.
+    * This method does not modify {@code readerIndex} or {@code writerIndex} of
+    * the source buffer (i.e. {@code this}).
+    *
+    * @throws IndexOutOfBoundsException
+    *         if the specified {@code index} is less than {@code 0} or
+    *         if {@code index + dst.writableBytes} is greater than
+    *            {@code this.capacity}
+    */
+   void getBytes(int index, HornetQBuffer dst);
+
+   /**
+    * Transfers this buffer's data to the specified destination starting at
+    * the specified absolute {@code index}.  This method is basically same
+    * with {@link #getBytes(int, HornetQBuffer, int, int)}, except that this
+    * method increases the {@code writerIndex} of the destination by the
+    * number of the transferred bytes while
+    * {@link #getBytes(int, HornetQBuffer, int, int)} does not.
+    * This method does not modify {@code readerIndex} or {@code writerIndex} of
+    * the source buffer (i.e. {@code this}).
+    *
+    * @param length the number of bytes to transfer
+    *
+    * @throws IndexOutOfBoundsException
+    *         if the specified {@code index} is less than {@code 0},
+    *         if {@code index + length} is greater than
+    *            {@code this.capacity}, or
+    *         if {@code length} is greater than {@code dst.writableBytes}
+    */
+   void getBytes(int index, HornetQBuffer dst, int length);
+
+   /**
+    * Transfers this buffer's data to the specified destination starting at
+    * the specified absolute {@code index}.
+    * This method does not modify {@code readerIndex} or {@code writerIndex}
+    * of both the source (i.e. {@code this}) and the destination.
+    *
+    * @param dstIndex the first index of the destination
+    * @param length   the number of bytes to transfer
+    *
+    * @throws IndexOutOfBoundsException
+    *         if the specified {@code index} is less than {@code 0},
+    *         if the specified {@code dstIndex} is less than {@code 0},
+    *         if {@code index + length} is greater than
+    *            {@code this.capacity}, or
+    *         if {@code dstIndex + length} is greater than
+    *            {@code dst.capacity}
+    */
+   void getBytes(int index, HornetQBuffer dst, int dstIndex, int length);
+
+   /**
+    * Transfers this buffer's data to the specified destination starting at
+    * the specified absolute {@code index}.
+    * This method does not modify {@code readerIndex} or {@code writerIndex} of
+    * this buffer
+    *
+    * @throws IndexOutOfBoundsException
+    *         if the specified {@code index} is less than {@code 0} or
+    *         if {@code index + dst.length} is greater than
+    *            {@code this.capacity}
+    */
+   void getBytes(int index, byte[] dst);
+
+   /**
+    * Transfers this buffer's data to the specified destination starting at
+    * the specified absolute {@code index}.
+    * This method does not modify {@code readerIndex} or {@code writerIndex}
+    * of this buffer.
+    *
+    * @param dstIndex the first index of the destination
+    * @param length   the number of bytes to transfer
+    *
+    * @throws IndexOutOfBoundsException
+    *         if the specified {@code index} is less than {@code 0},
+    *         if the specified {@code dstIndex} is less than {@code 0},
+    *         if {@code index + length} is greater than
+    *            {@code this.capacity}, or
+    *         if {@code dstIndex + length} is greater than
+    *            {@code dst.length}
+    */
+   void getBytes(int index, byte[] dst, int dstIndex, int length);
+
+   /**
+    * Transfers this buffer's data to the specified destination starting at
+    * the specified absolute {@code index} until the destination's position
+    * reaches its limit.
+    * This method does not modify {@code readerIndex} or {@code writerIndex} of
+    * this buffer while the destination's {@code position} will be increased.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if the specified {@code index} is less than {@code 0} or
+    *         if {@code index + dst.remaining()} is greater than
+    *            {@code this.capacity}
+    */
+   void getBytes(int index, ByteBuffer dst);
+
+   /**
+    * Gets a char at the specified absolute {@code index} in
+    * this buffer.  This method does not modify {@code readerIndex} or
+    * {@code writerIndex} of this buffer.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if the specified {@code index} is less than {@code 0} or
+    *         {@code index + 2} is greater than {@code this.capacity}
+    */
+   char getChar(int index);
+
+   /**
+    * Gets a float at the specified absolute {@code index} in
+    * this buffer.  This method does not modify {@code readerIndex} or
+    * {@code writerIndex} of this buffer.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if the specified {@code index} is less than {@code 0} or
+    *         {@code index + 4} is greater than {@code this.capacity}
+    */  
+   float getFloat(int index);
+
+   /**
+    * Gets a double at the specified absolute {@code index} in
+    * this buffer.  This method does not modify {@code readerIndex} or
+    * {@code writerIndex} of this buffer.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if the specified {@code index} is less than {@code 0} or
+    *         {@code index + 8} is greater than {@code this.capacity}
+    */    
+   double getDouble(int index);
+
+   /**
+    * Sets the specified byte at the specified absolute {@code index} in this
+    * buffer.
+    * This method does not modify {@code readerIndex} or {@code writerIndex} of
+    * this buffer.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if the specified {@code index} is less than {@code 0} or
+    *         {@code index + 1} is greater than {@code this.capacity}
+    */
+   void setByte(int index, byte value);
+
+   /**
+    * Sets the specified 16-bit short integer at the specified absolute
+    * {@code index} in this buffer.
+    * This method does not modify {@code readerIndex} or {@code writerIndex} of
+    * this buffer.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if the specified {@code index} is less than {@code 0} or
+    *         {@code index + 2} is greater than {@code this.capacity}
+    */
+   void setShort(int index, short value);
+
+   /**
+    * Sets the specified 32-bit integer at the specified absolute
+    * {@code index} in this buffer.
+    * This method does not modify {@code readerIndex} or {@code writerIndex} of
+    * this buffer.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if the specified {@code index} is less than {@code 0} or
+    *         {@code index + 4} is greater than {@code this.capacity}
+    */
+   void setInt(int index, int value);
+
+   /**
+    * Sets the specified 64-bit long integer at the specified absolute
+    * {@code index} in this buffer.
+    * This method does not modify {@code readerIndex} or {@code writerIndex} of
+    * this buffer.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if the specified {@code index} is less than {@code 0} or
+    *         {@code index + 8} is greater than {@code this.capacity}
+    */
+   void setLong(int index, long value);
+
+   /**
+    * Transfers the specified source buffer's data to this buffer starting at
+    * the specified absolute {@code index} until the destination becomes
+    * unreadable.  This method is basically same with
+    * {@link #setBytes(int, HornetQBuffer, int, int)}, except that this
+    * method increases the {@code readerIndex} of the source buffer by
+    * the number of the transferred bytes while
+    * {@link #getBytes(int, HornetQBuffer, int, int)} does not.
+    * This method does not modify {@code readerIndex} or {@code writerIndex} of
+    * the source buffer (i.e. {@code this}).
+    *
+    * @throws IndexOutOfBoundsException
+    *         if the specified {@code index} is less than {@code 0} or
+    *         if {@code index + src.readableBytes} is greater than
+    *            {@code this.capacity}
+    */
+   void setBytes(int index, HornetQBuffer src);
+
+   /**
+    * Transfers the specified source buffer's data to this buffer starting at
+    * the specified absolute {@code index}.  This method is basically same
+    * with {@link #setBytes(int, HornetQBuffer, int, int)}, except that this
+    * method increases the {@code readerIndex} of the source buffer by
+    * the number of the transferred bytes while
+    * {@link #getBytes(int, HornetQBuffer, int, int)} does not.
+    * This method does not modify {@code readerIndex} or {@code writerIndex} of
+    * the source buffer (i.e. {@code this}).
+    *
+    * @param length the number of bytes to transfer
+    *
+    * @throws IndexOutOfBoundsException
+    *         if the specified {@code index} is less than {@code 0},
+    *         if {@code index + length} is greater than
+    *            {@code this.capacity}, or
+    *         if {@code length} is greater than {@code src.readableBytes}
+    */
+   void setBytes(int index, HornetQBuffer src, int length);
+
+   /**
+    * Transfers the specified source buffer's data to this buffer starting at
+    * the specified absolute {@code index}.
+    * This method does not modify {@code readerIndex} or {@code writerIndex}
+    * of both the source (i.e. {@code this}) and the destination.
+    *
+    * @param srcIndex the first index of the source
+    * @param length   the number of bytes to transfer
+    *
+    * @throws IndexOutOfBoundsException
+    *         if the specified {@code index} is less than {@code 0},
+    *         if the specified {@code srcIndex} is less than {@code 0},
+    *         if {@code index + length} is greater than
+    *            {@code this.capacity}, or
+    *         if {@code srcIndex + length} is greater than
+    *            {@code src.capacity}
+    */
+   void setBytes(int index, HornetQBuffer src, int srcIndex, int length);
+
+   /**
+    * Transfers the specified source array's data to this buffer starting at
+    * the specified absolute {@code index}.
+    * This method does not modify {@code readerIndex} or {@code writerIndex} of
+    * this buffer.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if the specified {@code index} is less than {@code 0} or
+    *         if {@code index + src.length} is greater than
+    *            {@code this.capacity}
+    */
+   void setBytes(int index, byte[] src);
+
+   /**
+    * Transfers the specified source array's data to this buffer starting at
+    * the specified absolute {@code index}.
+    * This method does not modify {@code readerIndex} or {@code writerIndex} of
+    * this buffer.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if the specified {@code index} is less than {@code 0},
+    *         if the specified {@code srcIndex} is less than {@code 0},
+    *         if {@code index + length} is greater than
+    *            {@code this.capacity}, or
+    *         if {@code srcIndex + length} is greater than {@code src.length}
+    */
+   void setBytes(int index, byte[] src, int srcIndex, int length);
+
+   /**
+    * Transfers the specified source buffer's data to this buffer starting at
+    * the specified absolute {@code index} until the source buffer's position
+    * reaches its limit.
+    * This method does not modify {@code readerIndex} or {@code writerIndex} of
+    * this buffer.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if the specified {@code index} is less than {@code 0} or
+    *         if {@code index + src.remaining()} is greater than
+    *            {@code this.capacity}
+    */
+   void setBytes(int index, ByteBuffer src);
+
+   /**
+    * Sets the specified char at the specified absolute
+    * {@code index} in this buffer.
+    * This method does not modify {@code readerIndex} or {@code writerIndex} of
+    * this buffer.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if the specified {@code index} is less than {@code 0} or
+    *         {@code index + 2} is greater than {@code this.capacity}
+    */
+   void setChar(int index, char value);
+
+   /**
+    * Sets the specified float at the specified absolute
+    * {@code index} in this buffer.
+    * This method does not modify {@code readerIndex} or {@code writerIndex} of
+    * this buffer.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if the specified {@code index} is less than {@code 0} or
+    *         {@code index + 4} is greater than {@code this.capacity}
+    */
+   void setFloat(int index, float value);
+
+   /**
+    * Sets the specified double at the specified absolute
+    * {@code index} in this buffer.
+    * This method does not modify {@code readerIndex} or {@code writerIndex} of
+    * this buffer.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if the specified {@code index} is less than {@code 0} or
+    *         {@code index + 8} is greater than {@code this.capacity}
+    */
+   void setDouble(int index, double value);
+
+   /**
+    * Gets a byte at the current {@code readerIndex} and increases
+    * the {@code readerIndex} by {@code 1} in this buffer.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if {@code this.readableBytes} is less than {@code 1}
+    */
+   byte readByte();
+
+   /**
+    * Gets an unsigned byte at the current {@code readerIndex} and increases
+    * the {@code readerIndex} by {@code 1} in this buffer.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if {@code this.readableBytes} is less than {@code 1}
+    */
+   short readUnsignedByte();
+
+   /**
+    * Gets a 16-bit short integer at the current {@code readerIndex}
+    * and increases the {@code readerIndex} by {@code 2} in this buffer.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if {@code this.readableBytes} is less than {@code 2}
+    */
+   short readShort();
+
+   /**
+    * Gets an unsigned 16-bit short integer at the current {@code readerIndex}
+    * and increases the {@code readerIndex} by {@code 2} in this buffer.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if {@code this.readableBytes} is less than {@code 2}
+    */
+   int   readUnsignedShort();
+
+   /**
+    * Gets a 32-bit integer at the current {@code readerIndex}
+    * and increases the {@code readerIndex} by {@code 4} in this buffer.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if {@code this.readableBytes} is less than {@code 4}
+    */
+   int   readInt();
+
+   /**
+    * Gets an unsigned 32-bit integer at the current {@code readerIndex}
+    * and increases the {@code readerIndex} by {@code 4} in this buffer.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if {@code this.readableBytes} is less than {@code 4}
+    */
+   long  readUnsignedInt();
+
+   /**
+    * Gets a 64-bit integer at the current {@code readerIndex}
+    * and increases the {@code readerIndex} by {@code 8} in this buffer.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if {@code this.readableBytes} is less than {@code 8}
+    */
+   long  readLong();
+
+   /**
+    * Gets a char at the current {@code readerIndex}
+    * and increases the {@code readerIndex} by {@code 2} in this buffer.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if {@code this.readableBytes} is less than {@code 2}
+    */
+   char readChar();
+
+   /**
+    * Gets a float at the current {@code readerIndex}
+    * and increases the {@code readerIndex} by {@code 4} in this buffer.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if {@code this.readableBytes} is less than {@code 4}
+    */
+   float readFloat();
+
+   /**
+    * Gets a double at the current {@code readerIndex}
+    * and increases the {@code readerIndex} by {@code 8} in this buffer.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if {@code this.readableBytes} is less than {@code 8}
+    */
+   double readDouble();
+
+   /**
+    * Gets a boolean at the current {@code readerIndex}
+    * and increases the {@code readerIndex} by {@code 1} in this buffer.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if {@code this.readableBytes} is less than {@code 1}
+    */
+   boolean readBoolean();
+
+   /**
+    * Gets a SimpleString (potentially {@code null}) at the current {@code readerIndex}
+    */
+   SimpleString readNullableSimpleString();
+
+   /**
+    * Gets a String (potentially {@code null}) at the current {@code readerIndex}
+    */
+   String readNullableString();
+
+   /**
+    * Gets a non-null SimpleString at the current {@code readerIndex}
+    */
+   SimpleString readSimpleString();
+
+   /**
+    * Gets a non-null String at the current {@code readerIndex}
+    */
+   String readString();
+
+   /**
+    * Gets a UTF-8 String at the current {@code readerIndex}
+    */
+   String readUTF();
+
+   /**
+    * Transfers this buffer's data to a newly created buffer starting at
+    * the current {@code readerIndex} and increases the {@code readerIndex}
+    * by the number of the transferred bytes (= {@code length}).
+    * The returned buffer's {@code readerIndex} and {@code writerIndex} are
+    * {@code 0} and {@code length} respectively.
+    *
+    * @param length the number of bytes to transfer
+    *
+    * @return the newly created buffer which contains the transferred bytes
+    *
+    * @throws IndexOutOfBoundsException
+    *         if {@code length} is greater than {@code this.readableBytes}
+    */
+   HornetQBuffer readBytes(int length);
+
+   /**
+    * Returns a new slice of this buffer's sub-region starting at the current
+    * {@code readerIndex} and increases the {@code readerIndex} by the size
+    * of the new slice (= {@code length}).
+    *
+    * @param length the size of the new slice
+    *
+    * @return the newly created slice
+    *
+    * @throws IndexOutOfBoundsException
+    *         if {@code length} is greater than {@code this.readableBytes}
+    */
+   HornetQBuffer readSlice(int length);
+
+   /**
+    * Transfers this buffer's data to the specified destination starting at
+    * the current {@code readerIndex} until the destination becomes
+    * non-writable, and increases the {@code readerIndex} by the number of the
+    * transferred bytes.  This method is basically same with
+    * {@link #readBytes(HornetQBuffer, int, int)}, except that this method
+    * increases the {@code writerIndex} of the destination by the number of
+    * the transferred bytes while {@link #readBytes(HornetQBuffer, int, int)}
+    * does not.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if {@code dst.writableBytes} is greater than
+    *            {@code this.readableBytes}
+    */
+   void readBytes(HornetQBuffer dst);
+
+   /**
+    * Transfers this buffer's data to the specified destination starting at
+    * the current {@code readerIndex} and increases the {@code readerIndex}
+    * by the number of the transferred bytes (= {@code length}).  This method
+    * is basically same with {@link #readBytes(HornetQBuffer, int, int)},
+    * except that this method increases the {@code writerIndex} of the
+    * destination by the number of the transferred bytes (= {@code length})
+    * while {@link #readBytes(HornetQBuffer, int, int)} does not.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if {@code length} is greater than {@code this.readableBytes} or
+    *         if {@code length} is greater than {@code dst.writableBytes}
+    */
+   void readBytes(HornetQBuffer dst, int length);
+
+   /**
+    * Transfers this buffer's data to the specified destination starting at
+    * the current {@code readerIndex} and increases the {@code readerIndex}
+    * by the number of the transferred bytes (= {@code length}).
+    *
+    * @param dstIndex the first index of the destination
+    * @param length   the number of bytes to transfer
+    *
+    * @throws IndexOutOfBoundsException
+    *         if the specified {@code dstIndex} is less than {@code 0},
+    *         if {@code length} is greater than {@code this.readableBytes}, or
+    *         if {@code dstIndex + length} is greater than
+    *            {@code dst.capacity}
+    */
+   void readBytes(HornetQBuffer dst, int dstIndex, int length);
+
+   /**
+    * Transfers this buffer's data to the specified destination starting at
+    * the current {@code readerIndex} and increases the {@code readerIndex}
+    * by the number of the transferred bytes (= {@code dst.length}).
+    *
+    * @throws IndexOutOfBoundsException
+    *         if {@code dst.length} is greater than {@code this.readableBytes}
+    */
+   void readBytes(byte[] dst);
+
+   /**
+    * Transfers this buffer's data to the specified destination starting at
+    * the current {@code readerIndex} and increases the {@code readerIndex}
+    * by the number of the transferred bytes (= {@code length}).
+    *
+    * @param dstIndex the first index of the destination
+    * @param length   the number of bytes to transfer
+    *
+    * @throws IndexOutOfBoundsException
+    *         if the specified {@code dstIndex} is less than {@code 0},
+    *         if {@code length} is greater than {@code this.readableBytes}, or
+    *         if {@code dstIndex + length} is greater than {@code dst.length}
+    */
+   void readBytes(byte[] dst, int dstIndex, int length);
+
+   /**
+    * Transfers this buffer's data to the specified destination starting at
+    * the current {@code readerIndex} until the destination's position
+    * reaches its limit, and increases the {@code readerIndex} by the
+    * number of the transferred bytes.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if {@code dst.remaining()} is greater than
+    *            {@code this.readableBytes}
+    */
+   void readBytes(ByteBuffer dst);
+
+   /**
+    * Increases the current {@code readerIndex} by the specified
+    * {@code length} in this buffer.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if {@code length} is greater than {@code this.readableBytes}
+    */
+   void skipBytes(int length);
+
+   /**
+    * Sets the specified byte at the current {@code writerIndex}
+    * and increases the {@code writerIndex} by {@code 1} in this buffer.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if {@code this.writableBytes} is less than {@code 1}
+    */
+   void writeByte(byte  value);
+
+   /**
+    * Sets the specified 16-bit short integer at the current
+    * {@code writerIndex} and increases the {@code writerIndex} by {@code 2}
+    * in this buffer.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if {@code this.writableBytes} is less than {@code 2}
+    */
+   void writeShort(short value);
+
+   /**
+    * Sets the specified 32-bit integer at the current {@code writerIndex}
+    * and increases the {@code writerIndex} by {@code 4} in this buffer.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if {@code this.writableBytes} is less than {@code 4}
+    */
+   void writeInt(int   value);
+
+   /**
+    * Sets the specified 64-bit long integer at the current
+    * {@code writerIndex} and increases the {@code writerIndex} by {@code 8}
+    * in this buffer.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if {@code this.writableBytes} is less than {@code 8}
+    */
+   void writeLong(long  value);
+
+   /**
+    * Sets the specified char at the current {@code writerIndex}
+    * and increases the {@code writerIndex} by {@code 2} in this buffer.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if {@code this.writableBytes} is less than {@code 2}
+    */
+   void writeChar(char chr);
+
+   /**
+    * Sets the specified float at the current {@code writerIndex}
+    * and increases the {@code writerIndex} by {@code 4} in this buffer.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if {@code this.writableBytes} is less than {@code 4}
+    */
+   void writeFloat(float value);
+
+   /**
+    * Sets the specified double at the current {@code writerIndex}
+    * and increases the {@code writerIndex} by {@code 8} in this buffer.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if {@code this.writableBytes} is less than {@code 8}
+    */
+   void writeDouble(double value);
+
+   /**
+    * Sets the specified boolean at the current {@code writerIndex}
+    */
+   void writeBoolean(boolean val);
+
+   /**
+    * Sets the specified SimpleString (potentially {@code null}) at the current {@code writerIndex}
+    */
+   void writeNullableSimpleString(SimpleString val);
+
+   /**
+    * Sets the specified String (potentially {@code null}) at the current {@code writerIndex}
+    */
+   void writeNullableString(String val);
+
+   /**
+    * Sets the specified non-null SimpleString at the current {@code writerIndex}
+    */
+   void writeSimpleString(SimpleString val);
+
+   /**
+    * Sets the specified non-null String at the current {@code writerIndex}
+    */
+   void writeString(String val);
+
+   /**
+    * Sets the specified UTF-8 String at the current {@code writerIndex}
+    */
+
+   void writeUTF(String utf);
+
+   /**
+    * Transfers the specified source buffer's data to this buffer starting at
+    * the current {@code writerIndex} and increases the {@code writerIndex}
+    * by the number of the transferred bytes (= {@code length}).  This method
+    * is basically same with {@link #writeBytes(HornetQBuffer, int, int)},
+    * except that this method increases the {@code readerIndex} of the source
+    * buffer by the number of the transferred bytes (= {@code length}) while
+    * {@link #writeBytes(HornetQBuffer, int, int)} does not.
+    *
+    * @param length the number of bytes to transfer
+    *
+    * @throws IndexOutOfBoundsException
+    *         if {@code length} is greater than {@code this.writableBytes} or
+    *         if {@code length} is greater then {@code src.readableBytes}
+    */
+   void writeBytes(HornetQBuffer src, int length);
+
+   /**
+    * Transfers the specified source buffer's data to this buffer starting at
+    * the current {@code writerIndex} and increases the {@code writerIndex}
+    * by the number of the transferred bytes (= {@code length}).
+    *
+    * @param srcIndex the first index of the source
+    * @param length   the number of bytes to transfer
+    *
+    * @throws IndexOutOfBoundsException
+    *         if the specified {@code srcIndex} is less than {@code 0},
+    *         if {@code srcIndex + length} is greater than
+    *            {@code src.capacity}, or
+    *         if {@code length} is greater than {@code this.writableBytes}
+    */
+   void writeBytes(HornetQBuffer src, int srcIndex, int length);
+
+   /**
+    * Transfers the specified source array's data to this buffer starting at
+    * the current {@code writerIndex} and increases the {@code writerIndex}
+    * by the number of the transferred bytes (= {@code src.length}).
+    *
+    * @throws IndexOutOfBoundsException
+    *         if {@code src.length} is greater than {@code this.writableBytes}
+    */
+   void writeBytes(byte[] src);
+
+   /**
+    * Transfers the specified source array's data to this buffer starting at
+    * the current {@code writerIndex} and increases the {@code writerIndex}
+    * by the number of the transferred bytes (= {@code length}).
+    *
+    * @param srcIndex the first index of the source
+    * @param length   the number of bytes to transfer
+    *
+    * @throws IndexOutOfBoundsException
+    *         if the specified {@code srcIndex} is less than {@code 0},
+    *         if {@code srcIndex + length} is greater than
+    *            {@code src.length}, or
+    *         if {@code length} is greater than {@code this.writableBytes}
+    */
+   void writeBytes(byte[] src, int srcIndex, int length);
+
+   /**
+    * Transfers the specified source buffer's data to this buffer starting at
+    * the current {@code writerIndex} until the source buffer's position
+    * reaches its limit, and increases the {@code writerIndex} by the
+    * number of the transferred bytes.
+    *
+    * @throws IndexOutOfBoundsException
+    *         if {@code src.remaining()} is greater than
+    *            {@code this.writableBytes}
+    */
+   void writeBytes(ByteBuffer src);
+
+   /**
+    * Returns a copy of this buffer's readable bytes.  Modifying the content
+    * of the returned buffer or this buffer does not affect each other at all.
+    * This method is identical to {@code buf.copy(buf.readerIndex(), buf.readableBytes())}.
+    * This method does not modify {@code readerIndex} or {@code writerIndex} of
+    * this buffer.
+    *
+    */
+   HornetQBuffer copy();
+
+   /**
+    * Returns a copy of this buffer's sub-region.  Modifying the content of
+    * the returned buffer or this buffer does not affect each other at all.
+    * This method does not modify {@code readerIndex} or {@code writerIndex} of
+    * this buffer.
+    */
+   HornetQBuffer copy(int index, int length);
+
+   /**
+    * Returns a slice of this buffer's readable bytes. Modifying the content
+    * of the returned buffer or this buffer affects each other's content
+    * while they maintain separate indexes and marks.  This method is
+    * identical to {@code buf.slice(buf.readerIndex(), buf.readableBytes())}.
+    * This method does not modify {@code readerIndex} or {@code writerIndex} of
+    * this buffer.
+    */
+   HornetQBuffer slice();
+
+   /**
+    * Returns a slice of this buffer's sub-region. Modifying the content of
+    * the returned buffer or this buffer affects each other's content while
+    * they maintain separate indexes and marks.
+    * This method does not modify {@code readerIndex} or {@code writerIndex} of
+    * this buffer.
+    */
+   HornetQBuffer slice(int index, int length);
+
+   /**
+    * Returns a buffer which shares the whole region of this buffer.
+    * Modifying the content of the returned buffer or this buffer affects
+    * each other's content while they maintain separate indexes and marks.
+    * This method is identical to {@code buf.slice(0, buf.capacity())}.
+    * This method does not modify {@code readerIndex} or {@code writerIndex} of
+    * this buffer.
+    */
+   HornetQBuffer duplicate();
+
+   /**
+    * Converts this buffer's readable bytes into a NIO buffer.  The returned
+    * buffer might or might not share the content with this buffer, while
+    * they have separate indexes and marks.  This method is identical to
+    * {@code buf.toByteBuffer(buf.readerIndex(), buf.readableBytes())}.
+    * This method does not modify {@code readerIndex} or {@code writerIndex} of
+    * this buffer.
+    */
+   ByteBuffer toByteBuffer();
+
+   /**
+    * Converts this buffer's sub-region into a NIO buffer.  The returned
+    * buffer might or might not share the content with this buffer, while
+    * they have separate indexes and marks.
+    * This method does not modify {@code readerIndex} or {@code writerIndex} of
+    * this buffer.
+    */
+   ByteBuffer toByteBuffer(int index, int length);
+}

Copied: trunk/hornetq-commons/src/main/java/org/hornetq/api/core/HornetQBuffers.java (from rev 10738, trunk/hornetq-core/src/main/java/org/hornetq/api/core/HornetQBuffers.java)
===================================================================
--- trunk/hornetq-commons/src/main/java/org/hornetq/api/core/HornetQBuffers.java	                        (rev 0)
+++ trunk/hornetq-commons/src/main/java/org/hornetq/api/core/HornetQBuffers.java	2011-05-26 12:50:50 UTC (rev 10739)
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.api.core;
+
+import java.nio.ByteBuffer;
+
+import org.hornetq.core.buffers.impl.ChannelBufferWrapper;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+
+/**
+ * Factory class to create HornetQBuffers
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ */
+public class HornetQBuffers
+{   
+   /**
+    * Creates a <em>self-expanding</em> HornetQBuffer with the given initial size
+    * 
+    * @param size the initial size of the created HornetQBuffer
+    * @return a self-expanding HornetQBuffer starting with the given size
+    */
+   public static HornetQBuffer dynamicBuffer(final int size)
+   {
+      return new ChannelBufferWrapper(ChannelBuffers.dynamicBuffer(size));
+   }
+
+   /**
+    * Creates a <em>self-expanding</em> HornetQBuffer filled with the given byte array
+    * 
+    * @param bytes the created buffer will be initially filled with this byte array
+    * @return a self-expanding HornetQBuffer filled with the given byte array
+    */
+   public static HornetQBuffer dynamicBuffer(final byte[] bytes)
+   {
+      ChannelBuffer buff = ChannelBuffers.dynamicBuffer(bytes.length);
+
+      buff.writeBytes(bytes);
+
+      return new ChannelBufferWrapper(buff);
+   }
+
+   /**
+    * Creates a HornetQBuffer wrapping an underlying NIO ByteBuffer
+    * 
+    * The position on this buffer won't affect the position on the inner buffer
+    * 
+    * @param underlying the underlying NIO ByteBuffer
+    * @return a HornetQBuffer wrapping the underlying NIO ByteBuffer
+    */
+   public static HornetQBuffer wrappedBuffer(final ByteBuffer underlying)
+   {
+      HornetQBuffer buff = new ChannelBufferWrapper(ChannelBuffers.wrappedBuffer(underlying));
+
+      buff.clear();
+
+      return buff;
+   }
+
+   /**
+    * Creates a HornetQBuffer wrapping an underlying byte array
+    *
+    * @param underlying the underlying byte array
+    * @return a HornetQBuffer wrapping the underlying byte array
+    */
+   public static HornetQBuffer wrappedBuffer(final byte[] underlying)
+   {
+      return new ChannelBufferWrapper(ChannelBuffers.wrappedBuffer(underlying));
+   }
+
+   /**
+    * Creates a <em>fixed</em> HornetQBuffer of the given size
+    * 
+    * @param size the size of the created HornetQBuffer
+    * @return a fixed HornetQBuffer with the given size
+    */
+   public static HornetQBuffer fixedBuffer(final int size)
+   {
+      return new ChannelBufferWrapper(ChannelBuffers.buffer(size));
+   }
+   
+   private HornetQBuffers()
+   {
+   }
+}

Copied: trunk/hornetq-commons/src/main/java/org/hornetq/api/core/HornetQException.java (from rev 10738, trunk/hornetq-core/src/main/java/org/hornetq/api/core/HornetQException.java)
===================================================================
--- trunk/hornetq-commons/src/main/java/org/hornetq/api/core/HornetQException.java	                        (rev 0)
+++ trunk/hornetq-commons/src/main/java/org/hornetq/api/core/HornetQException.java	2011-05-26 12:50:50 UTC (rev 10739)
@@ -0,0 +1,226 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.api.core;
+
+/**
+ * 
+ * HornetQException is the root exception for HornetQ API. 
+ * 
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public class HornetQException extends Exception
+{
+   private static final long serialVersionUID = -4802014152804997417L;
+
+   // Error codes -------------------------------------------------
+
+   /**
+    * Internal error which prevented HornetQ to perform.
+    */
+   public static final int INTERNAL_ERROR = 000;
+
+   /**
+    * A packet of unsupported type was received by HornetQ PacketHandler.
+    */
+   public static final int UNSUPPORTED_PACKET = 001;
+
+   /**
+    * A client is not able to connect to HornetQ server.
+    */
+   public static final int NOT_CONNECTED = 002;
+
+   /**
+    * A client timed out will connecting to HornetQ server.
+    */
+   public static final int CONNECTION_TIMEDOUT = 003;
+
+   /**
+    * A client was disconnected from HornetQ server when the server has shut down.
+    */
+   public static final int DISCONNECTED = 004;
+
+   /**
+    * A blocking call from a client was unblocked during failover.
+    */
+   public static final int UNBLOCKED = 005;
+
+   /**
+    * Unexpected I/O error occured on the server.
+    */
+   public static final int IO_ERROR = 006;
+
+   /**
+    * An operation failed because a queue does not exist on the server.
+    */
+   public static final int QUEUE_DOES_NOT_EXIST = 100;
+
+   /**
+    * An operation failed because a queue exists on the server.
+    */
+   public static final int QUEUE_EXISTS = 101;
+
+   /**
+    * A client operation failed because the calling resource
+    * (ClientSession, ClientProducer, etc.) is closed.
+    */
+   public static final int OBJECT_CLOSED = 102;
+
+   /**
+    * An filter expression has not been validated
+    */
+   public static final int INVALID_FILTER_EXPRESSION = 103;
+
+   /**
+    * A HornetQ resource is not in a legal state (e.g. calling 
+    * ClientConsumer.receive() if a MessageHandler is set)
+    */
+   public static final int ILLEGAL_STATE = 104;
+
+   /**
+    * A security problem occured (authentication issues, permission issues,...)
+    */
+   public static final int SECURITY_EXCEPTION = 105;
+
+   /**
+    * An operation failed because an address does not exist on the server.
+    */
+   public static final int ADDRESS_DOES_NOT_EXIST = 106;
+
+   /**
+    * An operation failed because an address exists on the server.
+    */
+   public static final int ADDRESS_EXISTS = 107;
+
+   /**
+    * A incompatibility between HornetQ versions on the client and the server has been detected
+    */
+   public static final int INCOMPATIBLE_CLIENT_SERVER_VERSIONS = 108;
+
+   /**
+    * An operation failed because a session exists on the server.
+    */
+   public static final int SESSION_EXISTS = 109;
+
+   /**
+    * An problem occurred while manipulating the body of a large message.
+    */
+   public static final int LARGE_MESSAGE_ERROR_BODY = 110;
+
+   /**
+    * A transaction was rolled back.
+    */
+   public static final int TRANSACTION_ROLLED_BACK = 111;
+
+   /**
+    * The creation of a session was rejected by the server (e.g. if the
+    * server is starting and has not finish to be initialized)
+    */
+   public static final int SESSION_CREATION_REJECTED = 112;
+   
+   /**
+    * A DuplicateID was rejected.
+    */
+   public static final int DUPLICATE_ID_REJECTED = 113;
+
+   
+   // Native Error codes ----------------------------------------------
+
+   /**
+    * A internal error occured in the AIO native code
+    */
+   public static final int NATIVE_ERROR_INTERNAL = 200;
+
+   /**
+    * A buffer is invalid in the AIO native code
+    */
+   public static final int NATIVE_ERROR_INVALID_BUFFER = 201;
+
+   /**
+    * Alignment error in the AIO native code
+    */
+   public static final int NATIVE_ERROR_NOT_ALIGNED = 202;
+
+   /**
+    * AIO has not been properly initialized
+    */
+   public static final int NATIVE_ERROR_CANT_INITIALIZE_AIO = 203;
+
+   /**
+    * AIO has not been properly released
+    */
+   public static final int NATIVE_ERROR_CANT_RELEASE_AIO = 204;
+
+   /**
+    * A closed file has not be properly reopened
+    */
+   public static final int NATIVE_ERROR_CANT_OPEN_CLOSE_FILE = 205;
+
+   /**
+    * An error occured while allocating a queue in AIO native code
+    */
+   public static final int NATIVE_ERROR_CANT_ALLOCATE_QUEUE = 206;
+
+   /**
+    * An error occured while pre-allocating a file in AIO native code
+    */
+   public static final int NATIVE_ERROR_PREALLOCATE_FILE = 208;
+
+   /**
+    * An error occurred while allocating memory in the AIO native code
+    */
+   public static final int NATIVE_ERROR_ALLOCATE_MEMORY = 209;
+
+   /**
+    * AIO is full
+    */
+   public static final int NATIVE_ERROR_AIO_FULL = 211;
+
+   private int code;
+
+   public HornetQException()
+   {
+   }
+
+   public HornetQException(final int code)
+   {
+      this.code = code;
+   }
+
+   public HornetQException(final int code, final String msg)
+   {
+      super(msg);
+
+      this.code = code;
+   }
+
+   public HornetQException(final int code, final String msg, final Throwable cause)
+   {
+      super(msg, cause);
+
+      this.code = code;
+   }
+
+   public int getCode()
+   {
+      return code;
+   }
+
+   @Override
+   public String toString()
+   {
+      return "HornetQException[errorCode=" + code + " message=" + getMessage() + "]";
+   }
+
+}

Copied: trunk/hornetq-commons/src/main/java/org/hornetq/api/core/Pair.java (from rev 10738, trunk/hornetq-core/src/main/java/org/hornetq/api/core/Pair.java)
===================================================================
--- trunk/hornetq-commons/src/main/java/org/hornetq/api/core/Pair.java	                        (rev 0)
+++ trunk/hornetq-commons/src/main/java/org/hornetq/api/core/Pair.java	2011-05-26 12:50:50 UTC (rev 10739)
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.api.core;
+
+import java.io.Serializable;
+
+/**
+ * 
+ * A Pair is a holder for 2 objects.
+ * 
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public class Pair<A, B> implements Serializable
+{
+   private static final long serialVersionUID = -2496357457812368127L;
+
+   public Pair(final A a, final B b)
+   {
+      this.a = a;
+
+      this.b = b;
+   }
+
+   public A a;
+
+   public B b;
+
+   private int hash = -1;
+
+   @Override
+   public int hashCode()
+   {
+      if (hash == -1)
+      {
+         if (a == null && b == null)
+         {
+            return super.hashCode();
+         }
+         else
+         {
+            hash = (a == null ? 0 : a.hashCode()) + 37 * (b == null ? 0 : b.hashCode());
+         }
+      }
+
+      return hash;
+   }
+
+   @Override
+   public boolean equals(final Object other)
+   {
+      if (other == this)
+      {
+         return true;
+      }
+
+      if (other instanceof Pair == false)
+      {
+         return false;
+      }
+
+      Pair<A, B> pother = (Pair<A, B>)other;
+
+      return (pother.a == null ? a == null : pother.a.equals(a)) && (pother.b == null ? b == null : pother.b.equals(b));
+
+   }
+
+   @Override
+   public String toString()
+   {
+      return "Pair[a=" + a + ", b=" + b + "]";
+   }
+}

Copied: trunk/hornetq-commons/src/main/java/org/hornetq/api/core/SimpleString.java (from rev 10738, trunk/hornetq-core/src/main/java/org/hornetq/api/core/SimpleString.java)
===================================================================
--- trunk/hornetq-commons/src/main/java/org/hornetq/api/core/SimpleString.java	                        (rev 0)
+++ trunk/hornetq-commons/src/main/java/org/hornetq/api/core/SimpleString.java	2011-05-26 12:50:50 UTC (rev 10739)
@@ -0,0 +1,426 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.api.core;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.hornetq.core.logging.Logger;
+import org.hornetq.utils.DataConstants;
+
+/**
+ * A simple String class that can store all characters, and stores as simple byte[],
+ * this minimises expensive copying between String objects.
+ *
+ * This object is used heavily throughout HornetQ for performance reasons.
+ * 
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+
+public class SimpleString implements CharSequence, Serializable, Comparable<SimpleString>
+{
+   private static final long serialVersionUID = 4204223851422244307L;
+
+   private static final Logger log = Logger.getLogger(SimpleString.class);
+
+   // Attributes
+   // ------------------------------------------------------------------------
+   private final byte[] data;
+
+   private transient int hash;
+
+   // Cache the string
+   private transient String str;
+
+   // Static
+   // ----------------------------------------------------------------------
+
+   /**
+    * Returns a SimpleString constructed from the <code>string</code> parameter.
+    * If <code>string</code> is <code>null</code>, the return value will be <code>null</code> too.
+    */
+   public static SimpleString toSimpleString(final String string)
+   {
+      if (string == null)
+      {
+         return null;
+      }
+      return new SimpleString(string);
+   }
+
+   // Constructors
+   // ----------------------------------------------------------------------
+   /**
+    * creates a SimpleString from a conventional String
+    * @param string the string to transform
+    */
+   public SimpleString(final String string)
+   {
+      int len = string.length();
+
+      data = new byte[len << 1];
+
+      int j = 0;
+
+      for (int i = 0; i < len; i++)
+      {
+         char c = string.charAt(i);
+
+         byte low = (byte)(c & 0xFF); // low byte
+
+         data[j++] = low;
+
+         byte high = (byte)(c >> 8 & 0xFF); // high byte
+
+         data[j++] = high;
+      }
+
+      str = string;
+   }
+
+   /**
+    * creates a SimpleString from a byte array
+    * @param data the byte array to use
+    */
+   public SimpleString(final byte[] data)
+   {
+      this.data = data;
+   }
+
+   // CharSequence implementation
+   // ---------------------------------------------------------------------------
+
+   public int length()
+   {
+      return data.length >> 1;
+   }
+
+   public char charAt(int pos)
+   {
+      if (pos < 0 || pos >= data.length >> 1)
+      {
+         throw new IndexOutOfBoundsException();
+      }
+      pos <<= 1;
+
+      return (char)(data[pos] | data[pos + 1] << 8);
+   }
+
+   public CharSequence subSequence(final int start, final int end)
+   {
+      int len = data.length >> 1;
+
+      if (end < start || start < 0 || end > len)
+      {
+         throw new IndexOutOfBoundsException();
+      }
+      else
+      {
+         int newlen = end - start << 1;
+         byte[] bytes = new byte[newlen];
+
+         System.arraycopy(data, start << 1, bytes, 0, newlen);
+
+         return new SimpleString(bytes);
+      }
+   }
+
+   // Comparable implementation -------------------------------------
+
+   public int compareTo(final SimpleString o)
+   {
+      return toString().compareTo(o.toString());
+   }
+
+   // Public
+   // ---------------------------------------------------------------------------
+
+   /**
+    * returns the underlying byte array of this SimpleString
+    * @return the byte array
+    */
+   public byte[] getData()
+   {
+      return data;
+   }
+
+   /**
+    * returns true if the SimpleString parameter starts with the same data as this one. false if not.
+    * @param other the SimpelString to look for
+    * @return true if this SimpleString starts with the same data
+    */
+   public boolean startsWith(final SimpleString other)
+   {
+      byte[] otherdata = other.data;
+
+      if (otherdata.length > data.length)
+      {
+         return false;
+      }
+
+      for (int i = 0; i < otherdata.length; i++)
+      {
+         if (data[i] != otherdata[i])
+         {
+            return false;
+         }
+      }
+
+      return true;
+   }
+
+   @Override
+   public String toString()
+   {
+      if (str == null)
+      {
+         int len = data.length >> 1;
+
+         char[] chars = new char[len];
+
+         int j = 0;
+
+         for (int i = 0; i < len; i++)
+         {
+            int low = data[j++] & 0xFF;
+
+            int high = data[j++] << 8 & 0xFF00;
+
+            chars[i] = (char)(low | high);
+         }
+
+         str = new String(chars);
+      }
+
+      return str;
+   }
+
+   @Override
+   public boolean equals(final Object other)
+   {
+      if (this == other)
+      {
+         return true;
+      }
+      
+      if (other instanceof SimpleString)
+      {
+         SimpleString s = (SimpleString)other;
+
+         if (data.length != s.data.length)
+         {
+            return false;
+         }
+
+         for (int i = 0; i < data.length; i++)
+         {
+            if (data[i] != s.data[i])
+            {
+               return false;
+            }
+         }
+
+         return true;
+      }
+      else
+      {
+         return false;
+      }
+   }
+
+   @Override
+   public int hashCode()
+   {
+      if (hash == 0)
+      {
+         int tmphash = 0;
+         for (byte element : data)
+         {
+            tmphash = (tmphash << 5) - tmphash + element; // (hash << 5) - hash is same as hash * 31
+         }
+         hash = tmphash;
+      }
+
+      return hash;
+   }
+
+   /**
+    * splits this SimpleString into an array of SimpleString using the char param as the delimeter.
+    *
+    * i.e. "a.b" would return "a" and "b" if . was the delimeter
+    * @param delim
+    */
+   public SimpleString[] split(final char delim)
+   {
+      if (!contains(delim))
+      {
+         return new SimpleString[] { this };
+      }
+      else
+      {
+         List<SimpleString> all = new ArrayList<SimpleString>();
+         int lasPos = 0;
+         for (int i = 0; i < data.length; i += 2)
+         {
+            byte low = (byte)(delim & 0xFF); // low byte
+            byte high = (byte)(delim >> 8 & 0xFF); // high byte
+            if (data[i] == low && data[i + 1] == high)
+            {
+               byte[] bytes = new byte[i - lasPos];
+               System.arraycopy(data, lasPos, bytes, 0, bytes.length);
+               lasPos = i + 2;
+               all.add(new SimpleString(bytes));
+            }
+         }
+         byte[] bytes = new byte[data.length - lasPos];
+         System.arraycopy(data, lasPos, bytes, 0, bytes.length);
+         all.add(new SimpleString(bytes));
+         SimpleString[] parts = new SimpleString[all.size()];
+         return all.toArray(parts);
+      }
+   }
+
+   /**
+    * checks to see if this SimpleString contains the char parameter passed in
+    *
+    * @param c the char to check for
+    * @return true if the char is found, false otherwise.
+    */
+   public boolean contains(final char c)
+   {
+      for (int i = 0; i < data.length; i += 2)
+      {
+         byte low = (byte)(c & 0xFF); // low byte
+         byte high = (byte)(c >> 8 & 0xFF); // high byte
+         if (data[i] == low && data[i + 1] == high)
+         {
+            return true;
+         }
+      }
+      return false;
+   }
+
+   /**
+    * concatanates a SimpleString and a String
+    *
+    * @param toAdd the String to concate with.
+    * @return the concatanated SimpleString
+    */
+   public SimpleString concat(final String toAdd)
+   {
+      return concat(new SimpleString(toAdd));
+   }
+
+   /**
+    * concatanates 2 SimpleString's
+    *
+    * @param toAdd the SimpleString to concate with.
+    * @return the concatanated SimpleString
+    */
+   public SimpleString concat(final SimpleString toAdd)
+   {
+      byte[] bytes = new byte[data.length + toAdd.getData().length];
+      System.arraycopy(data, 0, bytes, 0, data.length);
+      System.arraycopy(toAdd.getData(), 0, bytes, data.length, toAdd.getData().length);
+      return new SimpleString(bytes);
+   }
+
+   /**
+    * concatanates a SimpleString and a char
+    *
+    * @param c the char to concate with.
+    * @return the concatanated SimpleString
+    */
+   public SimpleString concat(final char c)
+   {
+      byte[] bytes = new byte[data.length + 2];
+      System.arraycopy(data, 0, bytes, 0, data.length);
+      bytes[data.length] = (byte)(c & 0xFF);
+      bytes[data.length + 1] = (byte)(c >> 8 & 0xFF);
+      return new SimpleString(bytes);
+   }
+
+   /**
+    * returns the size of this SimpleString
+    * @return the size
+    */
+   public int sizeof()
+   {
+      return DataConstants.SIZE_INT + data.length;
+   }
+
+   /**
+    * returns the size of a SimpleString
+    * @param str the SimpleString to check
+    * @return the size
+    */
+   public static int sizeofString(final SimpleString str)
+   {
+      return str.sizeof();
+   }
+
+   /**
+    * returns the size of a SimpleString which could be null
+    * @param str the SimpleString to check
+    * @return the size
+    */
+   public static int sizeofNullableString(final SimpleString str)
+   {
+      if (str == null)
+      {
+         return 1;
+      }
+      else
+      {
+         return 1 + str.sizeof();
+      }
+   }
+
+   /**
+    * 
+    * @param srcBegin
+    * @param srcEnd
+    * @param dst
+    * @param dstBegin
+    */
+   public void getChars(final int srcBegin, final int srcEnd, final char dst[], final int dstBegin)
+   {
+      if (srcBegin < 0)
+      {
+         throw new StringIndexOutOfBoundsException(srcBegin);
+      }
+      if (srcEnd > length())
+      {
+         throw new StringIndexOutOfBoundsException(srcEnd);
+      }
+      if (srcBegin > srcEnd)
+      {
+         throw new StringIndexOutOfBoundsException(srcEnd - srcBegin);
+      }
+
+      int j = 0;
+
+      for (int i = srcBegin; i < srcEnd - srcBegin; i++)
+      {
+         int low = data[j++] & 0xFF;
+
+         int high = data[j++] << 8 & 0xFF00;
+
+         dst[i] = (char)(low | high);
+      }
+   }
+
+}
\ No newline at end of file

Copied: trunk/hornetq-commons/src/main/java/org/hornetq/core/buffers/impl/ChannelBufferWrapper.java (from rev 10738, trunk/hornetq-core/src/main/java/org/hornetq/core/buffers/impl/ChannelBufferWrapper.java)
===================================================================
--- trunk/hornetq-commons/src/main/java/org/hornetq/core/buffers/impl/ChannelBufferWrapper.java	                        (rev 0)
+++ trunk/hornetq-commons/src/main/java/org/hornetq/core/buffers/impl/ChannelBufferWrapper.java	2011-05-26 12:50:50 UTC (rev 10739)
@@ -0,0 +1,620 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.core.buffers.impl;
+
+import java.nio.ByteBuffer;
+
+import org.hornetq.api.core.HornetQBuffer;
+import org.hornetq.api.core.SimpleString;
+import org.hornetq.core.logging.Logger;
+import org.hornetq.utils.DataConstants;
+import org.hornetq.utils.UTF8Util;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+/**
+ * 
+ * A ChannelBufferWrapper
+ *
+ * @author Tim Fox
+ *
+ *
+ */
+public class ChannelBufferWrapper implements HornetQBuffer
+{
+   private static final Logger log = Logger.getLogger(ChannelBufferWrapper.class);
+
+   protected ChannelBuffer buffer;
+
+   public ChannelBufferWrapper(final ChannelBuffer buffer)
+   {
+      this.buffer = buffer;
+   }
+
+   public boolean readBoolean()
+   {
+      return readByte() != 0;
+   }
+
+   public SimpleString readNullableSimpleString()
+   {
+      int b = buffer.readByte();
+      if (b == DataConstants.NULL)
+      {
+         return null;
+      }
+      else
+      {
+         return readSimpleStringInternal();
+      }
+   }
+
+   public String readNullableString()
+   {
+      int b = buffer.readByte();
+      if (b == DataConstants.NULL)
+      {
+         return null;
+      }
+      else
+      {
+         return readStringInternal();
+      }
+   }
+
+   public SimpleString readSimpleString()
+   {
+      return readSimpleStringInternal();
+   }
+
+   private SimpleString readSimpleStringInternal()
+   {
+      int len = buffer.readInt();
+      byte[] data = new byte[len];
+      buffer.readBytes(data);
+      return new SimpleString(data);
+   }
+
+   public String readString()
+   {
+      return readStringInternal();
+   }
+
+   private String readStringInternal()
+   {
+      int len = buffer.readInt();
+
+      if (len < 9)
+      {
+         char[] chars = new char[len];
+         for (int i = 0; i < len; i++)
+         {
+            chars[i] = (char)buffer.readShort();
+         }
+         return new String(chars);
+      }
+      else if (len < 0xfff)
+      {
+         return readUTF();
+      }
+      else
+      {
+         return readSimpleStringInternal().toString();
+      }
+   }
+
+   public String readUTF()
+   {
+      return UTF8Util.readUTF(this);
+   }
+
+   public void writeBoolean(final boolean val)
+   {
+      buffer.writeByte((byte)(val ? -1 : 0));
+   }
+
+   public void writeNullableSimpleString(final SimpleString val)
+   {
+      if (val == null)
+      {
+         buffer.writeByte(DataConstants.NULL);
+      }
+      else
+      {
+         buffer.writeByte(DataConstants.NOT_NULL);
+         writeSimpleStringInternal(val);
+      }
+   }
+
+   public void writeNullableString(final String val)
+   {
+      if (val == null)
+      {
+         buffer.writeByte(DataConstants.NULL);
+      }
+      else
+      {
+         buffer.writeByte(DataConstants.NOT_NULL);
+         writeStringInternal(val);
+      }
+   }
+
+   public void writeSimpleString(final SimpleString val)
+   {
+      writeSimpleStringInternal(val);
+   }
+
+   private void writeSimpleStringInternal(final SimpleString val)
+   {
+      byte[] data = val.getData();
+      buffer.writeInt(data.length);
+      buffer.writeBytes(data);
+   }
+
+   public void writeString(final String val)
+   {
+      writeStringInternal(val);
+   }
+
+   private void writeStringInternal(final String val)
+   {
+      int length = val.length();
+
+      buffer.writeInt(length);
+
+      if (length < 9)
+      {
+         // If very small it's more performant to store char by char
+         for (int i = 0; i < val.length(); i++)
+         {
+            buffer.writeShort((short)val.charAt(i));
+         }
+      }
+      else if (length < 0xfff)
+      {
+         // Store as UTF - this is quicker than char by char for most strings
+         writeUTF(val);
+      }
+      else
+      {
+         // Store as SimpleString, since can't store utf > 0xffff in length
+         writeSimpleStringInternal(new SimpleString(val));
+      }
+   }
+
+   public void writeUTF(final String utf)
+   {
+      UTF8Util.saveUTF(this, utf);
+   }
+
+   public int capacity()
+   {
+      return buffer.capacity();
+   }
+
+   public ChannelBuffer channelBuffer()
+   {
+      return buffer;
+   }
+
+   public void clear()
+   {
+      buffer.clear();
+   }
+
+   public HornetQBuffer copy()
+   {
+      return new ChannelBufferWrapper(buffer.copy());
+   }
+
+   public HornetQBuffer copy(final int index, final int length)
+   {
+      return new ChannelBufferWrapper(buffer.copy(index, length));
+   }
+
+   public void discardReadBytes()
+   {
+      buffer.discardReadBytes();
+   }
+
+   public HornetQBuffer duplicate()
+   {
+      return new ChannelBufferWrapper(buffer.duplicate());
+   }
+
+   public byte getByte(final int index)
+   {
+      return buffer.getByte(index);
+   }
+
+   public void getBytes(final int index, final byte[] dst, final int dstIndex, final int length)
+   {
+      buffer.getBytes(index, dst, dstIndex, length);
+   }
+
+   public void getBytes(final int index, final byte[] dst)
+   {
+      buffer.getBytes(index, dst);
+   }
+
+   public void getBytes(final int index, final ByteBuffer dst)
+   {
+      buffer.getBytes(index, dst);
+   }
+
+   public void getBytes(final int index, final HornetQBuffer dst, final int dstIndex, final int length)
+   {
+      buffer.getBytes(index, dst.channelBuffer(), dstIndex, length);
+   }
+
+   public void getBytes(final int index, final HornetQBuffer dst, final int length)
+   {
+      buffer.getBytes(index, dst.channelBuffer(), length);
+   }
+
+   public void getBytes(final int index, final HornetQBuffer dst)
+   {
+      buffer.getBytes(index, dst.channelBuffer());
+   }
+
+   public char getChar(final int index)
+   {
+      return (char)buffer.getShort(index);
+   }
+
+   public double getDouble(final int index)
+   {
+      return Double.longBitsToDouble(buffer.getLong(index));
+   }
+
+   public float getFloat(final int index)
+   {
+      return Float.intBitsToFloat(buffer.getInt(index));
+   }
+
+   public int getInt(final int index)
+   {
+      return buffer.getInt(index);
+   }
+
+   public long getLong(final int index)
+   {
+      return buffer.getLong(index);
+   }
+
+   public short getShort(final int index)
+   {
+      return buffer.getShort(index);
+   }
+
+   public short getUnsignedByte(final int index)
+   {
+      return buffer.getUnsignedByte(index);
+   }
+
+   public long getUnsignedInt(final int index)
+   {
+      return buffer.getUnsignedInt(index);
+   }
+
+   public int getUnsignedShort(final int index)
+   {
+      return buffer.getUnsignedShort(index);
+   }
+
+   public void markReaderIndex()
+   {
+      buffer.markReaderIndex();
+   }
+
+   public void markWriterIndex()
+   {
+      buffer.markWriterIndex();
+   }
+
+   public boolean readable()
+   {
+      return buffer.readable();
+   }
+
+   public int readableBytes()
+   {
+      return buffer.readableBytes();
+   }
+
+   public byte readByte()
+   {
+      return buffer.readByte();
+   }
+
+   public void readBytes(final byte[] dst, final int dstIndex, final int length)
+   {
+      buffer.readBytes(dst, dstIndex, length);
+   }
+
+   public void readBytes(final byte[] dst)
+   {
+      buffer.readBytes(dst);
+   }
+
+   public void readBytes(final ByteBuffer dst)
+   {
+      buffer.readBytes(dst);
+   }
+
+   public void readBytes(final HornetQBuffer dst, final int dstIndex, final int length)
+   {
+      buffer.readBytes(dst.channelBuffer(), dstIndex, length);
+   }
+
+   public void readBytes(final HornetQBuffer dst, final int length)
+   {
+      buffer.readBytes(dst.channelBuffer(), length);
+   }
+
+   public void readBytes(final HornetQBuffer dst)
+   {
+      buffer.readBytes(dst.channelBuffer());
+   }
+
+   public HornetQBuffer readBytes(final int length)
+   {
+      return new ChannelBufferWrapper(buffer.readBytes(length));
+   }
+
+   public char readChar()
+   {
+      return (char)buffer.readShort();
+   }
+
+   public double readDouble()
+   {
+      return Double.longBitsToDouble(buffer.readLong());
+   }
+
+   public int readerIndex()
+   {
+      return buffer.readerIndex();
+   }
+
+   public void readerIndex(final int readerIndex)
+   {
+      buffer.readerIndex(readerIndex);
+   }
+
+   public float readFloat()
+   {
+      return Float.intBitsToFloat(buffer.readInt());
+   }
+
+   public int readInt()
+   {
+      return buffer.readInt();
+   }
+
+   public long readLong()
+   {
+      return buffer.readLong();
+   }
+
+   public short readShort()
+   {
+      return buffer.readShort();
+   }
+
+   public HornetQBuffer readSlice(final int length)
+   {
+      return new ChannelBufferWrapper(buffer.readSlice(length));
+   }
+
+   public short readUnsignedByte()
+   {
+      return buffer.readUnsignedByte();
+   }
+
+   public long readUnsignedInt()
+   {
+      return buffer.readUnsignedInt();
+   }
+
+   public int readUnsignedShort()
+   {
+      return buffer.readUnsignedShort();
+   }
+
+   public void resetReaderIndex()
+   {
+      buffer.resetReaderIndex();
+   }
+
+   public void resetWriterIndex()
+   {
+      buffer.resetWriterIndex();
+   }
+
+   public void setByte(final int index, final byte value)
+   {
+      buffer.setByte(index, value);
+   }
+
+   public void setBytes(final int index, final byte[] src, final int srcIndex, final int length)
+   {
+      buffer.setBytes(index, src, srcIndex, length);
+   }
+
+   public void setBytes(final int index, final byte[] src)
+   {
+      buffer.setBytes(index, src);
+   }
+
+   public void setBytes(final int index, final ByteBuffer src)
+   {
+      buffer.setBytes(index, src);
+   }
+
+   public void setBytes(final int index, final HornetQBuffer src, final int srcIndex, final int length)
+   {
+      buffer.setBytes(index, src.channelBuffer(), srcIndex, length);
+   }
+
+   public void setBytes(final int index, final HornetQBuffer src, final int length)
+   {
+      buffer.setBytes(index, src.channelBuffer(), length);
+   }
+
+   public void setBytes(final int index, final HornetQBuffer src)
+   {
+      buffer.setBytes(index, src.channelBuffer());
+   }
+
+   public void setChar(final int index, final char value)
+   {
+      buffer.setShort(index, (short)value);
+   }
+
+   public void setDouble(final int index, final double value)
+   {
+      buffer.setLong(index, Double.doubleToLongBits(value));
+   }
+
+   public void setFloat(final int index, final float value)
+   {
+      buffer.setInt(index, Float.floatToIntBits(value));
+   }
+
+   public void setIndex(final int readerIndex, final int writerIndex)
+   {
+      buffer.setIndex(readerIndex, writerIndex);
+   }
+
+   public void setInt(final int index, final int value)
+   {
+      buffer.setInt(index, value);
+   }
+
+   public void setLong(final int index, final long value)
+   {
+      buffer.setLong(index, value);
+   }
+
+   public void setShort(final int index, final short value)
+   {
+      buffer.setShort(index, value);
+   }
+
+   public void skipBytes(final int length)
+   {
+      buffer.skipBytes(length);
+   }
+
+   public HornetQBuffer slice()
+   {
+      return new ChannelBufferWrapper(buffer.slice());
+   }
+
+   public HornetQBuffer slice(final int index, final int length)
+   {
+      return new ChannelBufferWrapper(buffer.slice(index, length));
+   }
+
+   public ByteBuffer toByteBuffer()
+   {
+      return buffer.toByteBuffer();
+   }
+
+   public ByteBuffer toByteBuffer(final int index, final int length)
+   {
+      return buffer.toByteBuffer(index, length);
+   }
+
+   public boolean writable()
+   {
+      return buffer.writable();
+   }
+
+   public int writableBytes()
+   {
+      return buffer.writableBytes();
+   }
+
+   public void writeByte(final byte value)
+   {
+      buffer.writeByte(value);
+   }
+
+   public void writeBytes(final byte[] src, final int srcIndex, final int length)
+   {
+      buffer.writeBytes(src, srcIndex, length);
+   }
+
+   public void writeBytes(final byte[] src)
+   {
+      buffer.writeBytes(src);
+   }
+
+   public void writeBytes(final ByteBuffer src)
+   {
+      buffer.writeBytes(src);
+   }
+
+   public void writeBytes(final HornetQBuffer src, final int srcIndex, final int length)
+   {
+      buffer.writeBytes(src.channelBuffer(), srcIndex, length);
+   }
+
+   public void writeBytes(final HornetQBuffer src, final int length)
+   {
+      buffer.writeBytes(src.channelBuffer(), length);
+   }
+
+   public void writeChar(final char chr)
+   {
+      buffer.writeShort((short)chr);
+   }
+
+   public void writeDouble(final double value)
+   {
+      buffer.writeLong(Double.doubleToLongBits(value));
+   }
+
+   public void writeFloat(final float value)
+   {
+      buffer.writeInt(Float.floatToIntBits(value));
+   }
+
+   public void writeInt(final int value)
+   {
+      buffer.writeInt(value);
+   }
+
+   public void writeLong(final long value)
+   {
+      buffer.writeLong(value);
+   }
+
+   public int writerIndex()
+   {
+      return buffer.writerIndex();
+   }
+
+   public void writerIndex(final int writerIndex)
+   {
+      buffer.writerIndex(writerIndex);
+   }
+
+   public void writeShort(final short value)
+   {
+      buffer.writeShort(value);
+   }
+
+}

Copied: trunk/hornetq-commons/src/main/java/org/hornetq/core/server/HornetQComponent.java (from rev 10738, trunk/hornetq-core/src/main/java/org/hornetq/core/server/HornetQComponent.java)
===================================================================
--- trunk/hornetq-commons/src/main/java/org/hornetq/core/server/HornetQComponent.java	                        (rev 0)
+++ trunk/hornetq-commons/src/main/java/org/hornetq/core/server/HornetQComponent.java	2011-05-26 12:50:50 UTC (rev 10739)
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.core.server;
+
+/**
+ * A HornetQComponent
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 2796 $</tt>
+ *
+ * $Id: HornetQComponent.java 2796 2007-06-25 22:24:41Z timfox $
+ *
+ */
+public interface HornetQComponent
+{
+   void start() throws Exception;
+
+   void stop() throws Exception;
+
+   boolean isStarted();
+}

Copied: trunk/hornetq-commons/src/main/java/org/hornetq/utils/DataConstants.java (from rev 10738, trunk/hornetq-core/src/main/java/org/hornetq/utils/DataConstants.java)
===================================================================
--- trunk/hornetq-commons/src/main/java/org/hornetq/utils/DataConstants.java	                        (rev 0)
+++ trunk/hornetq-commons/src/main/java/org/hornetq/utils/DataConstants.java	2011-05-26 12:50:50 UTC (rev 10739)
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.utils;
+
+/**
+ * 
+ * A DataConstants
+ * 
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public class DataConstants
+{
+   public static final int SIZE_INT = 4;
+
+   public static final int SIZE_BOOLEAN = 1;
+
+   public static final int SIZE_LONG = 8;
+
+   public static final int SIZE_BYTE = 1;
+
+   public static final int SIZE_SHORT = 2;
+
+   public static final int SIZE_DOUBLE = 8;
+
+   public static final int SIZE_FLOAT = 4;
+
+   public static final int SIZE_CHAR = 2;
+
+   public static final byte TRUE = 1;
+
+   public static final byte FALSE = 0;
+
+   public static final byte NULL = 0;
+
+   public static final byte NOT_NULL = 1;
+
+   public static final byte BOOLEAN = 2;
+
+   public static final byte BYTE = 3;
+
+   public static final byte BYTES = 4;
+
+   public static final byte SHORT = 5;
+
+   public static final byte INT = 6;
+
+   public static final byte LONG = 7;
+
+   public static final byte FLOAT = 8;
+
+   public static final byte DOUBLE = 9;
+
+   public static final byte STRING = 10;
+
+   public static final byte CHAR = 11;
+}

Copied: trunk/hornetq-commons/src/main/java/org/hornetq/utils/UTF8Util.java (from rev 10738, trunk/hornetq-core/src/main/java/org/hornetq/utils/UTF8Util.java)
===================================================================
--- trunk/hornetq-commons/src/main/java/org/hornetq/utils/UTF8Util.java	                        (rev 0)
+++ trunk/hornetq-commons/src/main/java/org/hornetq/utils/UTF8Util.java	2011-05-26 12:50:50 UTC (rev 10739)
@@ -0,0 +1,272 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.utils;
+
+import java.lang.ref.SoftReference;
+
+import org.hornetq.api.core.HornetQBuffer;
+import org.hornetq.core.logging.Logger;
+
+/**
+ * 
+ * A UTF8Util
+ * 
+ * This class will write UTFs directly to the ByteOutput (through the MessageBuffer interface)
+ *
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ * 
+ * Created Feb 20, 2009 1:37:18 PM
+ *
+ *
+ */
+public class UTF8Util
+{
+   static boolean optimizeStrings = true;
+
+   private static final Logger log = Logger.getLogger(UTF8Util.class);
+
+   private static final boolean isTrace = UTF8Util.log.isTraceEnabled();
+
+   private static ThreadLocal<SoftReference<StringUtilBuffer>> currenBuffer = new ThreadLocal<SoftReference<StringUtilBuffer>>();
+
+   public static void saveUTF(final HornetQBuffer out, final String str)
+   {
+      StringUtilBuffer buffer = UTF8Util.getThreadLocalBuffer();
+
+      if (str.length() > 0xffff)
+      {
+         throw new IllegalArgumentException("the specified string is too long (" + str.length() + ")");
+      }
+
+      final int len = UTF8Util.calculateUTFSize(str, buffer);
+
+      if (len > 0xffff)
+      {
+         throw new IllegalArgumentException("the encoded string is too long (" + len + ")");
+      }
+
+      out.writeShort((short)len);
+
+      if (len > buffer.byteBuffer.length)
+      {
+         buffer.resizeByteBuffer(len);
+      }
+
+      if (len == (long)str.length())
+      {
+         for (int byteLocation = 0; byteLocation < len; byteLocation++)
+         {
+            buffer.byteBuffer[byteLocation] = (byte)buffer.charBuffer[byteLocation];
+         }
+         out.writeBytes(buffer.byteBuffer, 0, len);
+      }
+      else
+      {
+         if (UTF8Util.isTrace)
+         {
+            // This message is too verbose for debug, that's why we are using trace here
+            UTF8Util.log.trace("Saving string with utfSize=" + len + " stringSize=" + str.length());
+         }
+
+         int stringLength = str.length();
+
+         int charCount = 0;
+
+         for (int i = 0; i < stringLength; i++)
+         {
+            char charAtPos = buffer.charBuffer[i];
+            if (charAtPos >= 1 && charAtPos < 0x7f)
+            {
+               buffer.byteBuffer[charCount++] = (byte)charAtPos;
+            }
+            else if (charAtPos >= 0x800)
+            {
+               buffer.byteBuffer[charCount++] = (byte)(0xE0 | charAtPos >> 12 & 0x0F);
+               buffer.byteBuffer[charCount++] = (byte)(0x80 | charAtPos >> 6 & 0x3F);
+               buffer.byteBuffer[charCount++] = (byte)(0x80 | charAtPos >> 0 & 0x3F);
+            }
+            else
+            {
+               buffer.byteBuffer[charCount++] = (byte)(0xC0 | charAtPos >> 6 & 0x1F);
+               buffer.byteBuffer[charCount++] = (byte)(0x80 | charAtPos >> 0 & 0x3F);
+
+            }
+         }
+         out.writeBytes(buffer.byteBuffer, 0, len);
+      }
+   }
+
+   public static String readUTF(final HornetQBuffer input)
+   {
+      StringUtilBuffer buffer = UTF8Util.getThreadLocalBuffer();
+
+      final int size = input.readUnsignedShort();
+
+      if (size > buffer.byteBuffer.length)
+      {
+         buffer.resizeByteBuffer(size);
+      }
+
+      if (size > buffer.charBuffer.length)
+      {
+         buffer.resizeCharBuffer(size);
+      }
+
+      if (UTF8Util.isTrace)
+      {
+         // This message is too verbose for debug, that's why we are using trace here
+         UTF8Util.log.trace("Reading string with utfSize=" + size);
+      }
+
+      int count = 0;
+      int byte1, byte2, byte3;
+      int charCount = 0;
+
+      input.readBytes(buffer.byteBuffer, 0, size);
+
+      while (count < size)
+      {
+         byte1 = buffer.byteBuffer[count++];
+
+         if (byte1 > 0 && byte1 <= 0x7F)
+         {
+            buffer.charBuffer[charCount++] = (char)byte1;
+         }
+         else
+         {
+            int c = byte1 & 0xff;
+            switch (c >> 4)
+            {
+               case 0xc:
+               case 0xd:
+                  byte2 = buffer.byteBuffer[count++];
+                  buffer.charBuffer[charCount++] = (char)((c & 0x1F) << 6 | byte2 & 0x3F);
+                  break;
+               case 0xe:
+                  byte2 = buffer.byteBuffer[count++];
+                  byte3 = buffer.byteBuffer[count++];
+                  buffer.charBuffer[charCount++] = (char)((c & 0x0F) << 12 | (byte2 & 0x3F) << 6 | (byte3 & 0x3F) << 0);
+                  break;
+            }
+         }
+      }
+
+      return new String(buffer.charBuffer, 0, charCount);
+
+   }
+
+   private static StringUtilBuffer getThreadLocalBuffer()
+   {
+      SoftReference<StringUtilBuffer> softReference = UTF8Util.currenBuffer.get();
+      StringUtilBuffer value;
+      if (softReference == null)
+      {
+         value = new StringUtilBuffer();
+         softReference = new SoftReference<StringUtilBuffer>(value);
+         UTF8Util.currenBuffer.set(softReference);
+      }
+      else
+      {
+         value = softReference.get();
+      }
+
+      if (value == null)
+      {
+         value = new StringUtilBuffer();
+         softReference = new SoftReference<StringUtilBuffer>(value);
+         UTF8Util.currenBuffer.set(softReference);
+      }
+
+      return value;
+   }
+
+   public static void clearBuffer()
+   {
+      SoftReference<StringUtilBuffer> ref = UTF8Util.currenBuffer.get();
+      if (ref.get() != null)
+      {
+         ref.clear();
+      }
+   }
+
+   public static int calculateUTFSize(final String str, final StringUtilBuffer stringBuffer)
+   {
+      int calculatedLen = 0;
+
+      int stringLength = str.length();
+
+      if (stringLength > stringBuffer.charBuffer.length)
+      {
+         stringBuffer.resizeCharBuffer(stringLength);
+      }
+
+      str.getChars(0, stringLength, stringBuffer.charBuffer, 0);
+
+      for (int i = 0; i < stringLength; i++)
+      {
+         char c = stringBuffer.charBuffer[i];
+
+         if (c >= 1 && c < 0x7f)
+         {
+            calculatedLen++;
+         }
+         else if (c >= 0x800)
+         {
+            calculatedLen += 3;
+         }
+         else
+         {
+            calculatedLen += 2;
+         }
+      }
+      return calculatedLen;
+   }
+
+   private static class StringUtilBuffer
+   {
+
+      public char charBuffer[];
+
+      public byte byteBuffer[];
+
+      public void resizeCharBuffer(final int newSize)
+      {
+         if (newSize > charBuffer.length)
+         {
+            charBuffer = new char[newSize];
+         }
+      }
+
+      public void resizeByteBuffer(final int newSize)
+      {
+         if (newSize > byteBuffer.length)
+         {
+            byteBuffer = new byte[newSize];
+         }
+      }
+
+      public StringUtilBuffer()
+      {
+         this(1024, 1024);
+      }
+
+      public StringUtilBuffer(final int sizeChar, final int sizeByte)
+      {
+         charBuffer = new char[sizeChar];
+         byteBuffer = new byte[sizeByte];
+      }
+
+   }
+
+}

Deleted: trunk/hornetq-core/src/main/java/org/hornetq/api/core/HornetQBuffer.java
===================================================================
--- trunk/hornetq-core/src/main/java/org/hornetq/api/core/HornetQBuffer.java	2011-05-26 12:31:10 UTC (rev 10738)
+++ trunk/hornetq-core/src/main/java/org/hornetq/api/core/HornetQBuffer.java	2011-05-26 12:50:50 UTC (rev 10739)
@@ -1,1086 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *    http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.  See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package org.hornetq.api.core;
-
-import java.nio.ByteBuffer;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-
-/**
- *
- * A HornetQBuffer wraps a Netty's ChannelBuffer and is used throughout HornetQ code base.
- * 
- * Much of it derived from Netty ChannelBuffer by Trustin Lee
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * 
- * @see HornetQBuffers
- *
- */
-public interface HornetQBuffer
-{
-   /**
-    * Returns the underlying Netty's ChannelBuffer
-    * 
-    * @return the underlying Netty's ChannelBuffer
-    */
-   ChannelBuffer channelBuffer();
-
-   /**
-    * Returns the number of bytes this buffer can contain.
-    */
-   int capacity();
-
-   /**
-    * Returns the {@code readerIndex} of this buffer.
-    */
-   int readerIndex();
-
-   /**
-    * Sets the {@code readerIndex} of this buffer.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if the specified {@code readerIndex} is
-    *            less than {@code 0} or
-    *            greater than {@code this.writerIndex}
-    */
-   void readerIndex(int readerIndex);
-
-   /**
-    * Returns the {@code writerIndex} of this buffer.
-    */
-   int writerIndex();
-
-   /**
-    * Sets the {@code writerIndex} of this buffer.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if the specified {@code writerIndex} is
-    *            less than {@code this.readerIndex} or
-    *            greater than {@code this.capacity}
-    */
-   void writerIndex(int writerIndex);
-
-   /**
-    * Sets the {@code readerIndex} and {@code writerIndex} of this buffer
-    * in one shot.  This method is useful when you have to worry about the
-    * invocation order of {@link #readerIndex(int)} and {@link #writerIndex(int)}
-    * methods.  For example, the following code will fail:
-    *
-    * <pre>
-    * // Create a buffer whose readerIndex, writerIndex and capacity are
-    * // 0, 0 and 8 respectively.
-    * ChannelBuffer buf = ChannelBuffers.buffer(8);
-    *
-    * // IndexOutOfBoundsException is thrown because the specified
-    * // readerIndex (2) cannot be greater than the current writerIndex (0).
-    * buf.readerIndex(2);
-    * buf.writerIndex(4);
-    * </pre>
-    *
-    * The following code will also fail:
-    *
-    * <pre>
-    * // Create a buffer whose readerIndex, writerIndex and capacity are
-    * // 0, 8 and 8 respectively.
-    * ChannelBuffer buf = ChannelBuffers.wrappedBuffer(new byte[8]);
-    *
-    * // readerIndex becomes 8.
-    * buf.readLong();
-    *
-    * // IndexOutOfBoundsException is thrown because the specified
-    * // writerIndex (4) cannot be less than the current readerIndex (8).
-    * buf.writerIndex(4);
-    * buf.readerIndex(2);
-    * </pre>
-    *
-    * By contrast, {@link #setIndex(int, int)} guarantees that it never
-    * throws an {@link IndexOutOfBoundsException} as long as the specified
-    * indexes meet basic constraints, regardless what the current index
-    * values of the buffer are:
-    *
-    * <pre>
-    * // No matter what the current state of the buffer is, the following
-    * // call always succeeds as long as the capacity of the buffer is not
-    * // less than 4.
-    * buf.setIndex(2, 4);
-    * </pre>
-    *
-    * @throws IndexOutOfBoundsException
-    *         if the specified {@code readerIndex} is less than 0,
-    *         if the specified {@code writerIndex} is less than the specified
-    *         {@code readerIndex} or if the specified {@code writerIndex} is
-    *         greater than {@code this.capacity}
-    */
-   void setIndex(int readerIndex, int writerIndex);
-
-   /**
-    * Returns the number of readable bytes which is equal to
-    * {@code (this.writerIndex - this.readerIndex)}.
-    */
-   int readableBytes();
-
-   /**
-    * Returns the number of writable bytes which is equal to
-    * {@code (this.capacity - this.writerIndex)}.
-    */
-   int writableBytes();
-
-   /**
-    * Returns {@code true}
-    * if and only if {@code (this.writerIndex - this.readerIndex)} is greater
-    * than {@code 0}.
-    */
-   boolean readable();
-
-   /**
-    * Returns {@code true}
-    * if and only if {@code (this.capacity - this.writerIndex)} is greater
-    * than {@code 0}.
-    */
-   boolean writable();
-
-   /**
-    * Sets the {@code readerIndex} and {@code writerIndex} of this buffer to
-    * {@code 0}.
-    * This method is identical to {@link #setIndex(int, int) setIndex(0, 0)}.
-    * <p>
-    * Please note that the behavior of this method is different
-    * from that of NIO buffer, which sets the {@code limit} to
-    * the {@code capacity} of the buffer.
-    */
-   void clear();
-
-   /**
-    * Marks the current {@code readerIndex} in this buffer.  You can
-    * reposition the current {@code readerIndex} to the marked
-    * {@code readerIndex} by calling {@link #resetReaderIndex()}.
-    * The initial value of the marked {@code readerIndex} is {@code 0}.
-    */
-   void markReaderIndex();
-
-   /**
-    * Repositions the current {@code readerIndex} to the marked
-    * {@code readerIndex} in this buffer.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if the current {@code writerIndex} is less than the marked
-    *         {@code readerIndex}
-    */
-   void resetReaderIndex();
-
-   /**
-    * Marks the current {@code writerIndex} in this buffer.  You can
-    * reposition the current {@code writerIndex} to the marked
-    * {@code writerIndex} by calling {@link #resetWriterIndex()}.
-    * The initial value of the marked {@code writerIndex} is {@code 0}.
-    */
-   void markWriterIndex();
-
-   /**
-    * Repositions the current {@code writerIndex} to the marked
-    * {@code writerIndex} in this buffer.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if the current {@code readerIndex} is greater than the marked
-    *         {@code writerIndex}
-    */
-   void resetWriterIndex();
-
-   /**
-    * Discards the bytes between the 0th index and {@code readerIndex}.
-    * It moves the bytes between {@code readerIndex} and {@code writerIndex}
-    * to the 0th index, and sets {@code readerIndex} and {@code writerIndex}
-    * to {@code 0} and {@code oldWriterIndex - oldReaderIndex} respectively.
-    * <p>
-    * Please refer to the class documentation for more detailed explanation.
-    */
-   void discardReadBytes();
-
-   /**
-    * Gets a byte at the specified absolute {@code index} in this buffer.
-    * This method does not modify {@code readerIndex} or {@code writerIndex} of
-    * this buffer.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if the specified {@code index} is less than {@code 0} or
-    *         {@code index + 1} is greater than {@code this.capacity}
-    */
-   byte  getByte(int index);
-
-   /**
-    * Gets an unsigned byte at the specified absolute {@code index} in this
-    * buffer.  This method does not modify {@code readerIndex} or
-    * {@code writerIndex} of this buffer.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if the specified {@code index} is less than {@code 0} or
-    *         {@code index + 1} is greater than {@code this.capacity}
-    */
-   short getUnsignedByte(int index);
-
-   /**
-    * Gets a 16-bit short integer at the specified absolute {@code index} in
-    * this buffer.  This method does not modify {@code readerIndex} or
-    * {@code writerIndex} of this buffer.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if the specified {@code index} is less than {@code 0} or
-    *         {@code index + 2} is greater than {@code this.capacity}
-    */
-   short getShort(int index);
-
-   /**
-    * Gets an unsigned 16-bit short integer at the specified absolute
-    * {@code index} in this buffer.  This method does not modify
-    * {@code readerIndex} or {@code writerIndex} of this buffer.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if the specified {@code index} is less than {@code 0} or
-    *         {@code index + 2} is greater than {@code this.capacity}
-    */
-   int getUnsignedShort(int index);
-
-   /**
-    * Gets a 32-bit integer at the specified absolute {@code index} in
-    * this buffer.  This method does not modify {@code readerIndex} or
-    * {@code writerIndex} of this buffer.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if the specified {@code index} is less than {@code 0} or
-    *         {@code index + 4} is greater than {@code this.capacity}
-    */
-   int   getInt(int index);
-
-   /**
-    * Gets an unsigned 32-bit integer at the specified absolute {@code index}
-    * in this buffer.  This method does not modify {@code readerIndex} or
-    * {@code writerIndex} of this buffer.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if the specified {@code index} is less than {@code 0} or
-    *         {@code index + 4} is greater than {@code this.capacity}
-    */
-   long  getUnsignedInt(int index);
-
-   /**
-    * Gets a 64-bit long integer at the specified absolute {@code index} in
-    * this buffer.  This method does not modify {@code readerIndex} or
-    * {@code writerIndex} of this buffer.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if the specified {@code index} is less than {@code 0} or
-    *         {@code index + 8} is greater than {@code this.capacity}
-    */
-   long  getLong(int index);
-
-   /**
-    * Transfers this buffer's data to the specified destination starting at
-    * the specified absolute {@code index} until the destination becomes
-    * non-writable.  This method is basically same with
-    * {@link #getBytes(int, HornetQBuffer, int, int)}, except that this
-    * method increases the {@code writerIndex} of the destination by the
-    * number of the transferred bytes while
-    * {@link #getBytes(int, HornetQBuffer, int, int)} does not.
-    * This method does not modify {@code readerIndex} or {@code writerIndex} of
-    * the source buffer (i.e. {@code this}).
-    *
-    * @throws IndexOutOfBoundsException
-    *         if the specified {@code index} is less than {@code 0} or
-    *         if {@code index + dst.writableBytes} is greater than
-    *            {@code this.capacity}
-    */
-   void getBytes(int index, HornetQBuffer dst);
-
-   /**
-    * Transfers this buffer's data to the specified destination starting at
-    * the specified absolute {@code index}.  This method is basically same
-    * with {@link #getBytes(int, HornetQBuffer, int, int)}, except that this
-    * method increases the {@code writerIndex} of the destination by the
-    * number of the transferred bytes while
-    * {@link #getBytes(int, HornetQBuffer, int, int)} does not.
-    * This method does not modify {@code readerIndex} or {@code writerIndex} of
-    * the source buffer (i.e. {@code this}).
-    *
-    * @param length the number of bytes to transfer
-    *
-    * @throws IndexOutOfBoundsException
-    *         if the specified {@code index} is less than {@code 0},
-    *         if {@code index + length} is greater than
-    *            {@code this.capacity}, or
-    *         if {@code length} is greater than {@code dst.writableBytes}
-    */
-   void getBytes(int index, HornetQBuffer dst, int length);
-
-   /**
-    * Transfers this buffer's data to the specified destination starting at
-    * the specified absolute {@code index}.
-    * This method does not modify {@code readerIndex} or {@code writerIndex}
-    * of both the source (i.e. {@code this}) and the destination.
-    *
-    * @param dstIndex the first index of the destination
-    * @param length   the number of bytes to transfer
-    *
-    * @throws IndexOutOfBoundsException
-    *         if the specified {@code index} is less than {@code 0},
-    *         if the specified {@code dstIndex} is less than {@code 0},
-    *         if {@code index + length} is greater than
-    *            {@code this.capacity}, or
-    *         if {@code dstIndex + length} is greater than
-    *            {@code dst.capacity}
-    */
-   void getBytes(int index, HornetQBuffer dst, int dstIndex, int length);
-
-   /**
-    * Transfers this buffer's data to the specified destination starting at
-    * the specified absolute {@code index}.
-    * This method does not modify {@code readerIndex} or {@code writerIndex} of
-    * this buffer
-    *
-    * @throws IndexOutOfBoundsException
-    *         if the specified {@code index} is less than {@code 0} or
-    *         if {@code index + dst.length} is greater than
-    *            {@code this.capacity}
-    */
-   void getBytes(int index, byte[] dst);
-
-   /**
-    * Transfers this buffer's data to the specified destination starting at
-    * the specified absolute {@code index}.
-    * This method does not modify {@code readerIndex} or {@code writerIndex}
-    * of this buffer.
-    *
-    * @param dstIndex the first index of the destination
-    * @param length   the number of bytes to transfer
-    *
-    * @throws IndexOutOfBoundsException
-    *         if the specified {@code index} is less than {@code 0},
-    *         if the specified {@code dstIndex} is less than {@code 0},
-    *         if {@code index + length} is greater than
-    *            {@code this.capacity}, or
-    *         if {@code dstIndex + length} is greater than
-    *            {@code dst.length}
-    */
-   void getBytes(int index, byte[] dst, int dstIndex, int length);
-
-   /**
-    * Transfers this buffer's data to the specified destination starting at
-    * the specified absolute {@code index} until the destination's position
-    * reaches its limit.
-    * This method does not modify {@code readerIndex} or {@code writerIndex} of
-    * this buffer while the destination's {@code position} will be increased.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if the specified {@code index} is less than {@code 0} or
-    *         if {@code index + dst.remaining()} is greater than
-    *            {@code this.capacity}
-    */
-   void getBytes(int index, ByteBuffer dst);
-
-   /**
-    * Gets a char at the specified absolute {@code index} in
-    * this buffer.  This method does not modify {@code readerIndex} or
-    * {@code writerIndex} of this buffer.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if the specified {@code index} is less than {@code 0} or
-    *         {@code index + 2} is greater than {@code this.capacity}
-    */
-   char getChar(int index);
-
-   /**
-    * Gets a float at the specified absolute {@code index} in
-    * this buffer.  This method does not modify {@code readerIndex} or
-    * {@code writerIndex} of this buffer.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if the specified {@code index} is less than {@code 0} or
-    *         {@code index + 4} is greater than {@code this.capacity}
-    */  
-   float getFloat(int index);
-
-   /**
-    * Gets a double at the specified absolute {@code index} in
-    * this buffer.  This method does not modify {@code readerIndex} or
-    * {@code writerIndex} of this buffer.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if the specified {@code index} is less than {@code 0} or
-    *         {@code index + 8} is greater than {@code this.capacity}
-    */    
-   double getDouble(int index);
-
-   /**
-    * Sets the specified byte at the specified absolute {@code index} in this
-    * buffer.
-    * This method does not modify {@code readerIndex} or {@code writerIndex} of
-    * this buffer.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if the specified {@code index} is less than {@code 0} or
-    *         {@code index + 1} is greater than {@code this.capacity}
-    */
-   void setByte(int index, byte value);
-
-   /**
-    * Sets the specified 16-bit short integer at the specified absolute
-    * {@code index} in this buffer.
-    * This method does not modify {@code readerIndex} or {@code writerIndex} of
-    * this buffer.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if the specified {@code index} is less than {@code 0} or
-    *         {@code index + 2} is greater than {@code this.capacity}
-    */
-   void setShort(int index, short value);
-
-   /**
-    * Sets the specified 32-bit integer at the specified absolute
-    * {@code index} in this buffer.
-    * This method does not modify {@code readerIndex} or {@code writerIndex} of
-    * this buffer.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if the specified {@code index} is less than {@code 0} or
-    *         {@code index + 4} is greater than {@code this.capacity}
-    */
-   void setInt(int index, int value);
-
-   /**
-    * Sets the specified 64-bit long integer at the specified absolute
-    * {@code index} in this buffer.
-    * This method does not modify {@code readerIndex} or {@code writerIndex} of
-    * this buffer.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if the specified {@code index} is less than {@code 0} or
-    *         {@code index + 8} is greater than {@code this.capacity}
-    */
-   void setLong(int index, long value);
-
-   /**
-    * Transfers the specified source buffer's data to this buffer starting at
-    * the specified absolute {@code index} until the destination becomes
-    * unreadable.  This method is basically same with
-    * {@link #setBytes(int, HornetQBuffer, int, int)}, except that this
-    * method increases the {@code readerIndex} of the source buffer by
-    * the number of the transferred bytes while
-    * {@link #getBytes(int, HornetQBuffer, int, int)} does not.
-    * This method does not modify {@code readerIndex} or {@code writerIndex} of
-    * the source buffer (i.e. {@code this}).
-    *
-    * @throws IndexOutOfBoundsException
-    *         if the specified {@code index} is less than {@code 0} or
-    *         if {@code index + src.readableBytes} is greater than
-    *            {@code this.capacity}
-    */
-   void setBytes(int index, HornetQBuffer src);
-
-   /**
-    * Transfers the specified source buffer's data to this buffer starting at
-    * the specified absolute {@code index}.  This method is basically same
-    * with {@link #setBytes(int, HornetQBuffer, int, int)}, except that this
-    * method increases the {@code readerIndex} of the source buffer by
-    * the number of the transferred bytes while
-    * {@link #getBytes(int, HornetQBuffer, int, int)} does not.
-    * This method does not modify {@code readerIndex} or {@code writerIndex} of
-    * the source buffer (i.e. {@code this}).
-    *
-    * @param length the number of bytes to transfer
-    *
-    * @throws IndexOutOfBoundsException
-    *         if the specified {@code index} is less than {@code 0},
-    *         if {@code index + length} is greater than
-    *            {@code this.capacity}, or
-    *         if {@code length} is greater than {@code src.readableBytes}
-    */
-   void setBytes(int index, HornetQBuffer src, int length);
-
-   /**
-    * Transfers the specified source buffer's data to this buffer starting at
-    * the specified absolute {@code index}.
-    * This method does not modify {@code readerIndex} or {@code writerIndex}
-    * of both the source (i.e. {@code this}) and the destination.
-    *
-    * @param srcIndex the first index of the source
-    * @param length   the number of bytes to transfer
-    *
-    * @throws IndexOutOfBoundsException
-    *         if the specified {@code index} is less than {@code 0},
-    *         if the specified {@code srcIndex} is less than {@code 0},
-    *         if {@code index + length} is greater than
-    *            {@code this.capacity}, or
-    *         if {@code srcIndex + length} is greater than
-    *            {@code src.capacity}
-    */
-   void setBytes(int index, HornetQBuffer src, int srcIndex, int length);
-
-   /**
-    * Transfers the specified source array's data to this buffer starting at
-    * the specified absolute {@code index}.
-    * This method does not modify {@code readerIndex} or {@code writerIndex} of
-    * this buffer.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if the specified {@code index} is less than {@code 0} or
-    *         if {@code index + src.length} is greater than
-    *            {@code this.capacity}
-    */
-   void setBytes(int index, byte[] src);
-
-   /**
-    * Transfers the specified source array's data to this buffer starting at
-    * the specified absolute {@code index}.
-    * This method does not modify {@code readerIndex} or {@code writerIndex} of
-    * this buffer.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if the specified {@code index} is less than {@code 0},
-    *         if the specified {@code srcIndex} is less than {@code 0},
-    *         if {@code index + length} is greater than
-    *            {@code this.capacity}, or
-    *         if {@code srcIndex + length} is greater than {@code src.length}
-    */
-   void setBytes(int index, byte[] src, int srcIndex, int length);
-
-   /**
-    * Transfers the specified source buffer's data to this buffer starting at
-    * the specified absolute {@code index} until the source buffer's position
-    * reaches its limit.
-    * This method does not modify {@code readerIndex} or {@code writerIndex} of
-    * this buffer.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if the specified {@code index} is less than {@code 0} or
-    *         if {@code index + src.remaining()} is greater than
-    *            {@code this.capacity}
-    */
-   void setBytes(int index, ByteBuffer src);
-
-   /**
-    * Sets the specified char at the specified absolute
-    * {@code index} in this buffer.
-    * This method does not modify {@code readerIndex} or {@code writerIndex} of
-    * this buffer.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if the specified {@code index} is less than {@code 0} or
-    *         {@code index + 2} is greater than {@code this.capacity}
-    */
-   void setChar(int index, char value);
-
-   /**
-    * Sets the specified float at the specified absolute
-    * {@code index} in this buffer.
-    * This method does not modify {@code readerIndex} or {@code writerIndex} of
-    * this buffer.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if the specified {@code index} is less than {@code 0} or
-    *         {@code index + 4} is greater than {@code this.capacity}
-    */
-   void setFloat(int index, float value);
-
-   /**
-    * Sets the specified double at the specified absolute
-    * {@code index} in this buffer.
-    * This method does not modify {@code readerIndex} or {@code writerIndex} of
-    * this buffer.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if the specified {@code index} is less than {@code 0} or
-    *         {@code index + 8} is greater than {@code this.capacity}
-    */
-   void setDouble(int index, double value);
-
-   /**
-    * Gets a byte at the current {@code readerIndex} and increases
-    * the {@code readerIndex} by {@code 1} in this buffer.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if {@code this.readableBytes} is less than {@code 1}
-    */
-   byte readByte();
-
-   /**
-    * Gets an unsigned byte at the current {@code readerIndex} and increases
-    * the {@code readerIndex} by {@code 1} in this buffer.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if {@code this.readableBytes} is less than {@code 1}
-    */
-   short readUnsignedByte();
-
-   /**
-    * Gets a 16-bit short integer at the current {@code readerIndex}
-    * and increases the {@code readerIndex} by {@code 2} in this buffer.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if {@code this.readableBytes} is less than {@code 2}
-    */
-   short readShort();
-
-   /**
-    * Gets an unsigned 16-bit short integer at the current {@code readerIndex}
-    * and increases the {@code readerIndex} by {@code 2} in this buffer.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if {@code this.readableBytes} is less than {@code 2}
-    */
-   int   readUnsignedShort();
-
-   /**
-    * Gets a 32-bit integer at the current {@code readerIndex}
-    * and increases the {@code readerIndex} by {@code 4} in this buffer.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if {@code this.readableBytes} is less than {@code 4}
-    */
-   int   readInt();
-
-   /**
-    * Gets an unsigned 32-bit integer at the current {@code readerIndex}
-    * and increases the {@code readerIndex} by {@code 4} in this buffer.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if {@code this.readableBytes} is less than {@code 4}
-    */
-   long  readUnsignedInt();
-
-   /**
-    * Gets a 64-bit integer at the current {@code readerIndex}
-    * and increases the {@code readerIndex} by {@code 8} in this buffer.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if {@code this.readableBytes} is less than {@code 8}
-    */
-   long  readLong();
-
-   /**
-    * Gets a char at the current {@code readerIndex}
-    * and increases the {@code readerIndex} by {@code 2} in this buffer.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if {@code this.readableBytes} is less than {@code 2}
-    */
-   char readChar();
-
-   /**
-    * Gets a float at the current {@code readerIndex}
-    * and increases the {@code readerIndex} by {@code 4} in this buffer.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if {@code this.readableBytes} is less than {@code 4}
-    */
-   float readFloat();
-
-   /**
-    * Gets a double at the current {@code readerIndex}
-    * and increases the {@code readerIndex} by {@code 8} in this buffer.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if {@code this.readableBytes} is less than {@code 8}
-    */
-   double readDouble();
-
-   /**
-    * Gets a boolean at the current {@code readerIndex}
-    * and increases the {@code readerIndex} by {@code 1} in this buffer.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if {@code this.readableBytes} is less than {@code 1}
-    */
-   boolean readBoolean();
-
-   /**
-    * Gets a SimpleString (potentially {@code null}) at the current {@code readerIndex}
-    */
-   SimpleString readNullableSimpleString();
-
-   /**
-    * Gets a String (potentially {@code null}) at the current {@code readerIndex}
-    */
-   String readNullableString();
-
-   /**
-    * Gets a non-null SimpleString at the current {@code readerIndex}
-    */
-   SimpleString readSimpleString();
-
-   /**
-    * Gets a non-null String at the current {@code readerIndex}
-    */
-   String readString();
-
-   /**
-    * Gets a UTF-8 String at the current {@code readerIndex}
-    */
-   String readUTF();
-
-   /**
-    * Transfers this buffer's data to a newly created buffer starting at
-    * the current {@code readerIndex} and increases the {@code readerIndex}
-    * by the number of the transferred bytes (= {@code length}).
-    * The returned buffer's {@code readerIndex} and {@code writerIndex} are
-    * {@code 0} and {@code length} respectively.
-    *
-    * @param length the number of bytes to transfer
-    *
-    * @return the newly created buffer which contains the transferred bytes
-    *
-    * @throws IndexOutOfBoundsException
-    *         if {@code length} is greater than {@code this.readableBytes}
-    */
-   HornetQBuffer readBytes(int length);
-
-   /**
-    * Returns a new slice of this buffer's sub-region starting at the current
-    * {@code readerIndex} and increases the {@code readerIndex} by the size
-    * of the new slice (= {@code length}).
-    *
-    * @param length the size of the new slice
-    *
-    * @return the newly created slice
-    *
-    * @throws IndexOutOfBoundsException
-    *         if {@code length} is greater than {@code this.readableBytes}
-    */
-   HornetQBuffer readSlice(int length);
-
-   /**
-    * Transfers this buffer's data to the specified destination starting at
-    * the current {@code readerIndex} until the destination becomes
-    * non-writable, and increases the {@code readerIndex} by the number of the
-    * transferred bytes.  This method is basically same with
-    * {@link #readBytes(HornetQBuffer, int, int)}, except that this method
-    * increases the {@code writerIndex} of the destination by the number of
-    * the transferred bytes while {@link #readBytes(HornetQBuffer, int, int)}
-    * does not.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if {@code dst.writableBytes} is greater than
-    *            {@code this.readableBytes}
-    */
-   void readBytes(HornetQBuffer dst);
-
-   /**
-    * Transfers this buffer's data to the specified destination starting at
-    * the current {@code readerIndex} and increases the {@code readerIndex}
-    * by the number of the transferred bytes (= {@code length}).  This method
-    * is basically same with {@link #readBytes(HornetQBuffer, int, int)},
-    * except that this method increases the {@code writerIndex} of the
-    * destination by the number of the transferred bytes (= {@code length})
-    * while {@link #readBytes(HornetQBuffer, int, int)} does not.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if {@code length} is greater than {@code this.readableBytes} or
-    *         if {@code length} is greater than {@code dst.writableBytes}
-    */
-   void readBytes(HornetQBuffer dst, int length);
-
-   /**
-    * Transfers this buffer's data to the specified destination starting at
-    * the current {@code readerIndex} and increases the {@code readerIndex}
-    * by the number of the transferred bytes (= {@code length}).
-    *
-    * @param dstIndex the first index of the destination
-    * @param length   the number of bytes to transfer
-    *
-    * @throws IndexOutOfBoundsException
-    *         if the specified {@code dstIndex} is less than {@code 0},
-    *         if {@code length} is greater than {@code this.readableBytes}, or
-    *         if {@code dstIndex + length} is greater than
-    *            {@code dst.capacity}
-    */
-   void readBytes(HornetQBuffer dst, int dstIndex, int length);
-
-   /**
-    * Transfers this buffer's data to the specified destination starting at
-    * the current {@code readerIndex} and increases the {@code readerIndex}
-    * by the number of the transferred bytes (= {@code dst.length}).
-    *
-    * @throws IndexOutOfBoundsException
-    *         if {@code dst.length} is greater than {@code this.readableBytes}
-    */
-   void readBytes(byte[] dst);
-
-   /**
-    * Transfers this buffer's data to the specified destination starting at
-    * the current {@code readerIndex} and increases the {@code readerIndex}
-    * by the number of the transferred bytes (= {@code length}).
-    *
-    * @param dstIndex the first index of the destination
-    * @param length   the number of bytes to transfer
-    *
-    * @throws IndexOutOfBoundsException
-    *         if the specified {@code dstIndex} is less than {@code 0},
-    *         if {@code length} is greater than {@code this.readableBytes}, or
-    *         if {@code dstIndex + length} is greater than {@code dst.length}
-    */
-   void readBytes(byte[] dst, int dstIndex, int length);
-
-   /**
-    * Transfers this buffer's data to the specified destination starting at
-    * the current {@code readerIndex} until the destination's position
-    * reaches its limit, and increases the {@code readerIndex} by the
-    * number of the transferred bytes.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if {@code dst.remaining()} is greater than
-    *            {@code this.readableBytes}
-    */
-   void readBytes(ByteBuffer dst);
-
-   /**
-    * Increases the current {@code readerIndex} by the specified
-    * {@code length} in this buffer.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if {@code length} is greater than {@code this.readableBytes}
-    */
-   void skipBytes(int length);
-
-   /**
-    * Sets the specified byte at the current {@code writerIndex}
-    * and increases the {@code writerIndex} by {@code 1} in this buffer.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if {@code this.writableBytes} is less than {@code 1}
-    */
-   void writeByte(byte  value);
-
-   /**
-    * Sets the specified 16-bit short integer at the current
-    * {@code writerIndex} and increases the {@code writerIndex} by {@code 2}
-    * in this buffer.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if {@code this.writableBytes} is less than {@code 2}
-    */
-   void writeShort(short value);
-
-   /**
-    * Sets the specified 32-bit integer at the current {@code writerIndex}
-    * and increases the {@code writerIndex} by {@code 4} in this buffer.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if {@code this.writableBytes} is less than {@code 4}
-    */
-   void writeInt(int   value);
-
-   /**
-    * Sets the specified 64-bit long integer at the current
-    * {@code writerIndex} and increases the {@code writerIndex} by {@code 8}
-    * in this buffer.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if {@code this.writableBytes} is less than {@code 8}
-    */
-   void writeLong(long  value);
-
-   /**
-    * Sets the specified char at the current {@code writerIndex}
-    * and increases the {@code writerIndex} by {@code 2} in this buffer.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if {@code this.writableBytes} is less than {@code 2}
-    */
-   void writeChar(char chr);
-
-   /**
-    * Sets the specified float at the current {@code writerIndex}
-    * and increases the {@code writerIndex} by {@code 4} in this buffer.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if {@code this.writableBytes} is less than {@code 4}
-    */
-   void writeFloat(float value);
-
-   /**
-    * Sets the specified double at the current {@code writerIndex}
-    * and increases the {@code writerIndex} by {@code 8} in this buffer.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if {@code this.writableBytes} is less than {@code 8}
-    */
-   void writeDouble(double value);
-
-   /**
-    * Sets the specified boolean at the current {@code writerIndex}
-    */
-   void writeBoolean(boolean val);
-
-   /**
-    * Sets the specified SimpleString (potentially {@code null}) at the current {@code writerIndex}
-    */
-   void writeNullableSimpleString(SimpleString val);
-
-   /**
-    * Sets the specified String (potentially {@code null}) at the current {@code writerIndex}
-    */
-   void writeNullableString(String val);
-
-   /**
-    * Sets the specified non-null SimpleString at the current {@code writerIndex}
-    */
-   void writeSimpleString(SimpleString val);
-
-   /**
-    * Sets the specified non-null String at the current {@code writerIndex}
-    */
-   void writeString(String val);
-
-   /**
-    * Sets the specified UTF-8 String at the current {@code writerIndex}
-    */
-
-   void writeUTF(String utf);
-
-   /**
-    * Transfers the specified source buffer's data to this buffer starting at
-    * the current {@code writerIndex} and increases the {@code writerIndex}
-    * by the number of the transferred bytes (= {@code length}).  This method
-    * is basically same with {@link #writeBytes(HornetQBuffer, int, int)},
-    * except that this method increases the {@code readerIndex} of the source
-    * buffer by the number of the transferred bytes (= {@code length}) while
-    * {@link #writeBytes(HornetQBuffer, int, int)} does not.
-    *
-    * @param length the number of bytes to transfer
-    *
-    * @throws IndexOutOfBoundsException
-    *         if {@code length} is greater than {@code this.writableBytes} or
-    *         if {@code length} is greater then {@code src.readableBytes}
-    */
-   void writeBytes(HornetQBuffer src, int length);
-
-   /**
-    * Transfers the specified source buffer's data to this buffer starting at
-    * the current {@code writerIndex} and increases the {@code writerIndex}
-    * by the number of the transferred bytes (= {@code length}).
-    *
-    * @param srcIndex the first index of the source
-    * @param length   the number of bytes to transfer
-    *
-    * @throws IndexOutOfBoundsException
-    *         if the specified {@code srcIndex} is less than {@code 0},
-    *         if {@code srcIndex + length} is greater than
-    *            {@code src.capacity}, or
-    *         if {@code length} is greater than {@code this.writableBytes}
-    */
-   void writeBytes(HornetQBuffer src, int srcIndex, int length);
-
-   /**
-    * Transfers the specified source array's data to this buffer starting at
-    * the current {@code writerIndex} and increases the {@code writerIndex}
-    * by the number of the transferred bytes (= {@code src.length}).
-    *
-    * @throws IndexOutOfBoundsException
-    *         if {@code src.length} is greater than {@code this.writableBytes}
-    */
-   void writeBytes(byte[] src);
-
-   /**
-    * Transfers the specified source array's data to this buffer starting at
-    * the current {@code writerIndex} and increases the {@code writerIndex}
-    * by the number of the transferred bytes (= {@code length}).
-    *
-    * @param srcIndex the first index of the source
-    * @param length   the number of bytes to transfer
-    *
-    * @throws IndexOutOfBoundsException
-    *         if the specified {@code srcIndex} is less than {@code 0},
-    *         if {@code srcIndex + length} is greater than
-    *            {@code src.length}, or
-    *         if {@code length} is greater than {@code this.writableBytes}
-    */
-   void writeBytes(byte[] src, int srcIndex, int length);
-
-   /**
-    * Transfers the specified source buffer's data to this buffer starting at
-    * the current {@code writerIndex} until the source buffer's position
-    * reaches its limit, and increases the {@code writerIndex} by the
-    * number of the transferred bytes.
-    *
-    * @throws IndexOutOfBoundsException
-    *         if {@code src.remaining()} is greater than
-    *            {@code this.writableBytes}
-    */
-   void writeBytes(ByteBuffer src);
-
-   /**
-    * Returns a copy of this buffer's readable bytes.  Modifying the content
-    * of the returned buffer or this buffer does not affect each other at all.
-    * This method is identical to {@code buf.copy(buf.readerIndex(), buf.readableBytes())}.
-    * This method does not modify {@code readerIndex} or {@code writerIndex} of
-    * this buffer.
-    *
-    */
-   HornetQBuffer copy();
-
-   /**
-    * Returns a copy of this buffer's sub-region.  Modifying the content of
-    * the returned buffer or this buffer does not affect each other at all.
-    * This method does not modify {@code readerIndex} or {@code writerIndex} of
-    * this buffer.
-    */
-   HornetQBuffer copy(int index, int length);
-
-   /**
-    * Returns a slice of this buffer's readable bytes. Modifying the content
-    * of the returned buffer or this buffer affects each other's content
-    * while they maintain separate indexes and marks.  This method is
-    * identical to {@code buf.slice(buf.readerIndex(), buf.readableBytes())}.
-    * This method does not modify {@code readerIndex} or {@code writerIndex} of
-    * this buffer.
-    */
-   HornetQBuffer slice();
-
-   /**
-    * Returns a slice of this buffer's sub-region. Modifying the content of
-    * the returned buffer or this buffer affects each other's content while
-    * they maintain separate indexes and marks.
-    * This method does not modify {@code readerIndex} or {@code writerIndex} of
-    * this buffer.
-    */
-   HornetQBuffer slice(int index, int length);
-
-   /**
-    * Returns a buffer which shares the whole region of this buffer.
-    * Modifying the content of the returned buffer or this buffer affects
-    * each other's content while they maintain separate indexes and marks.
-    * This method is identical to {@code buf.slice(0, buf.capacity())}.
-    * This method does not modify {@code readerIndex} or {@code writerIndex} of
-    * this buffer.
-    */
-   HornetQBuffer duplicate();
-
-   /**
-    * Converts this buffer's readable bytes into a NIO buffer.  The returned
-    * buffer might or might not share the content with this buffer, while
-    * they have separate indexes and marks.  This method is identical to
-    * {@code buf.toByteBuffer(buf.readerIndex(), buf.readableBytes())}.
-    * This method does not modify {@code readerIndex} or {@code writerIndex} of
-    * this buffer.
-    */
-   ByteBuffer toByteBuffer();
-
-   /**
-    * Converts this buffer's sub-region into a NIO buffer.  The returned
-    * buffer might or might not share the content with this buffer, while
-    * they have separate indexes and marks.
-    * This method does not modify {@code readerIndex} or {@code writerIndex} of
-    * this buffer.
-    */
-   ByteBuffer toByteBuffer(int index, int length);
-}

Deleted: trunk/hornetq-core/src/main/java/org/hornetq/api/core/HornetQBuffers.java
===================================================================
--- trunk/hornetq-core/src/main/java/org/hornetq/api/core/HornetQBuffers.java	2011-05-26 12:31:10 UTC (rev 10738)
+++ trunk/hornetq-core/src/main/java/org/hornetq/api/core/HornetQBuffers.java	2011-05-26 12:50:50 UTC (rev 10739)
@@ -1,97 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *    http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.  See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package org.hornetq.api.core;
-
-import java.nio.ByteBuffer;
-
-import org.hornetq.core.buffers.impl.ChannelBufferWrapper;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-
-/**
- * Factory class to create HornetQBuffers
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- */
-public class HornetQBuffers
-{   
-   /**
-    * Creates a <em>self-expanding</em> HornetQBuffer with the given initial size
-    * 
-    * @param size the initial size of the created HornetQBuffer
-    * @return a self-expanding HornetQBuffer starting with the given size
-    */
-   public static HornetQBuffer dynamicBuffer(final int size)
-   {
-      return new ChannelBufferWrapper(ChannelBuffers.dynamicBuffer(size));
-   }
-
-   /**
-    * Creates a <em>self-expanding</em> HornetQBuffer filled with the given byte array
-    * 
-    * @param bytes the created buffer will be initially filled with this byte array
-    * @return a self-expanding HornetQBuffer filled with the given byte array
-    */
-   public static HornetQBuffer dynamicBuffer(final byte[] bytes)
-   {
-      ChannelBuffer buff = ChannelBuffers.dynamicBuffer(bytes.length);
-
-      buff.writeBytes(bytes);
-
-      return new ChannelBufferWrapper(buff);
-   }
-
-   /**
-    * Creates a HornetQBuffer wrapping an underlying NIO ByteBuffer
-    * 
-    * The position on this buffer won't affect the position on the inner buffer
-    * 
-    * @param underlying the underlying NIO ByteBuffer
-    * @return a HornetQBuffer wrapping the underlying NIO ByteBuffer
-    */
-   public static HornetQBuffer wrappedBuffer(final ByteBuffer underlying)
-   {
-      HornetQBuffer buff = new ChannelBufferWrapper(ChannelBuffers.wrappedBuffer(underlying));
-
-      buff.clear();
-
-      return buff;
-   }
-
-   /**
-    * Creates a HornetQBuffer wrapping an underlying byte array
-    *
-    * @param underlying the underlying byte array
-    * @return a HornetQBuffer wrapping the underlying byte array
-    */
-   public static HornetQBuffer wrappedBuffer(final byte[] underlying)
-   {
-      return new ChannelBufferWrapper(ChannelBuffers.wrappedBuffer(underlying));
-   }
-
-   /**
-    * Creates a <em>fixed</em> HornetQBuffer of the given size
-    * 
-    * @param size the size of the created HornetQBuffer
-    * @return a fixed HornetQBuffer with the given size
-    */
-   public static HornetQBuffer fixedBuffer(final int size)
-   {
-      return new ChannelBufferWrapper(ChannelBuffers.buffer(size));
-   }
-   
-   private HornetQBuffers()
-   {
-   }
-}

Deleted: trunk/hornetq-core/src/main/java/org/hornetq/api/core/HornetQException.java
===================================================================
--- trunk/hornetq-core/src/main/java/org/hornetq/api/core/HornetQException.java	2011-05-26 12:31:10 UTC (rev 10738)
+++ trunk/hornetq-core/src/main/java/org/hornetq/api/core/HornetQException.java	2011-05-26 12:50:50 UTC (rev 10739)
@@ -1,226 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *    http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.  See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package org.hornetq.api.core;
-
-/**
- * 
- * HornetQException is the root exception for HornetQ API. 
- * 
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- */
-public class HornetQException extends Exception
-{
-   private static final long serialVersionUID = -4802014152804997417L;
-
-   // Error codes -------------------------------------------------
-
-   /**
-    * Internal error which prevented HornetQ to perform.
-    */
-   public static final int INTERNAL_ERROR = 000;
-
-   /**
-    * A packet of unsupported type was received by HornetQ PacketHandler.
-    */
-   public static final int UNSUPPORTED_PACKET = 001;
-
-   /**
-    * A client is not able to connect to HornetQ server.
-    */
-   public static final int NOT_CONNECTED = 002;
-
-   /**
-    * A client timed out will connecting to HornetQ server.
-    */
-   public static final int CONNECTION_TIMEDOUT = 003;
-
-   /**
-    * A client was disconnected from HornetQ server when the server has shut down.
-    */
-   public static final int DISCONNECTED = 004;
-
-   /**
-    * A blocking call from a client was unblocked during failover.
-    */
-   public static final int UNBLOCKED = 005;
-
-   /**
-    * Unexpected I/O error occured on the server.
-    */
-   public static final int IO_ERROR = 006;
-
-   /**
-    * An operation failed because a queue does not exist on the server.
-    */
-   public static final int QUEUE_DOES_NOT_EXIST = 100;
-
-   /**
-    * An operation failed because a queue exists on the server.
-    */
-   public static final int QUEUE_EXISTS = 101;
-
-   /**
-    * A client operation failed because the calling resource
-    * (ClientSession, ClientProducer, etc.) is closed.
-    */
-   public static final int OBJECT_CLOSED = 102;
-
-   /**
-    * An filter expression has not been validated
-    */
-   public static final int INVALID_FILTER_EXPRESSION = 103;
-
-   /**
-    * A HornetQ resource is not in a legal state (e.g. calling 
-    * ClientConsumer.receive() if a MessageHandler is set)
-    */
-   public static final int ILLEGAL_STATE = 104;
-
-   /**
-    * A security problem occured (authentication issues, permission issues,...)
-    */
-   public static final int SECURITY_EXCEPTION = 105;
-
-   /**
-    * An operation failed because an address does not exist on the server.
-    */
-   public static final int ADDRESS_DOES_NOT_EXIST = 106;
-
-   /**
-    * An operation failed because an address exists on the server.
-    */
-   public static final int ADDRESS_EXISTS = 107;
-
-   /**
-    * A incompatibility between HornetQ versions on the client and the server has been detected
-    */
-   public static final int INCOMPATIBLE_CLIENT_SERVER_VERSIONS = 108;
-
-   /**
-    * An operation failed because a session exists on the server.
-    */
-   public static final int SESSION_EXISTS = 109;
-
-   /**
-    * An problem occurred while manipulating the body of a large message.
-    */
-   public static final int LARGE_MESSAGE_ERROR_BODY = 110;
-
-   /**
-    * A transaction was rolled back.
-    */
-   public static final int TRANSACTION_ROLLED_BACK = 111;
-
-   /**
-    * The creation of a session was rejected by the server (e.g. if the
-    * server is starting and has not finish to be initialized)
-    */
-   public static final int SESSION_CREATION_REJECTED = 112;
-   
-   /**
-    * A DuplicateID was rejected.
-    */
-   public static final int DUPLICATE_ID_REJECTED = 113;
-
-   
-   // Native Error codes ----------------------------------------------
-
-   /**
-    * A internal error occured in the AIO native code
-    */
-   public static final int NATIVE_ERROR_INTERNAL = 200;
-
-   /**
-    * A buffer is invalid in the AIO native code
-    */
-   public static final int NATIVE_ERROR_INVALID_BUFFER = 201;
-
-   /**
-    * Alignment error in the AIO native code
-    */
-   public static final int NATIVE_ERROR_NOT_ALIGNED = 202;
-
-   /**
-    * AIO has not been properly initialized
-    */
-   public static final int NATIVE_ERROR_CANT_INITIALIZE_AIO = 203;
-
-   /**
-    * AIO has not been properly released
-    */
-   public static final int NATIVE_ERROR_CANT_RELEASE_AIO = 204;
-
-   /**
-    * A closed file has not be properly reopened
-    */
-   public static final int NATIVE_ERROR_CANT_OPEN_CLOSE_FILE = 205;
-
-   /**
-    * An error occured while allocating a queue in AIO native code
-    */
-   public static final int NATIVE_ERROR_CANT_ALLOCATE_QUEUE = 206;
-
-   /**
-    * An error occured while pre-allocating a file in AIO native code
-    */
-   public static final int NATIVE_ERROR_PREALLOCATE_FILE = 208;
-
-   /**
-    * An error occurred while allocating memory in the AIO native code
-    */
-   public static final int NATIVE_ERROR_ALLOCATE_MEMORY = 209;
-
-   /**
-    * AIO is full
-    */
-   public static final int NATIVE_ERROR_AIO_FULL = 211;
-
-   private int code;
-
-   public HornetQException()
-   {
-   }
-
-   public HornetQException(final int code)
-   {
-      this.code = code;
-   }
-
-   public HornetQException(final int code, final String msg)
-   {
-      super(msg);
-
-      this.code = code;
-   }
-
-   public HornetQException(final int code, final String msg, final Throwable cause)
-   {
-      super(msg, cause);
-
-      this.code = code;
-   }
-
-   public int getCode()
-   {
-      return code;
-   }
-
-   @Override
-   public String toString()
-   {
-      return "HornetQException[errorCode=" + code + " message=" + getMessage() + "]";
-   }
-
-}

Deleted: trunk/hornetq-core/src/main/java/org/hornetq/api/core/Pair.java
===================================================================
--- trunk/hornetq-core/src/main/java/org/hornetq/api/core/Pair.java	2011-05-26 12:31:10 UTC (rev 10738)
+++ trunk/hornetq-core/src/main/java/org/hornetq/api/core/Pair.java	2011-05-26 12:50:50 UTC (rev 10739)
@@ -1,84 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *    http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.  See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package org.hornetq.api.core;
-
-import java.io.Serializable;
-
-/**
- * 
- * A Pair is a holder for 2 objects.
- * 
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- */
-public class Pair<A, B> implements Serializable
-{
-   private static final long serialVersionUID = -2496357457812368127L;
-
-   public Pair(final A a, final B b)
-   {
-      this.a = a;
-
-      this.b = b;
-   }
-
-   public A a;
-
-   public B b;
-
-   private int hash = -1;
-
-   @Override
-   public int hashCode()
-   {
-      if (hash == -1)
-      {
-         if (a == null && b == null)
-         {
-            return super.hashCode();
-         }
-         else
-         {
-            hash = (a == null ? 0 : a.hashCode()) + 37 * (b == null ? 0 : b.hashCode());
-         }
-      }
-
-      return hash;
-   }
-
-   @Override
-   public boolean equals(final Object other)
-   {
-      if (other == this)
-      {
-         return true;
-      }
-
-      if (other instanceof Pair == false)
-      {
-         return false;
-      }
-
-      Pair<A, B> pother = (Pair<A, B>)other;
-
-      return (pother.a == null ? a == null : pother.a.equals(a)) && (pother.b == null ? b == null : pother.b.equals(b));
-
-   }
-
-   @Override
-   public String toString()
-   {
-      return "Pair[a=" + a + ", b=" + b + "]";
-   }
-}

Deleted: trunk/hornetq-core/src/main/java/org/hornetq/api/core/SimpleString.java
===================================================================
--- trunk/hornetq-core/src/main/java/org/hornetq/api/core/SimpleString.java	2011-05-26 12:31:10 UTC (rev 10738)
+++ trunk/hornetq-core/src/main/java/org/hornetq/api/core/SimpleString.java	2011-05-26 12:50:50 UTC (rev 10739)
@@ -1,426 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *    http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.  See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package org.hornetq.api.core;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.hornetq.core.logging.Logger;
-import org.hornetq.utils.DataConstants;
-
-/**
- * A simple String class that can store all characters, and stores as simple byte[],
- * this minimises expensive copying between String objects.
- *
- * This object is used heavily throughout HornetQ for performance reasons.
- * 
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- */
-
-public class SimpleString implements CharSequence, Serializable, Comparable<SimpleString>
-{
-   private static final long serialVersionUID = 4204223851422244307L;
-
-   private static final Logger log = Logger.getLogger(SimpleString.class);
-
-   // Attributes
-   // ------------------------------------------------------------------------
-   private final byte[] data;
-
-   private transient int hash;
-
-   // Cache the string
-   private transient String str;
-
-   // Static
-   // ----------------------------------------------------------------------
-
-   /**
-    * Returns a SimpleString constructed from the <code>string</code> parameter.
-    * If <code>string</code> is <code>null</code>, the return value will be <code>null</code> too.
-    */
-   public static SimpleString toSimpleString(final String string)
-   {
-      if (string == null)
-      {
-         return null;
-      }
-      return new SimpleString(string);
-   }
-
-   // Constructors
-   // ----------------------------------------------------------------------
-   /**
-    * creates a SimpleString from a conventional String
-    * @param string the string to transform
-    */
-   public SimpleString(final String string)
-   {
-      int len = string.length();
-
-      data = new byte[len << 1];
-
-      int j = 0;
-
-      for (int i = 0; i < len; i++)
-      {
-         char c = string.charAt(i);
-
-         byte low = (byte)(c & 0xFF); // low byte
-
-         data[j++] = low;
-
-         byte high = (byte)(c >> 8 & 0xFF); // high byte
-
-         data[j++] = high;
-      }
-
-      str = string;
-   }
-
-   /**
-    * creates a SimpleString from a byte array
-    * @param data the byte array to use
-    */
-   public SimpleString(final byte[] data)
-   {
-      this.data = data;
-   }
-
-   // CharSequence implementation
-   // ---------------------------------------------------------------------------
-
-   public int length()
-   {
-      return data.length >> 1;
-   }
-
-   public char charAt(int pos)
-   {
-      if (pos < 0 || pos >= data.length >> 1)
-      {
-         throw new IndexOutOfBoundsException();
-      }
-      pos <<= 1;
-
-      return (char)(data[pos] | data[pos + 1] << 8);
-   }
-
-   public CharSequence subSequence(final int start, final int end)
-   {
-      int len = data.length >> 1;
-
-      if (end < start || start < 0 || end > len)
-      {
-         throw new IndexOutOfBoundsException();
-      }
-      else
-      {
-         int newlen = end - start << 1;
-         byte[] bytes = new byte[newlen];
-
-         System.arraycopy(data, start << 1, bytes, 0, newlen);
-
-         return new SimpleString(bytes);
-      }
-   }
-
-   // Comparable implementation -------------------------------------
-
-   public int compareTo(final SimpleString o)
-   {
-      return toString().compareTo(o.toString());
-   }
-
-   // Public
-   // ---------------------------------------------------------------------------
-
-   /**
-    * returns the underlying byte array of this SimpleString
-    * @return the byte array
-    */
-   public byte[] getData()
-   {
-      return data;
-   }
-
-   /**
-    * returns true if the SimpleString parameter starts with the same data as this one. false if not.
-    * @param other the SimpelString to look for
-    * @return true if this SimpleString starts with the same data
-    */
-   public boolean startsWith(final SimpleString other)
-   {
-      byte[] otherdata = other.data;
-
-      if (otherdata.length > data.length)
-      {
-         return false;
-      }
-
-      for (int i = 0; i < otherdata.length; i++)
-      {
-         if (data[i] != otherdata[i])
-         {
-            return false;
-         }
-      }
-
-      return true;
-   }
-
-   @Override
-   public String toString()
-   {
-      if (str == null)
-      {
-         int len = data.length >> 1;
-
-         char[] chars = new char[len];
-
-         int j = 0;
-
-         for (int i = 0; i < len; i++)
-         {
-            int low = data[j++] & 0xFF;
-
-            int high = data[j++] << 8 & 0xFF00;
-
-            chars[i] = (char)(low | high);
-         }
-
-         str = new String(chars);
-      }
-
-      return str;
-   }
-
-   @Override
-   public boolean equals(final Object other)
-   {
-      if (this == other)
-      {
-         return true;
-      }
-      
-      if (other instanceof SimpleString)
-      {
-         SimpleString s = (SimpleString)other;
-
-         if (data.length != s.data.length)
-         {
-            return false;
-         }
-
-         for (int i = 0; i < data.length; i++)
-         {
-            if (data[i] != s.data[i])
-            {
-               return false;
-            }
-         }
-
-         return true;
-      }
-      else
-      {
-         return false;
-      }
-   }
-
-   @Override
-   public int hashCode()
-   {
-      if (hash == 0)
-      {
-         int tmphash = 0;
-         for (byte element : data)
-         {
-            tmphash = (tmphash << 5) - tmphash + element; // (hash << 5) - hash is same as hash * 31
-         }
-         hash = tmphash;
-      }
-
-      return hash;
-   }
-
-   /**
-    * splits this SimpleString into an array of SimpleString using the char param as the delimeter.
-    *
-    * i.e. "a.b" would return "a" and "b" if . was the delimeter
-    * @param delim
-    */
-   public SimpleString[] split(final char delim)
-   {
-      if (!contains(delim))
-      {
-         return new SimpleString[] { this };
-      }
-      else
-      {
-         List<SimpleString> all = new ArrayList<SimpleString>();
-         int lasPos = 0;
-         for (int i = 0; i < data.length; i += 2)
-         {
-            byte low = (byte)(delim & 0xFF); // low byte
-            byte high = (byte)(delim >> 8 & 0xFF); // high byte
-            if (data[i] == low && data[i + 1] == high)
-            {
-               byte[] bytes = new byte[i - lasPos];
-               System.arraycopy(data, lasPos, bytes, 0, bytes.length);
-               lasPos = i + 2;
-               all.add(new SimpleString(bytes));
-            }
-         }
-         byte[] bytes = new byte[data.length - lasPos];
-         System.arraycopy(data, lasPos, bytes, 0, bytes.length);
-         all.add(new SimpleString(bytes));
-         SimpleString[] parts = new SimpleString[all.size()];
-         return all.toArray(parts);
-      }
-   }
-
-   /**
-    * checks to see if this SimpleString contains the char parameter passed in
-    *
-    * @param c the char to check for
-    * @return true if the char is found, false otherwise.
-    */
-   public boolean contains(final char c)
-   {
-      for (int i = 0; i < data.length; i += 2)
-      {
-         byte low = (byte)(c & 0xFF); // low byte
-         byte high = (byte)(c >> 8 & 0xFF); // high byte
-         if (data[i] == low && data[i + 1] == high)
-         {
-            return true;
-         }
-      }
-      return false;
-   }
-
-   /**
-    * concatanates a SimpleString and a String
-    *
-    * @param toAdd the String to concate with.
-    * @return the concatanated SimpleString
-    */
-   public SimpleString concat(final String toAdd)
-   {
-      return concat(new SimpleString(toAdd));
-   }
-
-   /**
-    * concatanates 2 SimpleString's
-    *
-    * @param toAdd the SimpleString to concate with.
-    * @return the concatanated SimpleString
-    */
-   public SimpleString concat(final SimpleString toAdd)
-   {
-      byte[] bytes = new byte[data.length + toAdd.getData().length];
-      System.arraycopy(data, 0, bytes, 0, data.length);
-      System.arraycopy(toAdd.getData(), 0, bytes, data.length, toAdd.getData().length);
-      return new SimpleString(bytes);
-   }
-
-   /**
-    * concatanates a SimpleString and a char
-    *
-    * @param c the char to concate with.
-    * @return the concatanated SimpleString
-    */
-   public SimpleString concat(final char c)
-   {
-      byte[] bytes = new byte[data.length + 2];
-      System.arraycopy(data, 0, bytes, 0, data.length);
-      bytes[data.length] = (byte)(c & 0xFF);
-      bytes[data.length + 1] = (byte)(c >> 8 & 0xFF);
-      return new SimpleString(bytes);
-   }
-
-   /**
-    * returns the size of this SimpleString
-    * @return the size
-    */
-   public int sizeof()
-   {
-      return DataConstants.SIZE_INT + data.length;
-   }
-
-   /**
-    * returns the size of a SimpleString
-    * @param str the SimpleString to check
-    * @return the size
-    */
-   public static int sizeofString(final SimpleString str)
-   {
-      return str.sizeof();
-   }
-
-   /**
-    * returns the size of a SimpleString which could be null
-    * @param str the SimpleString to check
-    * @return the size
-    */
-   public static int sizeofNullableString(final SimpleString str)
-   {
-      if (str == null)
-      {
-         return 1;
-      }
-      else
-      {
-         return 1 + str.sizeof();
-      }
-   }
-
-   /**
-    * 
-    * @param srcBegin
-    * @param srcEnd
-    * @param dst
-    * @param dstBegin
-    */
-   public void getChars(final int srcBegin, final int srcEnd, final char dst[], final int dstBegin)
-   {
-      if (srcBegin < 0)
-      {
-         throw new StringIndexOutOfBoundsException(srcBegin);
-      }
-      if (srcEnd > length())
-      {
-         throw new StringIndexOutOfBoundsException(srcEnd);
-      }
-      if (srcBegin > srcEnd)
-      {
-         throw new StringIndexOutOfBoundsException(srcEnd - srcBegin);
-      }
-
-      int j = 0;
-
-      for (int i = srcBegin; i < srcEnd - srcBegin; i++)
-      {
-         int low = data[j++] & 0xFF;
-
-         int high = data[j++] << 8 & 0xFF00;
-
-         dst[i] = (char)(low | high);
-      }
-   }
-
-}
\ No newline at end of file

Deleted: trunk/hornetq-core/src/main/java/org/hornetq/core/buffers/impl/ChannelBufferWrapper.java
===================================================================
--- trunk/hornetq-core/src/main/java/org/hornetq/core/buffers/impl/ChannelBufferWrapper.java	2011-05-26 12:31:10 UTC (rev 10738)
+++ trunk/hornetq-core/src/main/java/org/hornetq/core/buffers/impl/ChannelBufferWrapper.java	2011-05-26 12:50:50 UTC (rev 10739)
@@ -1,620 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *    http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.  See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package org.hornetq.core.buffers.impl;
-
-import java.nio.ByteBuffer;
-
-import org.hornetq.api.core.HornetQBuffer;
-import org.hornetq.api.core.SimpleString;
-import org.hornetq.core.logging.Logger;
-import org.hornetq.utils.DataConstants;
-import org.hornetq.utils.UTF8Util;
-import org.jboss.netty.buffer.ChannelBuffer;
-
-/**
- * 
- * A ChannelBufferWrapper
- *
- * @author Tim Fox
- *
- *
- */
-public class ChannelBufferWrapper implements HornetQBuffer
-{
-   private static final Logger log = Logger.getLogger(ChannelBufferWrapper.class);
-
-   protected ChannelBuffer buffer;
-
-   public ChannelBufferWrapper(final ChannelBuffer buffer)
-   {
-      this.buffer = buffer;
-   }
-
-   public boolean readBoolean()
-   {
-      return readByte() != 0;
-   }
-
-   public SimpleString readNullableSimpleString()
-   {
-      int b = buffer.readByte();
-      if (b == DataConstants.NULL)
-      {
-         return null;
-      }
-      else
-      {
-         return readSimpleStringInternal();
-      }
-   }
-
-   public String readNullableString()
-   {
-      int b = buffer.readByte();
-      if (b == DataConstants.NULL)
-      {
-         return null;
-      }
-      else
-      {
-         return readStringInternal();
-      }
-   }
-
-   public SimpleString readSimpleString()
-   {
-      return readSimpleStringInternal();
-   }
-
-   private SimpleString readSimpleStringInternal()
-   {
-      int len = buffer.readInt();
-      byte[] data = new byte[len];
-      buffer.readBytes(data);
-      return new SimpleString(data);
-   }
-
-   public String readString()
-   {
-      return readStringInternal();
-   }
-
-   private String readStringInternal()
-   {
-      int len = buffer.readInt();
-
-      if (len < 9)
-      {
-         char[] chars = new char[len];
-         for (int i = 0; i < len; i++)
-         {
-            chars[i] = (char)buffer.readShort();
-         }
-         return new String(chars);
-      }
-      else if (len < 0xfff)
-      {
-         return readUTF();
-      }
-      else
-      {
-         return readSimpleStringInternal().toString();
-      }
-   }
-
-   public String readUTF()
-   {
-      return UTF8Util.readUTF(this);
-   }
-
-   public void writeBoolean(final boolean val)
-   {
-      buffer.writeByte((byte)(val ? -1 : 0));
-   }
-
-   public void writeNullableSimpleString(final SimpleString val)
-   {
-      if (val == null)
-      {
-         buffer.writeByte(DataConstants.NULL);
-      }
-      else
-      {
-         buffer.writeByte(DataConstants.NOT_NULL);
-         writeSimpleStringInternal(val);
-      }
-   }
-
-   public void writeNullableString(final String val)
-   {
-      if (val == null)
-      {
-         buffer.writeByte(DataConstants.NULL);
-      }
-      else
-      {
-         buffer.writeByte(DataConstants.NOT_NULL);
-         writeStringInternal(val);
-      }
-   }
-
-   public void writeSimpleString(final SimpleString val)
-   {
-      writeSimpleStringInternal(val);
-   }
-
-   private void writeSimpleStringInternal(final SimpleString val)
-   {
-      byte[] data = val.getData();
-      buffer.writeInt(data.length);
-      buffer.writeBytes(data);
-   }
-
-   public void writeString(final String val)
-   {
-      writeStringInternal(val);
-   }
-
-   private void writeStringInternal(final String val)
-   {
-      int length = val.length();
-
-      buffer.writeInt(length);
-
-      if (length < 9)
-      {
-         // If very small it's more performant to store char by char
-         for (int i = 0; i < val.length(); i++)
-         {
-            buffer.writeShort((short)val.charAt(i));
-         }
-      }
-      else if (length < 0xfff)
-      {
-         // Store as UTF - this is quicker than char by char for most strings
-         writeUTF(val);
-      }
-      else
-      {
-         // Store as SimpleString, since can't store utf > 0xffff in length
-         writeSimpleStringInternal(new SimpleString(val));
-      }
-   }
-
-   public void writeUTF(final String utf)
-   {
-      UTF8Util.saveUTF(this, utf);
-   }
-
-   public int capacity()
-   {
-      return buffer.capacity();
-   }
-
-   public ChannelBuffer channelBuffer()
-   {
-      return buffer;
-   }
-
-   public void clear()
-   {
-      buffer.clear();
-   }
-
-   public HornetQBuffer copy()
-   {
-      return new ChannelBufferWrapper(buffer.copy());
-   }
-
-   public HornetQBuffer copy(final int index, final int length)
-   {
-      return new ChannelBufferWrapper(buffer.copy(index, length));
-   }
-
-   public void discardReadBytes()
-   {
-      buffer.discardReadBytes();
-   }
-
-   public HornetQBuffer duplicate()
-   {
-      return new ChannelBufferWrapper(buffer.duplicate());
-   }
-
-   public byte getByte(final int index)
-   {
-      return buffer.getByte(index);
-   }
-
-   public void getBytes(final int index, final byte[] dst, final int dstIndex, final int length)
-   {
-      buffer.getBytes(index, dst, dstIndex, length);
-   }
-
-   public void getBytes(final int index, final byte[] dst)
-   {
-      buffer.getBytes(index, dst);
-   }
-
-   public void getBytes(final int index, final ByteBuffer dst)
-   {
-      buffer.getBytes(index, dst);
-   }
-
-   public void getBytes(final int index, final HornetQBuffer dst, final int dstIndex, final int length)
-   {
-      buffer.getBytes(index, dst.channelBuffer(), dstIndex, length);
-   }
-
-   public void getBytes(final int index, final HornetQBuffer dst, final int length)
-   {
-      buffer.getBytes(index, dst.channelBuffer(), length);
-   }
-
-   public void getBytes(final int index, final HornetQBuffer dst)
-   {
-      buffer.getBytes(index, dst.channelBuffer());
-   }
-
-   public char getChar(final int index)
-   {
-      return (char)buffer.getShort(index);
-   }
-
-   public double getDouble(final int index)
-   {
-      return Double.longBitsToDouble(buffer.getLong(index));
-   }
-
-   public float getFloat(final int index)
-   {
-      return Float.intBitsToFloat(buffer.getInt(index));
-   }
-
-   public int getInt(final int index)
-   {
-      return buffer.getInt(index);
-   }
-
-   public long getLong(final int index)
-   {
-      return buffer.getLong(index);
-   }
-
-   public short getShort(final int index)
-   {
-      return buffer.getShort(index);
-   }
-
-   public short getUnsignedByte(final int index)
-   {
-      return buffer.getUnsignedByte(index);
-   }
-
-   public long getUnsignedInt(final int index)
-   {
-      return buffer.getUnsignedInt(index);
-   }
-
-   public int getUnsignedShort(final int index)
-   {
-      return buffer.getUnsignedShort(index);
-   }
-
-   public void markReaderIndex()
-   {
-      buffer.markReaderIndex();
-   }
-
-   public void markWriterIndex()
-   {
-      buffer.markWriterIndex();
-   }
-
-   public boolean readable()
-   {
-      return buffer.readable();
-   }
-
-   public int readableBytes()
-   {
-      return buffer.readableBytes();
-   }
-
-   public byte readByte()
-   {
-      return buffer.readByte();
-   }
-
-   public void readBytes(final byte[] dst, final int dstIndex, final int length)
-   {
-      buffer.readBytes(dst, dstIndex, length);
-   }
-
-   public void readBytes(final byte[] dst)
-   {
-      buffer.readBytes(dst);
-   }
-
-   public void readBytes(final ByteBuffer dst)
-   {
-      buffer.readBytes(dst);
-   }
-
-   public void readBytes(final HornetQBuffer dst, final int dstIndex, final int length)
-   {
-      buffer.readBytes(dst.channelBuffer(), dstIndex, length);
-   }
-
-   public void readBytes(final HornetQBuffer dst, final int length)
-   {
-      buffer.readBytes(dst.channelBuffer(), length);
-   }
-
-   public void readBytes(final HornetQBuffer dst)
-   {
-      buffer.readBytes(dst.channelBuffer());
-   }
-
-   public HornetQBuffer readBytes(final int length)
-   {
-      return new ChannelBufferWrapper(buffer.readBytes(length));
-   }
-
-   public char readChar()
-   {
-      return (char)buffer.readShort();
-   }
-
-   public double readDouble()
-   {
-      return Double.longBitsToDouble(buffer.readLong());
-   }
-
-   public int readerIndex()
-   {
-      return buffer.readerIndex();
-   }
-
-   public void readerIndex(final int readerIndex)
-   {
-      buffer.readerIndex(readerIndex);
-   }
-
-   public float readFloat()
-   {
-      return Float.intBitsToFloat(buffer.readInt());
-   }
-
-   public int readInt()
-   {
-      return buffer.readInt();
-   }
-
-   public long readLong()
-   {
-      return buffer.readLong();
-   }
-
-   public short readShort()
-   {
-      return buffer.readShort();
-   }
-
-   public HornetQBuffer readSlice(final int length)
-   {
-      return new ChannelBufferWrapper(buffer.readSlice(length));
-   }
-
-   public short readUnsignedByte()
-   {
-      return buffer.readUnsignedByte();
-   }
-
-   public long readUnsignedInt()
-   {
-      return buffer.readUnsignedInt();
-   }
-
-   public int readUnsignedShort()
-   {
-      return buffer.readUnsignedShort();
-   }
-
-   public void resetReaderIndex()
-   {
-      buffer.resetReaderIndex();
-   }
-
-   public void resetWriterIndex()
-   {
-      buffer.resetWriterIndex();
-   }
-
-   public void setByte(final int index, final byte value)
-   {
-      buffer.setByte(index, value);
-   }
-
-   public void setBytes(final int index, final byte[] src, final int srcIndex, final int length)
-   {
-      buffer.setBytes(index, src, srcIndex, length);
-   }
-
-   public void setBytes(final int index, final byte[] src)
-   {
-      buffer.setBytes(index, src);
-   }
-
-   public void setBytes(final int index, final ByteBuffer src)
-   {
-      buffer.setBytes(index, src);
-   }
-
-   public void setBytes(final int index, final HornetQBuffer src, final int srcIndex, final int length)
-   {
-      buffer.setBytes(index, src.channelBuffer(), srcIndex, length);
-   }
-
-   public void setBytes(final int index, final HornetQBuffer src, final int length)
-   {
-      buffer.setBytes(index, src.channelBuffer(), length);
-   }
-
-   public void setBytes(final int index, final HornetQBuffer src)
-   {
-      buffer.setBytes(index, src.channelBuffer());
-   }
-
-   public void setChar(final int index, final char value)
-   {
-      buffer.setShort(index, (short)value);
-   }
-
-   public void setDouble(final int index, final double value)
-   {
-      buffer.setLong(index, Double.doubleToLongBits(value));
-   }
-
-   public void setFloat(final int index, final float value)
-   {
-      buffer.setInt(index, Float.floatToIntBits(value));
-   }
-
-   public void setIndex(final int readerIndex, final int writerIndex)
-   {
-      buffer.setIndex(readerIndex, writerIndex);
-   }
-
-   public void setInt(final int index, final int value)
-   {
-      buffer.setInt(index, value);
-   }
-
-   public void setLong(final int index, final long value)
-   {
-      buffer.setLong(index, value);
-   }
-
-   public void setShort(final int index, final short value)
-   {
-      buffer.setShort(index, value);
-   }
-
-   public void skipBytes(final int length)
-   {
-      buffer.skipBytes(length);
-   }
-
-   public HornetQBuffer slice()
-   {
-      return new ChannelBufferWrapper(buffer.slice());
-   }
-
-   public HornetQBuffer slice(final int index, final int length)
-   {
-      return new ChannelBufferWrapper(buffer.slice(index, length));
-   }
-
-   public ByteBuffer toByteBuffer()
-   {
-      return buffer.toByteBuffer();
-   }
-
-   public ByteBuffer toByteBuffer(final int index, final int length)
-   {
-      return buffer.toByteBuffer(index, length);
-   }
-
-   public boolean writable()
-   {
-      return buffer.writable();
-   }
-
-   public int writableBytes()
-   {
-      return buffer.writableBytes();
-   }
-
-   public void writeByte(final byte value)
-   {
-      buffer.writeByte(value);
-   }
-
-   public void writeBytes(final byte[] src, final int srcIndex, final int length)
-   {
-      buffer.writeBytes(src, srcIndex, length);
-   }
-
-   public void writeBytes(final byte[] src)
-   {
-      buffer.writeBytes(src);
-   }
-
-   public void writeBytes(final ByteBuffer src)
-   {
-      buffer.writeBytes(src);
-   }
-
-   public void writeBytes(final HornetQBuffer src, final int srcIndex, final int length)
-   {
-      buffer.writeBytes(src.channelBuffer(), srcIndex, length);
-   }
-
-   public void writeBytes(final HornetQBuffer src, final int length)
-   {
-      buffer.writeBytes(src.channelBuffer(), length);
-   }
-
-   public void writeChar(final char chr)
-   {
-      buffer.writeShort((short)chr);
-   }
-
-   public void writeDouble(final double value)
-   {
-      buffer.writeLong(Double.doubleToLongBits(value));
-   }
-
-   public void writeFloat(final float value)
-   {
-      buffer.writeInt(Float.floatToIntBits(value));
-   }
-
-   public void writeInt(final int value)
-   {
-      buffer.writeInt(value);
-   }
-
-   public void writeLong(final long value)
-   {
-      buffer.writeLong(value);
-   }
-
-   public int writerIndex()
-   {
-      return buffer.writerIndex();
-   }
-
-   public void writerIndex(final int writerIndex)
-   {
-      buffer.writerIndex(writerIndex);
-   }
-
-   public void writeShort(final short value)
-   {
-      buffer.writeShort(value);
-   }
-
-}

Deleted: trunk/hornetq-core/src/main/java/org/hornetq/core/server/HornetQComponent.java
===================================================================
--- trunk/hornetq-core/src/main/java/org/hornetq/core/server/HornetQComponent.java	2011-05-26 12:31:10 UTC (rev 10738)
+++ trunk/hornetq-core/src/main/java/org/hornetq/core/server/HornetQComponent.java	2011-05-26 12:50:50 UTC (rev 10739)
@@ -1,32 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *    http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.  See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package org.hornetq.core.server;
-
-/**
- * A HornetQComponent
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision: 2796 $</tt>
- *
- * $Id: HornetQComponent.java 2796 2007-06-25 22:24:41Z timfox $
- *
- */
-public interface HornetQComponent
-{
-   void start() throws Exception;
-
-   void stop() throws Exception;
-
-   boolean isStarted();
-}

Deleted: trunk/hornetq-core/src/main/java/org/hornetq/utils/DataConstants.java
===================================================================
--- trunk/hornetq-core/src/main/java/org/hornetq/utils/DataConstants.java	2011-05-26 12:31:10 UTC (rev 10738)
+++ trunk/hornetq-core/src/main/java/org/hornetq/utils/DataConstants.java	2011-05-26 12:50:50 UTC (rev 10739)
@@ -1,68 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *    http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.  See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package org.hornetq.utils;
-
-/**
- * 
- * A DataConstants
- * 
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- */
-public class DataConstants
-{
-   public static final int SIZE_INT = 4;
-
-   public static final int SIZE_BOOLEAN = 1;
-
-   public static final int SIZE_LONG = 8;
-
-   public static final int SIZE_BYTE = 1;
-
-   public static final int SIZE_SHORT = 2;
-
-   public static final int SIZE_DOUBLE = 8;
-
-   public static final int SIZE_FLOAT = 4;
-
-   public static final int SIZE_CHAR = 2;
-
-   public static final byte TRUE = 1;
-
-   public static final byte FALSE = 0;
-
-   public static final byte NULL = 0;
-
-   public static final byte NOT_NULL = 1;
-
-   public static final byte BOOLEAN = 2;
-
-   public static final byte BYTE = 3;
-
-   public static final byte BYTES = 4;
-
-   public static final byte SHORT = 5;
-
-   public static final byte INT = 6;
-
-   public static final byte LONG = 7;
-
-   public static final byte FLOAT = 8;
-
-   public static final byte DOUBLE = 9;
-
-   public static final byte STRING = 10;
-
-   public static final byte CHAR = 11;
-}

Deleted: trunk/hornetq-core/src/main/java/org/hornetq/utils/UTF8Util.java
===================================================================
--- trunk/hornetq-core/src/main/java/org/hornetq/utils/UTF8Util.java	2011-05-26 12:31:10 UTC (rev 10738)
+++ trunk/hornetq-core/src/main/java/org/hornetq/utils/UTF8Util.java	2011-05-26 12:50:50 UTC (rev 10739)
@@ -1,272 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *    http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.  See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package org.hornetq.utils;
-
-import java.lang.ref.SoftReference;
-
-import org.hornetq.api.core.HornetQBuffer;
-import org.hornetq.core.logging.Logger;
-
-/**
- * 
- * A UTF8Util
- * 
- * This class will write UTFs directly to the ByteOutput (through the MessageBuffer interface)
- *
- * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
- * 
- * Created Feb 20, 2009 1:37:18 PM
- *
- *
- */
-public class UTF8Util
-{
-   static boolean optimizeStrings = true;
-
-   private static final Logger log = Logger.getLogger(UTF8Util.class);
-
-   private static final boolean isTrace = UTF8Util.log.isTraceEnabled();
-
-   private static ThreadLocal<SoftReference<StringUtilBuffer>> currenBuffer = new ThreadLocal<SoftReference<StringUtilBuffer>>();
-
-   public static void saveUTF(final HornetQBuffer out, final String str)
-   {
-      StringUtilBuffer buffer = UTF8Util.getThreadLocalBuffer();
-
-      if (str.length() > 0xffff)
-      {
-         throw new IllegalArgumentException("the specified string is too long (" + str.length() + ")");
-      }
-
-      final int len = UTF8Util.calculateUTFSize(str, buffer);
-
-      if (len > 0xffff)
-      {
-         throw new IllegalArgumentException("the encoded string is too long (" + len + ")");
-      }
-
-      out.writeShort((short)len);
-
-      if (len > buffer.byteBuffer.length)
-      {
-         buffer.resizeByteBuffer(len);
-      }
-
-      if (len == (long)str.length())
-      {
-         for (int byteLocation = 0; byteLocation < len; byteLocation++)
-         {
-            buffer.byteBuffer[byteLocation] = (byte)buffer.charBuffer[byteLocation];
-         }
-         out.writeBytes(buffer.byteBuffer, 0, len);
-      }
-      else
-      {
-         if (UTF8Util.isTrace)
-         {
-            // This message is too verbose for debug, that's why we are using trace here
-            UTF8Util.log.trace("Saving string with utfSize=" + len + " stringSize=" + str.length());
-         }
-
-         int stringLength = str.length();
-
-         int charCount = 0;
-
-         for (int i = 0; i < stringLength; i++)
-         {
-            char charAtPos = buffer.charBuffer[i];
-            if (charAtPos >= 1 && charAtPos < 0x7f)
-            {
-               buffer.byteBuffer[charCount++] = (byte)charAtPos;
-            }
-            else if (charAtPos >= 0x800)
-            {
-               buffer.byteBuffer[charCount++] = (byte)(0xE0 | charAtPos >> 12 & 0x0F);
-               buffer.byteBuffer[charCount++] = (byte)(0x80 | charAtPos >> 6 & 0x3F);
-               buffer.byteBuffer[charCount++] = (byte)(0x80 | charAtPos >> 0 & 0x3F);
-            }
-            else
-            {
-               buffer.byteBuffer[charCount++] = (byte)(0xC0 | charAtPos >> 6 & 0x1F);
-               buffer.byteBuffer[charCount++] = (byte)(0x80 | charAtPos >> 0 & 0x3F);
-
-            }
-         }
-         out.writeBytes(buffer.byteBuffer, 0, len);
-      }
-   }
-
-   public static String readUTF(final HornetQBuffer input)
-   {
-      StringUtilBuffer buffer = UTF8Util.getThreadLocalBuffer();
-
-      final int size = input.readUnsignedShort();
-
-      if (size > buffer.byteBuffer.length)
-      {
-         buffer.resizeByteBuffer(size);
-      }
-
-      if (size > buffer.charBuffer.length)
-      {
-         buffer.resizeCharBuffer(size);
-      }
-
-      if (UTF8Util.isTrace)
-      {
-         // This message is too verbose for debug, that's why we are using trace here
-         UTF8Util.log.trace("Reading string with utfSize=" + size);
-      }
-
-      int count = 0;
-      int byte1, byte2, byte3;
-      int charCount = 0;
-
-      input.readBytes(buffer.byteBuffer, 0, size);
-
-      while (count < size)
-      {
-         byte1 = buffer.byteBuffer[count++];
-
-         if (byte1 > 0 && byte1 <= 0x7F)
-         {
-            buffer.charBuffer[charCount++] = (char)byte1;
-         }
-         else
-         {
-            int c = byte1 & 0xff;
-            switch (c >> 4)
-            {
-               case 0xc:
-               case 0xd:
-                  byte2 = buffer.byteBuffer[count++];
-                  buffer.charBuffer[charCount++] = (char)((c & 0x1F) << 6 | byte2 & 0x3F);
-                  break;
-               case 0xe:
-                  byte2 = buffer.byteBuffer[count++];
-                  byte3 = buffer.byteBuffer[count++];
-                  buffer.charBuffer[charCount++] = (char)((c & 0x0F) << 12 | (byte2 & 0x3F) << 6 | (byte3 & 0x3F) << 0);
-                  break;
-            }
-         }
-      }
-
-      return new String(buffer.charBuffer, 0, charCount);
-
-   }
-
-   private static StringUtilBuffer getThreadLocalBuffer()
-   {
-      SoftReference<StringUtilBuffer> softReference = UTF8Util.currenBuffer.get();
-      StringUtilBuffer value;
-      if (softReference == null)
-      {
-         value = new StringUtilBuffer();
-         softReference = new SoftReference<StringUtilBuffer>(value);
-         UTF8Util.currenBuffer.set(softReference);
-      }
-      else
-      {
-         value = softReference.get();
-      }
-
-      if (value == null)
-      {
-         value = new StringUtilBuffer();
-         softReference = new SoftReference<StringUtilBuffer>(value);
-         UTF8Util.currenBuffer.set(softReference);
-      }
-
-      return value;
-   }
-
-   public static void clearBuffer()
-   {
-      SoftReference<StringUtilBuffer> ref = UTF8Util.currenBuffer.get();
-      if (ref.get() != null)
-      {
-         ref.clear();
-      }
-   }
-
-   public static int calculateUTFSize(final String str, final StringUtilBuffer stringBuffer)
-   {
-      int calculatedLen = 0;
-
-      int stringLength = str.length();
-
-      if (stringLength > stringBuffer.charBuffer.length)
-      {
-         stringBuffer.resizeCharBuffer(stringLength);
-      }
-
-      str.getChars(0, stringLength, stringBuffer.charBuffer, 0);
-
-      for (int i = 0; i < stringLength; i++)
-      {
-         char c = stringBuffer.charBuffer[i];
-
-         if (c >= 1 && c < 0x7f)
-         {
-            calculatedLen++;
-         }
-         else if (c >= 0x800)
-         {
-            calculatedLen += 3;
-         }
-         else
-         {
-            calculatedLen += 2;
-         }
-      }
-      return calculatedLen;
-   }
-
-   private static class StringUtilBuffer
-   {
-
-      public char charBuffer[];
-
-      public byte byteBuffer[];
-
-      public void resizeCharBuffer(final int newSize)
-      {
-         if (newSize > charBuffer.length)
-         {
-            charBuffer = new char[newSize];
-         }
-      }
-
-      public void resizeByteBuffer(final int newSize)
-      {
-         if (newSize > byteBuffer.length)
-         {
-            byteBuffer = new byte[newSize];
-         }
-      }
-
-      public StringUtilBuffer()
-      {
-         this(1024, 1024);
-      }
-
-      public StringUtilBuffer(final int sizeChar, final int sizeByte)
-      {
-         charBuffer = new char[sizeChar];
-         byteBuffer = new byte[sizeByte];
-      }
-
-   }
-
-}



More information about the hornetq-commits mailing list