qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgodf...@apache.org
Subject svn commit: r1773584 [1/4] - in /qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0: ./ codec/ framing/ messaging/ type/ type/codec/ type/messaging/codec/ type/security/codec/ type/transaction/codec/ typ...
Date Sun, 11 Dec 2016 16:01:07 GMT
Author: rgodfrey
Date: Sun Dec 11 16:01:06 2016
New Revision: 1773584

URL: http://svn.apache.org/viewvc?rev=1773584&view=rev
Log:
QPID-7586 : Improve AMQP 1.0 codec

Removed:
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/ArrayWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/WrapperTypeValueWriter.java
Modified:
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/AMQPConnection_1_0.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageConverter_from_1_0.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/Session_1_0.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/AbstractDescribedTypeWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/AbstractListWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/AbstractMapWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/BinaryWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/BooleanWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/ByteArrayWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/ByteWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/CharWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/CompoundWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/DelegatingValueWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/DoubleWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/FixedEightWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/FixedFourWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/FixedOneWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/FixedSixteenWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/FixedTwoWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/FloatWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/FrameWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/IntegerWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/ListWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/LongWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/MapWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/NullWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/RestrictedTypeValueWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/ShortWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/SimpleVariableWidthWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/StringWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/SymbolArrayWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/SymbolWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/TimestampWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/UUIDWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/UnsignedByteWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/UnsignedIntegerWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/UnsignedLongWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/UnsignedShortWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/ValueWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/VariableWidthWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/framing/FrameHandler.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/messaging/SectionEncoderImpl.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/Binary.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/codec/AMQPDescribedTypeRegistry.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/AcceptedWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/AmqpSequenceWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/AmqpValueWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/ApplicationPropertiesWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/DataWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/DeleteOnCloseWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/DeleteOnNoLinksOrMessagesWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/DeleteOnNoLinksWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/DeleteOnNoMessagesWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/DeliveryAnnotationsWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/ExactSubjectFilterWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/FooterWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/HeaderWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/JMSSelectorFilterWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/MatchingSubjectFilterWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/MessageAnnotationsWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/ModifiedWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/NoLocalFilterWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/PropertiesWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/ReceivedWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/RejectedWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/ReleasedWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/SourceWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/TargetWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/security/codec/SaslChallengeWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/security/codec/SaslInitWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/security/codec/SaslMechanismsWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/security/codec/SaslOutcomeWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/security/codec/SaslResponseWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transaction/codec/CoordinatorWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transaction/codec/DeclareWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transaction/codec/DeclaredWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transaction/codec/DischargeWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transaction/codec/TransactionalStateWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/codec/AttachWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/codec/BeginWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/codec/CloseWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/codec/DetachWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/codec/DispositionWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/codec/EndWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/codec/ErrorWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/codec/FlowWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/codec/OpenWriter.java
    qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/codec/TransferWriter.java

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/AMQPConnection_1_0.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/AMQPConnection_1_0.java?rev=1773584&r1=1773583&r2=1773584&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/AMQPConnection_1_0.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/AMQPConnection_1_0.java Sun Dec 11 16:01:06 2016
@@ -1041,7 +1041,7 @@ public class AMQPConnection_1_0 extends
             }
             else
             {
-                int size = writer.writeToBuffer(EMPTY_BYTE_BUFFER);
+                int size = writer.getEncodedSize();
                 int maxPayloadSize = _maxFrameSize - (size + 9);
                 long payloadLength = QpidByteBufferUtils.remaining(payload);
                 if(payloadLength <= maxPayloadSize)
@@ -1054,7 +1054,7 @@ public class AMQPConnection_1_0 extends
                     ((Transfer) body).setMore(Boolean.TRUE);
 
                     writer = _describedTypeRegistry.getValueWriter(body);
-                    size = writer.writeToBuffer(EMPTY_BYTE_BUFFER);
+                    size = writer.getEncodedSize();
                     maxPayloadSize = _maxFrameSize - (size + 9);
 
                     List<QpidByteBuffer> payloadDup = new ArrayList<>(payload.size());

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageConverter_from_1_0.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageConverter_from_1_0.java?rev=1773584&r1=1773583&r2=1773584&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageConverter_from_1_0.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageConverter_from_1_0.java Sun Dec 11 16:01:06 2016
@@ -50,7 +50,6 @@ import org.apache.qpid.server.protocol.v
 import org.apache.qpid.server.protocol.v1_0.type.UnsignedShort;
 import org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpSequenceSection;
 import org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValueSection;
-import org.apache.qpid.server.protocol.v1_0.type.messaging.Data;
 import org.apache.qpid.server.protocol.v1_0.type.messaging.DataSection;
 import org.apache.qpid.server.protocol.v1_0.type.messaging.EncodingRetainingSection;
 import org.apache.qpid.server.util.ConnectionScopedRuntimeException;
@@ -116,7 +115,7 @@ public class MessageConverter_from_1_0
                     int totalSize = 0;
                     for(EncodingRetainingSection<?> section : sections)
                     {
-                        totalSize += ((DataSection)section).getValue().getLength();
+                        totalSize += ((DataSection)section).getValue().getArray().length;
                     }
                     byte[] bodyData = new byte[totalSize];
                     ByteBuffer buf = ByteBuffer.wrap(bodyData);
@@ -208,10 +207,7 @@ public class MessageConverter_from_1_0
             }
             else if(value instanceof Binary)
             {
-                Binary binary = (Binary)value;
-                byte[] data = new byte[binary.getLength()];
-                binary.asByteBuffer().get(data);
-                return data;
+                return ((Binary)value).getArray();
             }
             else
             {

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/Session_1_0.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/Session_1_0.java?rev=1773584&r1=1773583&r2=1773584&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/Session_1_0.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/Session_1_0.java Sun Dec 11 16:01:06 2016
@@ -1224,15 +1224,15 @@ public class Session_1_0 implements AMQS
             return null;
         }
 
-        if(txnId.getLength() > 4)
+        byte[] data = txnId.getArray();
+        if(data.length > 4)
             throw new IllegalArgumentException();
 
         int id = 0;
-        byte[] data = txnId.getArray();
-        for(int i = 0; i < txnId.getLength(); i++)
+        for(int i = 0; i < data.length; i++)
         {
             id <<= 8;
-            id |= ((int)data[i+txnId.getArrayOffset()] & 0xff);
+            id |= ((int)data[i] & 0xff);
         }
 
         return id;

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/AbstractDescribedTypeWriter.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/AbstractDescribedTypeWriter.java?rev=1773584&r1=1773583&r2=1773584&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/AbstractDescribedTypeWriter.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/AbstractDescribedTypeWriter.java Sun Dec 11 16:01:06 2016
@@ -25,164 +25,29 @@ import org.apache.qpid.bytebuffer.QpidBy
 
 public abstract class AbstractDescribedTypeWriter<V> implements ValueWriter<V>
 {
-    private int _length;
-    private Registry _registry;
-    private static final int LARGE_COMPOUND_THRESHOLD_COUNT = 10;
-    private ValueWriter _delegate;
     private static final byte DESCRIBED_TYPE = (byte)0;
+    private final ValueWriter _descriptorWriter;
+    private final ValueWriter _describedWriter;
 
-    public AbstractDescribedTypeWriter(final Registry registry)
+    public AbstractDescribedTypeWriter(ValueWriter descriptorWriter,
+                                       ValueWriter describedWriter)
     {
-        _registry = registry;
+        _descriptorWriter = descriptorWriter;
+        _describedWriter = describedWriter;
     }
 
-    enum State {
-        FORMAT_CODE,
-        DESCRIPTOR,
-        DESCRIBED,
-        DONE
-    }
-
-    private State _state = State.FORMAT_CODE;
-
-    public int writeToBuffer(QpidByteBuffer buffer)
-    {
-        final int length = _length;
-
-        if(length == -1)
-        {
-            writeFirstPass(buffer);
-        }
-        else
-        {
-
-            State state = _state;
-
-            switch(state)
-            {
-                case FORMAT_CODE:
-                    if(buffer.hasRemaining())
-                    {
-                        buffer.put(DESCRIBED_TYPE);
-                        state = State.DESCRIPTOR;
-                        _delegate = createDescriptorWriter();
-                    }
-                    else
-                    {
-                        break;
-                    }
-
-                case DESCRIPTOR:
-                    if(buffer.hasRemaining())
-                    {
-                        _delegate.writeToBuffer(buffer);
-                        if(_delegate.isComplete())
-                        {
-                            state = State.DESCRIBED;
-                            _delegate = createDescribedWriter();
-                        }
-                        else
-                        {
-                            break;
-                        }
-                    }
-                case DESCRIBED:
-                    if(buffer.hasRemaining())
-                    {
-                        _delegate.writeToBuffer(buffer);
-                        if(_delegate.isComplete())
-                        {
-                            state = State.DONE;
-                            _delegate = null;
-                        }
-                        else
-                        {
-                            break;
-                        }
-                    }
-
-            }
-
-            _state = state;
-
-        }
 
-        return _length;
-    }
-
-    private void writeFirstPass(QpidByteBuffer buffer)
+    public void writeToBuffer(QpidByteBuffer buffer)
     {
+        buffer.put(DESCRIBED_TYPE);
+        _descriptorWriter.writeToBuffer(buffer);
+        _describedWriter.writeToBuffer(buffer);
 
-        int length = 1;
-        State state = State.FORMAT_CODE;
-
-        ValueWriter descriptorWriter = createDescriptorWriter();
-        if(buffer.hasRemaining())
-        {
-            buffer.put(DESCRIBED_TYPE);
-            state = State.DESCRIPTOR;
-            _delegate = descriptorWriter;
-        }
-        length += descriptorWriter.writeToBuffer(buffer);
-
-        ValueWriter describedWriter = createDescribedWriter();
-
-        if(descriptorWriter.isComplete())
-        {
-            state = State.DESCRIBED;
-            _delegate = describedWriter;
-        }
-
-        length += describedWriter.writeToBuffer(buffer);
-
-        if(describedWriter.isComplete())
-        {
-            _delegate = null;
-            state = State.DONE;
-        }
-
-        _state = state;
-        _length = length;
-    }
-
-    public void setValue(V value)
-    {
-        _length = -1;
-        _delegate = null;
-        _state = State.FORMAT_CODE;
-        onSetValue(value);
-    }
-
-    public void setRegistry(Registry registry)
-    {
-        _registry = registry;
-    }
-
-    protected Registry getRegistry()
-    {
-        return _registry;
-    }
-
-    protected abstract void onSetValue(final V value);
-
-    protected abstract void clear();
-
-    protected abstract ValueWriter createDescribedWriter();
-
-    protected abstract Object getDescriptor();
-
-    protected final ValueWriter createDescriptorWriter()
-    {
-        return getRegistry().getValueWriter(getDescriptor());
-    }
-
-    public boolean isComplete()
-    {
-        return _state == State.DONE;
     }
 
-    public boolean isCacheable()
+    @Override
+    public int getEncodedSize()
     {
-        return false;
+        return 1 + _descriptorWriter.getEncodedSize() + _describedWriter.getEncodedSize();
     }
 }

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/AbstractListWriter.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/AbstractListWriter.java?rev=1773584&r1=1773583&r2=1773584&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/AbstractListWriter.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/AbstractListWriter.java Sun Dec 11 16:01:06 2016
@@ -27,6 +27,11 @@ public abstract class AbstractListWriter
         super(registry);
     }
 
+    public AbstractListWriter(final Registry registry, final V object)
+    {
+        super(registry, object);
+    }
+
     @Override
     protected byte getFourOctetEncodingCode()
     {

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/AbstractMapWriter.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/AbstractMapWriter.java?rev=1773584&r1=1773583&r2=1773584&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/AbstractMapWriter.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/AbstractMapWriter.java Sun Dec 11 16:01:06 2016
@@ -23,11 +23,11 @@ package org.apache.qpid.server.protocol.
 
 public abstract class AbstractMapWriter<V> extends CompoundWriter<V>
 {
-    private boolean onKey;
+    private boolean _onKey;
 
-    public AbstractMapWriter(Registry registry)
+    AbstractMapWriter(final Registry registry, final V object)
     {
-        super(registry);
+        super(registry, object);
     }
 
     @Override
@@ -53,7 +53,7 @@ public abstract class AbstractMapWriter<
     @Override
     protected final boolean hasNext()
     {
-        return onKey || hasMapNext();
+        return _onKey || hasMapNext();
     }
 
     protected abstract boolean hasMapNext();
@@ -61,7 +61,7 @@ public abstract class AbstractMapWriter<
     @Override
     protected final Object next()
     {
-        if(onKey = !onKey)
+        if(_onKey = !_onKey)
         {
             return nextKey();
         }
@@ -76,18 +76,9 @@ public abstract class AbstractMapWriter<
     protected abstract Object nextKey();
 
     @Override
-    protected final void clear()
-    {
-        onKey = false;
-        onClear();
-    }
-
-    protected abstract void onClear();
-
-    @Override
     protected final void reset()
     {
-        onKey = false;
+        _onKey = false;
         onReset();
     }
 

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/BinaryWriter.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/BinaryWriter.java?rev=1773584&r1=1773583&r2=1773584&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/BinaryWriter.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/BinaryWriter.java Sun Dec 11 16:01:06 2016
@@ -25,8 +25,11 @@ import org.apache.qpid.server.protocol.v
 
 public class BinaryWriter extends SimpleVariableWidthWriter<Binary>
 {
-    private int _offset;
-    private int _length;
+
+    public BinaryWriter(final Binary object)
+    {
+        super(object.getArray());
+    }
 
     @Override
     protected byte getFourOctetEncodingCode()
@@ -40,31 +43,15 @@ public class BinaryWriter extends Simple
         return (byte)0xa0;
     }
 
-    @Override
-    protected byte[] getByteArray(Binary value)
-    {
-        _offset = value.getArrayOffset();
-        _length = value.getLength();
-        return value.getArray();
-    }
-
-    @Override
-    protected int getOffset()
-    {
-        return _offset;
-    }
-
-    @Override protected int getLength()
-    {
-        return _length;
-    }
 
     private static Factory<Binary> FACTORY = new Factory<Binary>()
                                             {
 
-                                                public ValueWriter<Binary> newInstance(Registry registry)
+                                                @Override
+                                                public ValueWriter<Binary> newInstance(final Registry registry,
+                                                                                       final Binary object)
                                                 {
-                                                    return new BinaryWriter();
+                                                    return new BinaryWriter(object);
                                                 }
                                             };
 

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/BooleanWriter.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/BooleanWriter.java?rev=1773584&r1=1773583&r2=1773584&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/BooleanWriter.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/BooleanWriter.java Sun Dec 11 16:01:06 2016
@@ -25,41 +25,41 @@ import org.apache.qpid.bytebuffer.QpidBy
 
 public class BooleanWriter implements ValueWriter<Boolean>
 {
-    private boolean _complete = true;
     private boolean _value;
 
-    public int writeToBuffer(QpidByteBuffer buffer)
+    public BooleanWriter()
     {
-        if(!_complete && buffer.hasRemaining())
-        {
-            buffer.put(_value ? (byte)0x41 : (byte)0x42);
-            _complete = true;
-        }
-        return 1;
     }
 
-    public void setValue(Boolean value)
+    public BooleanWriter(final Boolean object)
     {
-        _complete = false;
-        _value = value.booleanValue();
+        setValue(object);
     }
 
-    public boolean isCacheable()
+    @Override
+    public int getEncodedSize()
     {
-        return true;
+        return 1;
     }
 
-    public boolean isComplete()
+    public void writeToBuffer(QpidByteBuffer buffer)
     {
-        return _complete;
+        buffer.put(_value ? (byte)0x41 : (byte)0x42);
+    }
+
+    public void setValue(Boolean value)
+    {
+        _value = value.booleanValue();
     }
 
     private static Factory<Boolean> FACTORY = new Factory<Boolean>()
                                             {
 
-                                                public ValueWriter<Boolean> newInstance(Registry registry)
+                                                @Override
+                                                public ValueWriter<Boolean> newInstance(final Registry registry,
+                                                                                        final Boolean object)
                                                 {
-                                                    return new BooleanWriter();
+                                                    return new BooleanWriter(object);
                                                 }
                                             };
 

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/ByteArrayWriter.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/ByteArrayWriter.java?rev=1773584&r1=1773583&r2=1773584&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/ByteArrayWriter.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/ByteArrayWriter.java Sun Dec 11 16:01:06 2016
@@ -24,6 +24,11 @@ package org.apache.qpid.server.protocol.
 public class ByteArrayWriter extends SimpleVariableWidthWriter<byte[]>
 {
 
+    public ByteArrayWriter(final byte[] object)
+    {
+        super(object);
+    }
+
     @Override
     protected byte getFourOctetEncodingCode()
     {
@@ -36,25 +41,14 @@ public class ByteArrayWriter extends Sim
         return (byte)0xa0;
     }
 
-    @Override
-    protected byte[] getByteArray(byte[] value)
-    {
-        return value;
-    }
-
-
-    @Override
-    protected int getOffset()
-    {
-        return 0;
-    }
-
     private static Factory<byte[]> FACTORY = new Factory<byte[]>()
                                             {
 
-                                                public ValueWriter<byte[]> newInstance(Registry registry)
+                                                @Override
+                                                public ValueWriter<byte[]> newInstance(final Registry registry,
+                                                                                       final byte[] object)
                                                 {
-                                                    return new ByteArrayWriter();
+                                                    return new ByteArrayWriter(object);
                                                 }
                                             };
 

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/ByteWriter.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/ByteWriter.java?rev=1773584&r1=1773583&r2=1773584&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/ByteWriter.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/ByteWriter.java Sun Dec 11 16:01:06 2016
@@ -25,61 +25,43 @@ import org.apache.qpid.bytebuffer.QpidBy
 
 public class ByteWriter implements ValueWriter<Byte>
 {
-    private int _written = 2;
     private byte _value;
 
-    public int writeToBuffer(QpidByteBuffer buffer)
+    public ByteWriter()
     {
+    }
 
-        switch(_written)
-        {
-            case 0:
-                if(buffer.hasRemaining())
-                {
-                    buffer.put((byte)0x51);
-                }
-                else
-                {
-                    break;
-                }
-            case 1:
-                if(buffer.hasRemaining())
-                {
-                    buffer.put(_value);
-                    _written = 2;
-                }
-                else
-                {
-                    _written = 1;
-                }
-
-        }
-
-        return 2;
+    public ByteWriter(final Byte object)
+    {
+        setValue(object);
     }
 
-    public void setValue(Byte value)
+    @Override
+    public int getEncodedSize()
     {
-        _written = 0;
-        _value = value.byteValue();
+        return 2;
     }
 
-    public boolean isComplete()
+    public void writeToBuffer(QpidByteBuffer buffer)
     {
-        return _written == 2;
+
+        buffer.put((byte)0x51);
+        buffer.put(_value);
     }
 
-    public boolean isCacheable()
+    public void setValue(Byte value)
     {
-        return true;
+        _value = value.byteValue();
     }
 
     private static Factory<Byte> FACTORY = new Factory<Byte>()
                                             {
 
-                                                public ValueWriter<Byte> newInstance(Registry registry)
+                                                @Override
+                                                public ValueWriter<Byte> newInstance(final Registry registry,
+                                                                                     final Byte object)
                                                 {
-                                                    return new ByteWriter();
+                                                    return new ByteWriter(object);
                                                 }
                                             };
 

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/CharWriter.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/CharWriter.java?rev=1773584&r1=1773583&r2=1773584&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/CharWriter.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/CharWriter.java Sun Dec 11 16:01:06 2016
@@ -25,24 +25,25 @@ public class CharWriter extends FixedFou
 {
     private static final byte FORMAT_CODE = (byte)0x73;
 
-    @Override
-    byte getFormatCode()
+    public CharWriter(final Character object)
     {
-        return FORMAT_CODE;
+        super((int)object.charValue());
     }
 
     @Override
-    int convertValueToInt(Character value)
+    byte getFormatCode()
     {
-        return (int) value.charValue();
+        return FORMAT_CODE;
     }
 
     private static Factory<Character> FACTORY = new Factory<Character>()
                                             {
 
-                                                public ValueWriter<Character> newInstance(Registry registry)
+                                                @Override
+                                                public ValueWriter<Character> newInstance(final Registry registry,
+                                                                                          final Character object)
                                                 {
-                                                    return new CharWriter();
+                                                    return new CharWriter(object);
                                                 }
                                             };
 

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/CompoundWriter.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/CompoundWriter.java?rev=1773584&r1=1773583&r2=1773584&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/CompoundWriter.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/CompoundWriter.java Sun Dec 11 16:01:06 2016
@@ -25,391 +25,101 @@ import org.apache.qpid.bytebuffer.QpidBy
 
 public abstract class CompoundWriter<V> implements ValueWriter<V>
 {
-    private int _length;
+    private int _length = -1;
     private Registry _registry;
-    private static final int LARGE_COMPOUND_THRESHOLD_COUNT = 25;
-    private ValueWriter _delegate;
 
     public CompoundWriter(final Registry registry)
     {
         _registry = registry;
     }
 
-    enum State {
-        FORMAT_CODE,
-        SIZE_0,
-        SIZE_1,
-        SIZE_2,
-        SIZE_3,
-        COUNT_0,
-        COUNT_1,
-        COUNT_2,
-        COUNT_3,
-        DELEGATING,
-        DONE
-    }
-
-    private State _state = State.FORMAT_CODE;
-
-    public int writeToBuffer(QpidByteBuffer buffer)
+    public CompoundWriter(final Registry registry, V object)
     {
-        return writeToBuffer(buffer, false);
+        _registry = registry;
     }
 
-    public int writeToBuffer(QpidByteBuffer buffer, boolean large)
-    {
-        final int length = _length;
 
-        if(length == -1)
+    @Override
+    public int getEncodedSize()
+    {
+        int encodedSize = 1; // byte for the count
+        if(_length == -1)
         {
-            writeFirstPass(buffer, (large || getCount() > LARGE_COMPOUND_THRESHOLD_COUNT) ? 4 : 1);
-            if(_delegate != null && _delegate.isComplete())
+            while (hasNext())
+            {
+                encodedSize += _registry.getValueWriter(next()).getEncodedSize();
+            }
+            if(encodedSize > 255)
             {
-                _delegate = null;
+                encodedSize += 3;  // we'll need four bytes for the count, to match the length
             }
+            _length = encodedSize;
         }
         else
         {
-            //
-
-            final int size = (length & 0xFFFFFF00) == 0 ? 1 : 4;
-            final int count = getCount();
-            final int typeLength = length - (1+size);
-
-            State state = _state;
-
-            switch(state)
-            {
-                case FORMAT_CODE:
-                    if(buffer.hasRemaining())
-                    {
-                        buffer.put(size == 1 ? getSingleOctetEncodingCode(): getFourOctetEncodingCode());
-                        state = State.SIZE_0;
-                    }
-                    else
-                    {
-                        break;
-                    }
-
-                case SIZE_0:
-                    if(size == 4)
-                    {
-                        if(buffer.remaining()>=4)
-                        {
-                            buffer.putInt(typeLength);
-                            state = State.COUNT_0;
-                        }
-                    }
-                    else if(size == 1)
-                    {
-                        if(buffer.hasRemaining())
-                        {
-                            buffer.put((byte)(typeLength));
-                            state = State.COUNT_0;
-                        }
-                        else
-                        {
-                            break;
-                        }
-
-                    }
-                case SIZE_1:
-                case SIZE_2:
-                    if(state != State.COUNT_0 && buffer.remaining() >= 2)
-                    {
-                        buffer.putShort((short)(((typeLength) >> ((3-state.ordinal())<<3)) & 0xFFFF ));
-                        state = (state == State.SIZE_0)
-                                 ? State.SIZE_2
-                                 : (state == State.SIZE_1)
-                                    ? State.SIZE_3
-                                    : State.COUNT_0;
-                    }
-                case SIZE_3:
-                    if(state != State.COUNT_0 && buffer.hasRemaining())
-                    {
-                        buffer.put((byte)(((typeLength) >> ((4-state.ordinal())<<3)) & 0xFF ));
-                        state = (state == State.SIZE_0)
-                                 ? State.SIZE_1
-                                 : (state == State.SIZE_1)
-                                    ? State.SIZE_2
-                                    : (state == State.SIZE_2)
-                                      ? State.SIZE_3
-                                      : State.COUNT_0;
-                    }
-                case COUNT_0:
-                    if(size == 4)
-                    {
-                        if(buffer.remaining()>=4)
-                        {
-                            buffer.putInt(count);
-                            state = State.DELEGATING;
-                        }
-                    }
-                    else if(size == 1)
-                    {
-                        if(buffer.hasRemaining())
-                        {
-                            buffer.put((byte)count);
-                            state = State.DELEGATING;
-                        }
-                        else
-                        {
-                            break;
-                        }
-
-                    }
-
-                case COUNT_1:
-                case COUNT_2:
-                    if(state != State.DELEGATING && buffer.remaining() >= 2)
-                    {
-                        buffer.putShort((short)((count >> ((7-state.ordinal())<<3)) & 0xFFFF ));
-                        state = state == State.COUNT_0
-                                 ? State.COUNT_2
-                                 : state == State.COUNT_1
-                                    ? State.COUNT_3
-                                    : State.DELEGATING;
-                    }
-                case COUNT_3:
-                    if(state != State.DELEGATING && buffer.hasRemaining())
-                    {
-                        buffer.put((byte)((count >> ((8-state.ordinal())<<3)) & 0xFF ));
-                        state = state == State.COUNT_0
-                                 ? State.COUNT_1
-                                 : state == State.COUNT_1
-                                    ? State.COUNT_2
-                                    : state == State.COUNT_2
-                                       ? State.COUNT_3
-                                       : State.DELEGATING;
-                    }
-                case DELEGATING:
-                    while(state == State.DELEGATING && buffer.hasRemaining())
-                    {
-                        if(_delegate == null || _delegate.isComplete())
-                        {
-                            if(hasNext())
-                            {
-                                Object val = next();
-                                _delegate = _registry.getValueWriter(val);
-                            }
-                            else
-                            {
-                                state = State.DONE;
-                                break;
-                            }
-                        }
-                        _delegate.writeToBuffer(buffer);
-                    }
-            }
-
-            _state = state;
-
+            encodedSize = _length;
         }
-
-        return _length;
-    }
-
-    private void writeFirstPass(QpidByteBuffer buffer, int size)
-    {
-
-        State state = State.FORMAT_CODE;
-        int origPosition = buffer.position();
-        int length ;
-
-
-        if(size == 4)
+        if(encodedSize>255)
         {
-            if(buffer.hasRemaining())
-            {
-                buffer.put(getFourOctetEncodingCode());
-
-                // Skip the size - we will come back and patch this
-                if(buffer.remaining() >= 4 )
-                {
-                    buffer.position(buffer.position()+4);
-                    state = State.COUNT_0;
-                }
-                else
-                {
-                    state = State.values()[buffer.remaining()+1];
-                    buffer.position(buffer.limit());
-                }
-
-
-                switch(buffer.remaining())
-                {
-                    case 0:
-                        break;
-                    case 1:
-                        buffer.put((byte)((getCount() >> 24) & 0xFF));
-                        state = State.COUNT_1;
-                        break;
-                    case 2:
-                        buffer.putShort((short)((getCount() >> 16) & 0xFFFF));
-                        state = State.COUNT_2;
-                        break;
-                    case 3:
-                        buffer.putShort((short)((getCount() >> 16) & 0xFFFF));
-                        buffer.put((byte)((getCount() >> 8) & 0xFF));
-                        state = State.COUNT_3;
-                        break;
-                    default:
-                        buffer.putInt(getCount());
-                        state = State.DELEGATING;
-                }
-
-
-
-            }
-            length = 9;
-
-
-
+            encodedSize+=5; // 1 byte constructor, 4 bytes length
         }
         else
         {
-            if(buffer.hasRemaining())
-            {
-                buffer.put(getSingleOctetEncodingCode());
-                if(buffer.hasRemaining())
-                {
-                    // Size - we will come back and patch this
-                    buffer.put((byte) 0);
-
-                    if(buffer.hasRemaining())
-                    {
-                        buffer.put((byte)getCount());
-                        state = State.DELEGATING;
-                    }
-                    else
-                    {
-                        state = State.COUNT_0;
-                    }
-                }
-                else
-                {
-                    state = State.SIZE_0;
-                }
-            }
-            length = 3;
-
+            encodedSize+=2; // 1 byte constructor, 1 byte length
         }
+        return encodedSize;
+    }
 
-
-        int iterPos = -1;
-        for(int i = 0; i < getCount(); i++)
+    @Override
+    public void writeToBuffer(QpidByteBuffer buffer)
+    {
+        if(_length == -1)
         {
-            Object val = next();
-            ValueWriter writer = _registry.getValueWriter(val);
-            if(writer == null)
-            {
-                // TODO
-                System.out.println("no writer for " + val);
-            }
-            length += writer.writeToBuffer(buffer);
-            if(iterPos == -1 && !writer.isComplete())
-            {
-                iterPos = i;
-                _delegate = writer;
-            }
-
-            if(size == 1 && length > 255)
-            {
-                reset();
-                buffer.position(origPosition);
-                writeFirstPass(buffer, 4);
-                return;
-            }
-
+            getEncodedSize();
         }
+        writeToBuffer(buffer, _length>255);
+    }
 
-        // TODO - back-patch size
-        if(buffer.limit() - origPosition >= 2)
-        {
-            buffer.position(origPosition+1);
-            if(size == 1)
-            {
-                buffer.put((byte)((length & 0xFF)-2));
-            }
-            else
-            {
-                switch(buffer.remaining())
-                {
-                    case 1:
-                        buffer.put((byte)(((length-5) >> 24) & 0xFF));
-                        break;
-                    case 2:
-                        buffer.putShort((short)(((length-5) >> 16) & 0xFFFF));
-                        break;
-                    case 3:
-                        buffer.putShort((short)(((length-5) >> 16) & 0xFFFF));
-                        buffer.put((byte)(((length-5) >> 8) & 0xFF));
-                        break;
-                    default:
-                        buffer.putInt(length-5);
-                }
-            }
-        }
+    private void writeToBuffer(QpidByteBuffer buffer, boolean large)
+    {
+        reset();
+        final int count = getCount();
 
-        if(buffer.limit() - origPosition >= length)
+        buffer.put(large ? getFourOctetEncodingCode() : getSingleOctetEncodingCode());
+        if(large)
         {
-            buffer.position(origPosition+length);
-            state = State.DONE;
+            buffer.putInt(_length);
+            buffer.putInt(count);
         }
         else
         {
-            reset();
-            while(iterPos-- >= 0)
-            {
-                next();
-            }
-            buffer.position(buffer.limit());
+            buffer.put((byte) (_length));
+            buffer.put((byte) count);
+        }
+
+        while(hasNext())
+        {
+            Object val = next();
+             _registry.getValueWriter(val).writeToBuffer(buffer);
         }
-        _state = state;
-        _length = length;
+
     }
 
+
     protected abstract byte getFourOctetEncodingCode();
 
     protected abstract byte getSingleOctetEncodingCode();
 
-    public void setValue(V value)
-    {
-        _length = -1;
-        _delegate = null;
-        _state = State.FORMAT_CODE;
-        onSetValue(value);
-    }
-
-    public void setRegistry(Registry registry)
-    {
-        _registry = registry;
-    }
-
     public Registry getRegistry()
     {
         return _registry;
     }
 
-    protected abstract void onSetValue(final V value);
-
     protected abstract int getCount();
 
     protected abstract boolean hasNext();
 
     protected abstract Object next();
 
-    protected abstract void clear();
-
     protected abstract void reset();
-
-    public boolean isCacheable()
-    {
-        return false;
-    }
-
-    public boolean isComplete()
-    {
-        return _state == State.DONE;
-    }
 }

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/DelegatingValueWriter.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/DelegatingValueWriter.java?rev=1773584&r1=1773583&r2=1773584&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/DelegatingValueWriter.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/DelegatingValueWriter.java Sun Dec 11 16:01:06 2016
@@ -33,20 +33,27 @@ public abstract class DelegatingValueWri
         _registry = registry;
     }
 
-    public int writeToBuffer(final QpidByteBuffer buffer)
+    protected DelegatingValueWriter(final Registry registry, V object)
     {
-        return _delegate.writeToBuffer(buffer);
+        _registry = registry;
+        setValue(object);
     }
 
-    public void setValue(final V frameBody)
+    public void writeToBuffer(final QpidByteBuffer buffer)
     {
-        _delegate = _registry.getValueWriter(getUnderlyingValue(frameBody));
+        _delegate.writeToBuffer(buffer);
     }
 
-    protected abstract Object getUnderlyingValue(final V frameBody);
+    @Override
+    public int getEncodedSize()
+    {
+        return _delegate.getEncodedSize();
+    }
 
-    public boolean isComplete()
+    public void setValue(final V frameBody)
     {
-        return _delegate.isComplete();
+        _delegate = _registry.getValueWriter(getUnderlyingValue(frameBody));
     }
+
+    protected abstract Object getUnderlyingValue(final V frameBody);
 }

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/DoubleWriter.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/DoubleWriter.java?rev=1773584&r1=1773583&r2=1773584&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/DoubleWriter.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/DoubleWriter.java Sun Dec 11 16:01:06 2016
@@ -25,25 +25,25 @@ public class DoubleWriter extends FixedE
 {
     private static final byte FORMAT_CODE = (byte) 0x82;
 
-
-    @Override
-    byte getFormatCode()
+    public DoubleWriter(final Double object)
     {
-        return FORMAT_CODE;
+        super(Double.doubleToLongBits(object.doubleValue()));
     }
 
     @Override
-    long convertValueToLong(Double value)
+    byte getFormatCode()
     {
-        return Double.doubleToLongBits(value.doubleValue());
+        return FORMAT_CODE;
     }
 
     private static Factory<Double> FACTORY = new Factory<Double>()
                                             {
 
-                                                public ValueWriter<Double> newInstance(Registry registry)
+                                                @Override
+                                                public ValueWriter<Double> newInstance(final Registry registry,
+                                                                                       final Double object)
                                                 {
-                                                    return new DoubleWriter();
+                                                    return new DoubleWriter(object);
                                                 }
                                             };
 

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/FixedEightWriter.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/FixedEightWriter.java?rev=1773584&r1=1773583&r2=1773584&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/FixedEightWriter.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/FixedEightWriter.java Sun Dec 11 16:01:06 2016
@@ -25,84 +25,24 @@ import org.apache.qpid.bytebuffer.QpidBy
 
 public abstract class FixedEightWriter<T extends Object> implements ValueWriter<T>
 {
-    private int _written = 9;
     private long _value;
 
-    public final int writeToBuffer(QpidByteBuffer buffer)
+    public FixedEightWriter(long value)
     {
-        int remaining = buffer.remaining();
-        int written = _written;
-        switch(written)
-        {
-            case 0:
-                if(buffer.hasRemaining())
-                {
-                    buffer.put(getFormatCode());
-                    remaining--;
-                    written = 1;
-                }
-                else
-                {
-                    break;
-                }
-            case 1:
-                if(remaining>=8)
-                {
-                    buffer.putLong(_value);
-                    written = 9;
-                    break;
-                }
-            case 2:
-            case 3:
-            case 4:
-            case 5:
-                if(remaining >= 4)
-                {
-                    buffer.putInt((int)((_value >> ((5-written)<<3)) & 0xFFFFFFFF ));
-                    remaining-=4;
-                    written+=4;
-                }
-            case 6:
-            case 7:
-                if(remaining >= 2 && written <= 7)
-                {
-                    buffer.putShort((short)((_value >> ((7-written)<<3)) & 0xFFFF ));
-                    remaining -= 2;
-                    written += 2;
-                }
-            case 8:
-                if(remaining >=1 && written != 9)
-                {
-                    buffer.put((byte)((_value >> ((8-written)<<3)) & 0xFF ));
-                    written++;
-                }
-
-
-        }
-        _written = written;
-
-        return 9;
+        _value = value;
     }
 
-    abstract byte getFormatCode();
-
-    public final void setValue(T value)
+    public final void writeToBuffer(QpidByteBuffer buffer)
     {
-        _written = 0;
-        _value = convertValueToLong(value);
+        buffer.put(getFormatCode());
+        buffer.putLong(_value);
     }
 
-    abstract long convertValueToLong(T value);
-
-    public boolean isCacheable()
+    @Override
+    public int getEncodedSize()
     {
-        return true;
-    }
-
-    public final boolean isComplete()
-    {
-        return _written == 9;
+        return 9;
     }
 
-
+    abstract byte getFormatCode();
 }

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/FixedFourWriter.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/FixedFourWriter.java?rev=1773584&r1=1773583&r2=1773584&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/FixedFourWriter.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/FixedFourWriter.java Sun Dec 11 16:01:06 2016
@@ -25,98 +25,25 @@ import org.apache.qpid.bytebuffer.QpidBy
 
 public abstract class FixedFourWriter<T extends Object> implements ValueWriter<T>
 {
-    private int _written = 5;
     private int _value;
 
-    public final int writeToBuffer(QpidByteBuffer buffer)
-    {
-        int remaining = buffer.remaining();
-        int written = _written;
-        switch(written)
-        {
-            case 0:
-                if(remaining-- != 0)
-                {
-                    buffer.put(getFormatCode());
-                    written = 1;
-                }
-                else
-                {
-                    break;
-                }
-            case 1:
-                if(remaining>=4)
-                {
-                    buffer.putInt(_value);
-                    written = 5;
-                    break;
-                }
-                else if(remaining-- != 0)
-                {
-                    buffer.put((byte)((_value >> 24)&0xFF));
-                    written = 2;
-                }
-                else
-                {
-                    break;
-                }
-            case 2:
-                if(remaining-- != 0)
-                {
-                    buffer.put((byte)((_value >> 16)&0xFF));
-                    written = 3;
-                }
-                else
-                {
-                    break;
-                }
-            case 3:
-                if(remaining-- != 0)
-                {
-                    buffer.put((byte)((_value >> 8)&0xFF));
-                    written = 4;
-                }
-                else
-                {
-                    break;
-                }
-            case 4:
-                if(remaining-- != 0)
-                {
-                    buffer.put((byte)(_value&0xFF));
-                    written = 5;
-                }
-
-        }
-        _written = written;
-
-        return 5;
-    }
 
-    abstract byte getFormatCode();
-
-    public final void setValue(T value)
+    public FixedFourWriter(int object)
     {
-        if(_written==1)
-        {
-            // TODO - remove
-            System.out.println("Remove");
-        }
-        _written = 0;
-        _value = convertValueToInt(value);
+        _value = object;
     }
 
-    abstract int convertValueToInt(T value);
-
-    public boolean isCacheable()
+    public final void writeToBuffer(QpidByteBuffer buffer)
     {
-        return true;
+        buffer.put(getFormatCode());
+        buffer.putInt(_value);
     }
 
-    public final boolean isComplete()
+    @Override
+    public int getEncodedSize()
     {
-        return _written == 5;
+        return 5;
     }
 
-
+    abstract byte getFormatCode();
 }

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/FixedOneWriter.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/FixedOneWriter.java?rev=1773584&r1=1773583&r2=1773584&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/FixedOneWriter.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/FixedOneWriter.java Sun Dec 11 16:01:06 2016
@@ -24,56 +24,24 @@ import org.apache.qpid.bytebuffer.QpidBy
 
 public abstract class FixedOneWriter<T> implements ValueWriter<T>
 {
-    protected int _written = 2;
-    protected byte _value;
+    protected final byte _value;
 
-    public int writeToBuffer(QpidByteBuffer buffer)
+    public FixedOneWriter(final byte value)
     {
-
-        switch(_written)
-        {
-            case 0:
-                if(buffer.hasRemaining())
-                {
-                    buffer.put(getFormatCode());
-                }
-                else
-                {
-                    break;
-                }
-            case 1:
-                if(buffer.hasRemaining())
-                {
-                    buffer.put(_value);
-                    _written = 2;
-                }
-                else
-                {
-                    _written = 1;
-                }
-
-        }
-
-        return 2;
+        _value = value;
     }
 
-    protected abstract byte getFormatCode();
-
-    public boolean isComplete()
+    public void writeToBuffer(QpidByteBuffer buffer)
     {
-        return _written == 2;
+        buffer.put(getFormatCode());
+        buffer.put(_value);
     }
 
-    public boolean isCacheable()
+    @Override
+    public int getEncodedSize()
     {
-        return true;
-    }
-
-    public void setValue(final T value)
-    {
-        _written = 0;
-        _value = convertToByte(value);
+        return 2;
     }
 
-    protected abstract byte convertToByte(final T value);
+    protected abstract byte getFormatCode();
 }

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/FixedSixteenWriter.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/FixedSixteenWriter.java?rev=1773584&r1=1773583&r2=1773584&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/FixedSixteenWriter.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/FixedSixteenWriter.java Sun Dec 11 16:01:06 2016
@@ -25,102 +25,30 @@ import org.apache.qpid.bytebuffer.QpidBy
 
 public abstract class FixedSixteenWriter<T extends Object> implements ValueWriter<T>
 {
-    private int _written = 17;
     private long _msb;
     private long _lsb;
 
-    public final int writeToBuffer(QpidByteBuffer buffer)
+    public FixedSixteenWriter()
     {
-        int remaining = buffer.remaining();
-        int written = _written;
-        switch(written)
-        {
-            case 0:
-                if(buffer.hasRemaining())
-                {
-                    buffer.put(getFormatCode());
-                    remaining--;
-                    written = 1;
-                }
-                else
-                {
-                    break;
-                }
-            case 1:
-                if(remaining>=8)
-                {
-                    buffer.putLong(_msb);
-                    written = 9;
-                    break;
-                }
-            case 2:
-            case 3:
-            case 4:
-            case 5:
-                if(remaining >= 4)
-                {
-                    buffer.putInt((int)((_msb >> ((5-written)<<3)) & 0xFFFFFFFF ));
-                    remaining-=4;
-                    written+=4;
-                }
-            case 6:
-            case 7:
-                if(remaining >= 2 && written <= 7)
-                {
-                    buffer.putShort((short)((_msb >> ((7-written)<<3)) & 0xFFFF ));
-                    remaining -= 2;
-                    written += 2;
-                }
-            case 8:
-                if(remaining >=1 && written != 9)
-                {
-                    buffer.put((byte)((_msb >> ((8-written)<<3)) & 0xFF ));
-                    written++;
-                }
-
-
-        }
-        if(remaining != 0)
-        {
-            switch(written)
-            {
-                case 9:
-                    if(remaining>=8)
-                    {
-                        buffer.putLong(_lsb);
-                        written = 17;
-                        break;
-                    }
-                case 10:
-                case 11:
-                case 12:
-                case 13:
-                    if(remaining >= 4)
-                    {
-                        buffer.putInt((int)((_lsb >> ((13-written)<<3)) & 0xFFFFFFFF ));
-                        remaining-=4;
-                        written+=4;
-                    }
-                case 14:
-                case 15:
-                    if(remaining >= 2 && written <= 15)
-                    {
-                        buffer.putShort((short)((_lsb >> ((15-written)<<3)) & 0xFFFF ));
-                        remaining -= 2;
-                        written += 2;
-                    }
-                case 16:
-                    if(remaining >=1 && written != 17)
-                    {
-                        buffer.put((byte)((_msb >> ((16-written)<<3)) & 0xFF ));
-                        written++;
-                    }
-            }
+    }
+
+    public FixedSixteenWriter(T object)
+    {
+        setValue(object);
+    }
 
-        }
 
-        _written = written;
 
+    public final void writeToBuffer(QpidByteBuffer buffer)
+    {
+        buffer.put(getFormatCode());
+        buffer.putLong(_msb);
+        buffer.putLong(_lsb);
+    }
+
+    @Override
+    public int getEncodedSize()
+    {
         return 17;
     }
 
@@ -128,23 +56,10 @@ public abstract class FixedSixteenWriter
 
     public final void setValue(T value)
     {
-        _written = 0;
         _msb = convertValueToMSB(value);
         _lsb = convertValueToLSB(value);
     }
 
     abstract long convertValueToMSB(T value);
     abstract long convertValueToLSB(T value);
-
-    public boolean isCacheable()
-    {
-        return true;
-    }
-
-    public final boolean isComplete()
-    {
-        return _written == 17;
-    }
-
-
 }

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/FixedTwoWriter.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/FixedTwoWriter.java?rev=1773584&r1=1773583&r2=1773584&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/FixedTwoWriter.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/FixedTwoWriter.java Sun Dec 11 16:01:06 2016
@@ -25,71 +25,36 @@ import org.apache.qpid.bytebuffer.QpidBy
 
 public abstract class FixedTwoWriter <T extends Object> implements ValueWriter<T>
 {
-    private int _written = 3;
     private short _value;
 
-    public int writeToBuffer(QpidByteBuffer buffer)
+    public FixedTwoWriter()
     {
+    }
 
-        switch(_written)
-        {
-            case 0:
-                if(buffer.hasRemaining())
-                {
-                    buffer.put(getFormatCode());
-                }
-                else
-                {
-                    break;
-                }
-            case 1:
-
-                if(buffer.remaining()>1)
-                {
-                    buffer.putShort(_value);
-                    _written = 3;
-                }
-                else if(buffer.hasRemaining())
-                {
-                    buffer.put((byte) (0xFF & (_value >> 8)));
-                    _written = 2;
-                }
-                else
-                {
-                    _written = 1;
-                }
-                break;
-            case 2:
-                if(buffer.hasRemaining())
-                {
-                    buffer.put((byte)(0xFF & _value));
-                }
-
+    public FixedTwoWriter(T object)
+    {
+        setValue(object);
+    }
 
-        }
+    public void writeToBuffer(QpidByteBuffer buffer)
+    {
+        buffer.put(getFormatCode());
+        buffer.putShort(_value);
+    }
 
+    @Override
+    public int getEncodedSize()
+    {
         return 3;
     }
 
-
     public final void setValue(T value)
     {
-        _written = 0;
         _value = convertValueToShort(value);
     }
 
     abstract short convertValueToShort(T value);
 
-    public boolean isCacheable()
-    {
-        return true;
-    }
-
-    public boolean isComplete()
-    {
-        return _written == 3;
-    }
-
     abstract byte getFormatCode();
 
 

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/FloatWriter.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/FloatWriter.java?rev=1773584&r1=1773583&r2=1773584&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/FloatWriter.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/FloatWriter.java Sun Dec 11 16:01:06 2016
@@ -26,24 +26,25 @@ public class FloatWriter extends FixedFo
     private static final byte FORMAT_CODE = (byte)0x72;
 
 
-    @Override
-    byte getFormatCode()
+    public FloatWriter(final Float object)
     {
-        return FORMAT_CODE;
+        super(Float.floatToIntBits(object));
     }
 
     @Override
-    int convertValueToInt(Float value)
+    byte getFormatCode()
     {
-        return Float.floatToIntBits(value.floatValue());
+        return FORMAT_CODE;
     }
 
     private static Factory<Float> FACTORY = new Factory<Float>()
                                             {
 
-                                                public ValueWriter<Float> newInstance(Registry registry)
+                                                @Override
+                                                public ValueWriter<Float> newInstance(final Registry registry,
+                                                                                      final Float object)
                                                 {
-                                                    return new FloatWriter();
+                                                    return new FloatWriter(object);
                                                 }
                                             };
 

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/FrameWriter.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/FrameWriter.java?rev=1773584&r1=1773583&r2=1773584&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/FrameWriter.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/FrameWriter.java Sun Dec 11 16:01:06 2016
@@ -54,9 +54,7 @@ public class FrameWriter
         }
         else
         {
-            typeWriter.setValue(frame.getFrameBody());
-            QpidByteBuffer qpidByteBuffer = QpidByteBuffer.wrap(EMPTY_BYTE_ARRAY);
-            bodySize = typeWriter.writeToBuffer(qpidByteBuffer) + 8;
+            bodySize = 8 + typeWriter.getEncodedSize();
         }
 
         QpidByteBuffer body = QpidByteBuffer.allocate(_sender.isDirectBufferPreferred(), bodySize);

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/IntegerWriter.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/IntegerWriter.java?rev=1773584&r1=1773583&r2=1773584&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/IntegerWriter.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/IntegerWriter.java Sun Dec 11 16:01:06 2016
@@ -21,86 +21,60 @@
 
 package org.apache.qpid.server.protocol.v1_0.codec;
 
-import org.apache.qpid.bytebuffer.QpidByteBuffer;
-
-public class IntegerWriter implements ValueWriter<Integer>
+public class IntegerWriter
 {
     private static final byte EIGHT_BYTE_FORMAT_CODE = (byte)0x71;
     private static final byte ONE_BYTE_FORMAT_CODE = (byte) 0x54;
 
-    private ValueWriter<Integer> _delegate;
-
-    private final FixedFourWriter<Integer> _eightByteWriter = new FixedFourWriter<Integer>()
-    {
-
-        @Override
-        byte getFormatCode()
-        {
-            return EIGHT_BYTE_FORMAT_CODE;
-        }
+    private static ValueWriter.Factory<Integer> FACTORY = new ValueWriter.Factory<Integer>()
+                                            {
 
-        @Override
-        int convertValueToInt(Integer value)
-        {
-            return value.intValue();
-        }
-    };
+                                                @Override
+                                                public ValueWriter<Integer> newInstance(final ValueWriter.Registry registry,
+                                                                                        final Integer i)
+                                                {
+                                                    if(i >= -128 && i <= 127)
+                                                    {
+                                                        return new IntegerFixedOneWriter(i);
+                                                    }
+                                                    else
+                                                    {
+                                                        return new IntegerFixedFourWriter(i);
+                                                    }
+                                                }
+                                            };
 
-    private final ValueWriter<Integer> _oneByteWriter = new FixedOneWriter<Integer>()
+    public static void register(ValueWriter.Registry registry)
     {
+        registry.register(Integer.class, FACTORY);
+    }
 
-        @Override protected byte getFormatCode()
+    private static class IntegerFixedFourWriter extends FixedFourWriter<Integer>
+    {
+        public IntegerFixedFourWriter(final Integer object)
         {
-            return ONE_BYTE_FORMAT_CODE;
+            super(object);
         }
 
-        @Override protected byte convertToByte(final Integer value)
+        @Override
+        byte getFormatCode()
         {
-            return value.byteValue();
+            return EIGHT_BYTE_FORMAT_CODE;
         }
-    };
 
-
-    public int writeToBuffer(final QpidByteBuffer buffer)
-    {
-        return _delegate.writeToBuffer(buffer);
     }
 
-    public void setValue(final Integer i)
+    private static class IntegerFixedOneWriter extends FixedOneWriter<Integer>
     {
-        if(i >= -128 && i <= 127)
+
+        public IntegerFixedOneWriter(final Integer value)
         {
-            _delegate = _oneByteWriter;
+            super(value.byteValue());
         }
-        else
+
+        @Override protected byte getFormatCode()
         {
-            _delegate = _eightByteWriter;
+            return ONE_BYTE_FORMAT_CODE;
         }
-        _delegate.setValue(i);
-    }
-
-    public boolean isComplete()
-    {
-        return _delegate.isComplete();
-    }
-
-    public boolean isCacheable()
-    {
-        return false;
-    }
-
-
-    private static Factory<Integer> FACTORY = new Factory<Integer>()
-                                            {
-
-                                                public ValueWriter<Integer> newInstance(Registry registry)
-                                                {
-                                                    return new IntegerWriter();
-                                                }
-                                            };
-
-    public static void register(ValueWriter.Registry registry)
-    {
-        registry.register(Integer.class, FACTORY);
     }
 }

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/ListWriter.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/ListWriter.java?rev=1773584&r1=1773583&r2=1773584&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/ListWriter.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/ListWriter.java Sun Dec 11 16:01:06 2016
@@ -25,24 +25,17 @@ import java.util.List;
 
 import org.apache.qpid.bytebuffer.QpidByteBuffer;
 
-public class ListWriter implements ValueWriter<List>
+public class ListWriter
 {
     private static class NonEmptyListWriter extends AbstractListWriter<List>
     {
         private List _list;
         private int _position = 0;
 
-        public NonEmptyListWriter(final Registry registry)
+        public NonEmptyListWriter(final Registry registry, final List object)
         {
-            super(registry);
-        }
-
-        @Override
-        protected void onSetValue(final List value)
-        {
-            _list = value;
-            _position = 0;
-
+            super(registry, object);
+            _list = object;
         }
 
         @Override
@@ -64,13 +57,6 @@ public class ListWriter implements Value
         }
 
         @Override
-        protected void clear()
-        {
-            _list = null;
-            _position = 0;
-        }
-
-        @Override
         protected void reset()
         {
             _position = 0;
@@ -78,96 +64,40 @@ public class ListWriter implements Value
 
     }
 
-    private final NonEmptyListWriter _nonEmptyListWriter;
     private static final byte ZERO_BYTE_FORMAT_CODE = (byte) 0x45;
 
-    private final ValueWriter<List> _emptyListWriter = new EmptyListValueWriter();
+    public static final ValueWriter<List> EMPTY_LIST_WRITER = new EmptyListValueWriter();
 
-
-    private ValueWriter<List> _delegate;
-
-    public ListWriter(final Registry registry)
-    {
-        _nonEmptyListWriter = new NonEmptyListWriter(registry);
-
-    }
-
-
-    public int writeToBuffer(QpidByteBuffer buffer)
+    public static class EmptyListValueWriter implements ValueWriter<List>
     {
-        return _delegate.writeToBuffer(buffer);
-    }
 
-    public void setValue(List frameBody)
-    {
-        if(frameBody.isEmpty())
+        @Override
+        public int getEncodedSize()
         {
-            _delegate = _emptyListWriter;
+            return 1;
         }
-        else
+
+        public void writeToBuffer(QpidByteBuffer buffer)
         {
-            _delegate = _nonEmptyListWriter;
+            buffer.put(ZERO_BYTE_FORMAT_CODE);
         }
-        _delegate.setValue(frameBody);
-    }
-
-    public boolean isComplete()
-    {
-        return _delegate.isComplete();
     }
 
-    public boolean isCacheable()
-    {
-        return false;
-    }
-
-
-
-    private static Factory<List> FACTORY = new Factory<List>()
-                                            {
+    private static ValueWriter.Factory<List> FACTORY =
+            new ValueWriter.Factory<List>()
+            {
 
-                                                public ValueWriter<List> newInstance(Registry registry)
-                                                {
-                                                    return new ListWriter(registry);
-                                                }
-                                            };
+                @Override
+                public ValueWriter<List> newInstance(final ValueWriter.Registry registry,
+                                                     final List object)
+                {
+                    return object.isEmpty() ? EMPTY_LIST_WRITER : new NonEmptyListWriter(registry, object);
+                }
+            };
 
     public static void register(ValueWriter.Registry registry)
     {
         registry.register(List.class, FACTORY);
     }
 
-    public static class EmptyListValueWriter implements ValueWriter<List>
-    {
-        private boolean _complete;
-
-
-        public int writeToBuffer(QpidByteBuffer buffer)
-        {
-
-            if(!_complete && buffer.hasRemaining())
-            {
-                buffer.put(ZERO_BYTE_FORMAT_CODE);
-                _complete = true;
-            }
-
-            return 1;
-        }
-
-        public void setValue(List list)
-        {
-            _complete = false;
-        }
-
-        public boolean isCacheable()
-        {
-            return true;
-        }
-
-        public boolean isComplete()
-        {
-            return _complete;
-        }
-
-    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message