qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgodf...@apache.org
Subject svn commit: r1773584 [2/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
Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/LongWriter.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/LongWriter.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/LongWriter.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/LongWriter.java Sun Dec 11 16:01:06 2016
@@ -21,91 +21,60 @@
 
 package org.apache.qpid.server.protocol.v1_0.codec;
 
-import org.apache.qpid.bytebuffer.QpidByteBuffer;
-
-public class LongWriter implements ValueWriter<Long>
+public class LongWriter
 {
     private static final byte EIGHT_BYTE_FORMAT_CODE = (byte) 0x81;
 
 
     private static final byte ONE_BYTE_FORMAT_CODE = (byte) 0x55;
 
-    private ValueWriter<Long> _delegate;
+    private static ValueWriter.Factory<Long> FACTORY =
+            new ValueWriter.Factory<Long>()
+            {
+                @Override
+                public ValueWriter<Long> newInstance(final ValueWriter.Registry registry,
+                                                     final Long l)
+                {
+                    if (l >= -128 && l <= 127)
+                    {
+                        return new LongFixedOneWriter(l);
+                    }
+                    else
+                    {
+                        return new LongFixedEightWriter(l);
+                    }
+                }
+            };
 
-    private final FixedEightWriter<Long> _eightByteWriter = new FixedEightWriter<Long>()
+    public static void register(ValueWriter.Registry registry)
     {
+        registry.register(Long.class, FACTORY);
+    }
 
-        @Override
-        byte getFormatCode()
-        {
-            return EIGHT_BYTE_FORMAT_CODE;
-        }
-
-        @Override
-        long convertValueToLong(Long value)
-        {
-            return value;
-        }
-
-    };
-
-    private final ValueWriter<Long> _oneByteWriter = new FixedOneWriter<Long>()
+    private static class LongFixedEightWriter extends FixedEightWriter<Long>
     {
-
-        @Override protected byte getFormatCode()
+        public LongFixedEightWriter(final Long object)
         {
-            return ONE_BYTE_FORMAT_CODE;
+            super(object);
         }
 
-        @Override protected byte convertToByte(final Long 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 Long l)
+    private static class LongFixedOneWriter extends FixedOneWriter<Long>
     {
-        if(l >= -128 && l <= 127)
+        public LongFixedOneWriter(final Long value)
         {
-            _delegate = _oneByteWriter;
+            super(value.byteValue());
         }
-        else
+
+        @Override protected byte getFormatCode()
         {
-            _delegate = _eightByteWriter;
+            return ONE_BYTE_FORMAT_CODE;
         }
-        _delegate.setValue(l);
     }
-
-    public boolean isComplete()
-    {
-        return _delegate.isComplete();
-    }
-
-    public boolean isCacheable()
-    {
-        return false;
-    }
-
-
-
-
-    private static Factory<Long> FACTORY = new Factory<Long>()
-                                            {
-
-                                                public ValueWriter<Long> newInstance(Registry registry)
-                                                {
-                                                    return new LongWriter();
-                                                }
-                                            };
-
-    public static void register(ValueWriter.Registry registry)
-    {
-        registry.register(Long.class, FACTORY);
-    }
-
 }

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/MapWriter.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/MapWriter.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/MapWriter.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/MapWriter.java Sun Dec 11 16:01:06 2016
@@ -30,18 +30,15 @@ public class MapWriter extends AbstractM
     private Object _value;
     private Iterator<Map.Entry> _iterator;
 
-    public MapWriter(final Registry registry)
-    {
-        super(registry);
-    }
 
-    @Override
-    protected void onSetValue(final Map value)
+    private MapWriter(final Registry registry, final Map object)
     {
-        _map = value;
-        _iterator = value.entrySet().iterator();
+        super(registry, object);
+        _map = object;
+        _iterator = object.entrySet().iterator();
     }
 
+
     @Override
     protected int getMapCount()
     {
@@ -71,14 +68,6 @@ public class MapWriter extends AbstractM
 
 
     @Override
-    protected void onClear()
-    {
-        _map = null;
-        _iterator = null;
-        _value = null;
-    }
-
-    @Override
     protected void onReset()
     {
         _iterator = _map.entrySet().iterator();
@@ -89,9 +78,11 @@ public class MapWriter extends AbstractM
     private static Factory<Map> FACTORY = new Factory<Map>()
                                             {
 
-                                                public ValueWriter<Map> newInstance(Registry registry)
+                                                @Override
+                                                public ValueWriter<Map> newInstance(final Registry registry,
+                                                                                    final Map object)
                                                 {
-                                                    return new MapWriter(registry);
+                                                    return new MapWriter(registry, object);
                                                 }
                                             };
 

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/NullWriter.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/NullWriter.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/NullWriter.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/NullWriter.java Sun Dec 11 16:01:06 2016
@@ -25,41 +25,28 @@ import org.apache.qpid.bytebuffer.QpidBy
 
 public class NullWriter implements ValueWriter<Void>
 {
-    private boolean _complete = true;
+    private static final NullWriter INSTANCE = new NullWriter();
 
-    public int writeToBuffer(QpidByteBuffer buffer)
+    @Override
+    public int getEncodedSize()
     {
-
-        if(!_complete && buffer.hasRemaining())
-        {
-            buffer.put((byte)0x40);
-            _complete = true;
-        }
-
         return 1;
     }
 
-    public void setValue(Void frameBody)
+    public void writeToBuffer(QpidByteBuffer buffer)
     {
-        _complete = false;
-    }
 
-    public boolean isCacheable()
-    {
-        return true;
-    }
-
-    public boolean isComplete()
-    {
-        return _complete;
+        buffer.put((byte)0x40);
     }
 
     private static Factory<Void> FACTORY = new Factory<Void>()
                                             {
 
-                                                public ValueWriter<Void> newInstance(Registry registry)
+                                                @Override
+                                                public ValueWriter<Void> newInstance(final Registry registry,
+                                                                                     final Void object)
                                                 {
-                                                    return new NullWriter();
+                                                    return INSTANCE;
                                                 }
                                             };
 

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/RestrictedTypeValueWriter.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/RestrictedTypeValueWriter.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/RestrictedTypeValueWriter.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/RestrictedTypeValueWriter.java Sun Dec 11 16:01:06 2016
@@ -29,6 +29,12 @@ public class RestrictedTypeValueWriter<V
         super(registry);
     }
 
+    public RestrictedTypeValueWriter(final Registry registry,
+                                     final RestrictedType<V> object)
+    {
+        super(registry, object);
+    }
+
     @Override
     protected Object getUnderlyingValue(final RestrictedType<V> restrictedType)
     {
@@ -38,17 +44,13 @@ public class RestrictedTypeValueWriter<V
     private static Factory FACTORY = new Factory()
     {
 
-        public ValueWriter newInstance(Registry registry)
+        @Override
+        public ValueWriter newInstance(final Registry registry, final Object object)
         {
-            return new RestrictedTypeValueWriter(registry);
+            return new RestrictedTypeValueWriter(registry, (RestrictedType) object);
         }
     };
 
-    public boolean isCacheable()
-    {
-        return true;
-    }
-
     public static void register(ValueWriter.Registry registry, Class clazz)
     {
         registry.register(clazz, FACTORY);

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/ShortWriter.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/ShortWriter.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/ShortWriter.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/ShortWriter.java Sun Dec 11 16:01:06 2016
@@ -26,6 +26,15 @@ public class ShortWriter extends FixedTw
 
     private static final byte FORMAT_CODE = (byte)0x61;
 
+    public ShortWriter()
+    {
+    }
+
+    public ShortWriter(Short object)
+    {
+        setValue(object);
+    }
+
 
     @Override
     short convertValueToShort(Short value)
@@ -42,9 +51,11 @@ public class ShortWriter extends FixedTw
     private static Factory<Short> FACTORY = new Factory<Short>()
                                             {
 
-                                                public ValueWriter<Short> newInstance(Registry registry)
+                                                @Override
+                                                public ValueWriter<Short> newInstance(final Registry registry,
+                                                                                      final Short object)
                                                 {
-                                                    return new ShortWriter();
+                                                    return new ShortWriter(object);
                                                 }
                                             };
 

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/SimpleVariableWidthWriter.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/SimpleVariableWidthWriter.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/SimpleVariableWidthWriter.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/SimpleVariableWidthWriter.java Sun Dec 11 16:01:06 2016
@@ -27,42 +27,15 @@ public abstract class SimpleVariableWidt
 {
     private byte[] _buf;
 
-
-    public void setValue(V value)
-    {
-        _buf = getByteArray(value);
-        super.setValue(value);
-    }
-
-    protected int getLength()
+    public SimpleVariableWidthWriter(byte[] value)
     {
-        return _buf.length;
+        super(value.length);
+        _buf = value;
     }
 
-    protected void writeBytes(QpidByteBuffer buf, int offset, int length)
+    protected final void writeBytes(QpidByteBuffer buf, int offset, int length)
     {
-        buf.put(_buf, getOffset()+offset, length);
+        buf.put(_buf, offset, length);
     }
 
-    @Override
-    protected void clearValue()
-    {
-        _buf = null;
-    }
-
-    @Override
-    protected boolean hasValue()
-    {
-        return _buf != null;
-    }
-
-    public boolean isCacheable()
-    {
-        return true;
-    }
-
-    protected abstract byte[] getByteArray(V value);
-
-    protected abstract int getOffset();
-
 }

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/StringWriter.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/StringWriter.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/StringWriter.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/StringWriter.java Sun Dec 11 16:01:06 2016
@@ -21,11 +21,8 @@
 
 package org.apache.qpid.server.protocol.v1_0.codec;
 
-import java.nio.ByteBuffer;
 import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
-import java.util.LinkedHashMap;
-import java.util.Map;
 
 public class StringWriter extends SimpleVariableWidthWriter<String>
 {
@@ -49,30 +46,11 @@ public class StringWriter extends Simple
         }
     }
 
-    private static final class ValueCache<K,V> extends LinkedHashMap<K,V>
+    public StringWriter(final String value)
     {
-        private final int _cacheSize;
-
-        public ValueCache(int cacheSize)
-        {
-            _cacheSize = cacheSize;
-        }
-
-        @Override
-        protected boolean removeEldestEntry(Map.Entry<K, V> eldest)
-        {
-            return size() > _cacheSize;
-        }
-
-        public boolean isFull()
-        {
-            return size() == _cacheSize;
-        }
+        super(value.getBytes(ENCODING_CHARSET));
     }
 
-    private final ValueCache<String, byte[]> _cachedEncodings = new ValueCache<String, byte[]>(10);
-
-
     @Override
     protected byte getFourOctetEncodingCode()
     {
@@ -85,58 +63,15 @@ public class StringWriter extends Simple
         return ONE_BYTE_CODE;
     }
 
-    @Override
-    protected byte[] getByteArray(String value)
-    {
-
-        byte[] encoding;
-        boolean isFull = _cachedEncodings.isFull();
-        if(isFull)
-        {
-            encoding = _cachedEncodings.remove(value);
-        }
-        else
-        {
-            encoding = _cachedEncodings.get(value);
-        }
-
-
-        if(encoding == null)
-        {
-            ByteBuffer buf = ENCODING_CHARSET.encode(value);
-            if(buf.hasArray() && buf.arrayOffset() == 0 && buf.limit()==buf.capacity())
-            {
-                encoding = buf.array();
-            }
-            else
-            {
-                byte[] bufArray = new byte[buf.limit()-buf.position()];
-                buf.get(bufArray);
-                encoding = bufArray;
-            }
-            _cachedEncodings.put(value,encoding);
-
-        }
-        else if(isFull)
-        {
-            _cachedEncodings.put(value,encoding);
-        }
-
-        return encoding;
-    }
-
-    @Override
-    protected int getOffset()
-    {
-        return 0;
-    }
 
     private static Factory<String> FACTORY = new Factory<String>()
                                             {
 
-                                                public ValueWriter<String> newInstance(Registry registry)
+                                                @Override
+                                                public ValueWriter<String> newInstance(final Registry registry,
+                                                                                       final String object)
                                                 {
-                                                    return new StringWriter();
+                                                    return new StringWriter(object);
                                                 }
                                             };
 

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/SymbolArrayWriter.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/SymbolArrayWriter.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/SymbolArrayWriter.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/SymbolArrayWriter.java Sun Dec 11 16:01:06 2016
@@ -19,75 +19,52 @@
 
 package org.apache.qpid.server.protocol.v1_0.codec;
 
-import org.apache.qpid.server.protocol.v1_0.type.Symbol;
-import org.apache.qpid.bytebuffer.QpidByteBuffer;
-
 import java.nio.ByteBuffer;
 
-public class SymbolArrayWriter extends VariableWidthWriter<Symbol[]>
-{
-
-    private int _length;
-    private byte[] _encodedVal;
-
-    @Override protected void clearValue()
-    {
-        _encodedVal = null;
-    }
+import org.apache.qpid.server.protocol.v1_0.type.Symbol;
 
-    @Override protected boolean hasValue()
+public class SymbolArrayWriter extends SimpleVariableWidthWriter<Symbol[]>
+{
+    private SymbolArrayWriter(final Symbol[] object)
     {
-        return _encodedVal != null;
+        super(getEncodedValue(object));
     }
 
-    @Override protected byte getFourOctetEncodingCode()
+    @Override
+    protected byte getFourOctetEncodingCode()
     {
         return (byte) 0xf0;
     }
 
-    @Override protected byte getSingleOctetEncodingCode()
+    @Override
+    protected byte getSingleOctetEncodingCode()
     {
         return (byte) 0xe0;
     }
 
-    @Override protected int getLength()
-    {
-        return _length;
-    }
-
-    @Override protected void writeBytes(final QpidByteBuffer buf, final int offset, final int length)
+    private static byte[] getEncodedValue(final Symbol[] value)
     {
-        buf.put(_encodedVal,offset,length);
-    }
-
-    public boolean isCacheable()
-    {
-        return false;
-    }
-
-    public void setValue(final Symbol[] value)
-    {
-
+        byte[] encodedVal;
+        int length;
         boolean useSmallConstructor = useSmallConstructor(value);
         boolean isSmall = useSmallConstructor && canFitInSmall(value);
         if(isSmall)
         {
-            _length = 2;
+            length = 2;
         }
         else
         {
-            _length = 5;
+            length = 5;
         }
         for(Symbol symbol : value)
         {
-            _length += symbol.length() ;
+            length += symbol.length() ;
         }
-        _length += value.length * (useSmallConstructor ? 1 : 4);
-
+        length += value.length * (useSmallConstructor ? 1 : 4);
 
-        _encodedVal = new byte[_length];
+        encodedVal = new byte[length];
 
-        ByteBuffer buf = ByteBuffer.wrap(_encodedVal);
+        ByteBuffer buf = ByteBuffer.wrap(encodedVal);
         if(isSmall)
         {
             buf.put((byte)value.length);
@@ -116,13 +93,10 @@ public class SymbolArrayWriter extends V
                 buf.put((byte)symbol.charAt(i));
             }
         }
-
-
-
-        super.setValue(value);
+        return encodedVal;
     }
 
-    private boolean useSmallConstructor(final Symbol[] value)
+    private static boolean useSmallConstructor(final Symbol[] value)
     {
         for(Symbol sym : value)
         {
@@ -134,7 +108,7 @@ public class SymbolArrayWriter extends V
         return true;
     }
 
-    private boolean canFitInSmall(final Symbol[] value)
+    private static boolean canFitInSmall(final Symbol[] value)
     {
         if(value.length>=127)
         {
@@ -158,9 +132,11 @@ public class SymbolArrayWriter extends V
     private static Factory<Symbol[]> FACTORY = new Factory<Symbol[]>()
                                             {
 
-                                                public ValueWriter<Symbol[]> newInstance(Registry registry)
+                                                @Override
+                                                public ValueWriter<Symbol[]> newInstance(final Registry registry,
+                                                                                         final Symbol[] object)
                                                 {
-                                                    return new SymbolArrayWriter();
+                                                    return new SymbolArrayWriter(object);
                                                 }
                                             };
 

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/SymbolWriter.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/SymbolWriter.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/SymbolWriter.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/SymbolWriter.java Sun Dec 11 16:01:06 2016
@@ -21,11 +21,11 @@
 
 package org.apache.qpid.server.protocol.v1_0.codec;
 
-import org.apache.qpid.server.protocol.v1_0.type.Symbol;
-import org.apache.qpid.bytebuffer.QpidByteBuffer;
-
 import java.nio.charset.Charset;
 
+import org.apache.qpid.bytebuffer.QpidByteBuffer;
+import org.apache.qpid.server.protocol.v1_0.type.Symbol;
+
 public class SymbolWriter extends VariableWidthWriter<Symbol>
 {
     private static final Charset ENCODING_CHARSET = Charset.forName("US-ASCII");
@@ -33,6 +33,11 @@ public class SymbolWriter extends Variab
     public static final byte SMALL_ENCODING_CODE = (byte) 0xa3;
     private Symbol _value;
 
+    public SymbolWriter(final Symbol object)
+    {
+        super(object.length());
+        _value = object;
+    }
 
     @Override
     protected byte getFourOctetEncodingCode()
@@ -47,36 +52,6 @@ public class SymbolWriter extends Variab
     }
 
     @Override
-    public void setValue(Symbol value)
-    {
-        _value = value;
-        super.setValue(value);
-    }
-
-    public boolean isCacheable()
-    {
-        return true;
-    }
-
-    @Override
-    protected void clearValue()
-    {
-        _value = null;
-    }
-
-    @Override
-    protected boolean hasValue()
-    {
-        return _value != null;
-    }
-
-    @Override
-    protected int getLength()
-    {
-        return _value.length();
-    }
-
-    @Override
     protected void writeBytes(QpidByteBuffer buf, int offset, int length)
     {
         int end = offset + length;
@@ -89,9 +64,11 @@ public class SymbolWriter extends Variab
     private static Factory<Symbol> FACTORY = new Factory<Symbol>()
                                             {
 
-                                                public ValueWriter<Symbol> newInstance(Registry registry)
+                                                @Override
+                                                public ValueWriter<Symbol> newInstance(final Registry registry,
+                                                                                       final Symbol object)
                                                 {
-                                                    return new SymbolWriter();
+                                                    return new SymbolWriter(object);
                                                 }
                                             };
 

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/TimestampWriter.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/TimestampWriter.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/TimestampWriter.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/TimestampWriter.java Sun Dec 11 16:01:06 2016
@@ -27,25 +27,25 @@ public class TimestampWriter extends Fix
 {
     private static final byte FORMAT_CODE = (byte) 0x83;
 
-
-    @Override
-    byte getFormatCode()
+    public TimestampWriter(final Date object)
     {
-        return FORMAT_CODE;
+        super(object.getTime());
     }
 
     @Override
-    long convertValueToLong(Date value)
+    byte getFormatCode()
     {
-        return value.getTime();
+        return FORMAT_CODE;
     }
 
     private static Factory<Date> FACTORY = new Factory<Date>()
                                             {
 
-                                                public ValueWriter<Date> newInstance(Registry registry)
+                                                @Override
+                                                public ValueWriter<Date> newInstance(final Registry registry,
+                                                                                     final Date object)
                                                 {
-                                                    return new TimestampWriter();
+                                                    return new TimestampWriter(object);
                                                 }
                                             };
 

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/UUIDWriter.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/UUIDWriter.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/UUIDWriter.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/UUIDWriter.java Sun Dec 11 16:01:06 2016
@@ -27,6 +27,14 @@ public class UUIDWriter extends FixedSix
 {
     private static final byte FORMAT_CODE = (byte) 0x98;
 
+    public UUIDWriter()
+    {
+    }
+
+    public UUIDWriter(final UUID object)
+    {
+        super(object);
+    }
 
     @Override
     byte getFormatCode()
@@ -49,9 +57,11 @@ public class UUIDWriter extends FixedSix
     private static Factory<UUID> FACTORY = new Factory<UUID>()
                                             {
 
-                                                public ValueWriter<UUID> newInstance(Registry registry)
+                                                @Override
+                                                public ValueWriter<UUID> newInstance(final Registry registry,
+                                                                                     final UUID object)
                                                 {
-                                                    return new UUIDWriter();
+                                                    return new UUIDWriter(object);
                                                 }
                                             };
 

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/UnsignedByteWriter.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/UnsignedByteWriter.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/UnsignedByteWriter.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/UnsignedByteWriter.java Sun Dec 11 16:01:06 2016
@@ -26,61 +26,44 @@ import org.apache.qpid.bytebuffer.QpidBy
 
 public class UnsignedByteWriter implements ValueWriter<UnsignedByte>
 {
-    private int _written;
     private byte _value;
 
-    public int writeToBuffer(QpidByteBuffer buffer)
+    public UnsignedByteWriter()
     {
+    }
 
-        switch(_written)
-        {
-            case 0:
-                if(buffer.hasRemaining())
-                {
-                    buffer.put((byte)0x50);
-                }
-                else
-                {
-                    break;
-                }
-            case 1:
-                if(buffer.hasRemaining())
-                {
-                    buffer.put(_value);
-                    _written = 2;
-                }
-                else
-                {
-                    _written = 1;
-                }
-
-        }
 
-        return 2;
+    public UnsignedByteWriter(UnsignedByte value)
+    {
+        setValue(value);
     }
 
-    public void setValue(UnsignedByte 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)0x50);
+        buffer.put(_value);
     }
 
-    public boolean isCacheable()
+    public void setValue(UnsignedByte value)
     {
-        return true;
+        _value = value.byteValue();
     }
 
     private static Factory<UnsignedByte> FACTORY = new Factory<UnsignedByte>()
                                             {
 
-                                                public ValueWriter<UnsignedByte> newInstance(Registry registry)
+                                                @Override
+                                                public ValueWriter<UnsignedByte> newInstance(final Registry registry,
+                                                                                             final UnsignedByte object)
                                                 {
-                                                    return new UnsignedByteWriter();
+                                                    return new UnsignedByteWriter(object);
                                                 }
                                             };
 

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/UnsignedIntegerWriter.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/UnsignedIntegerWriter.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/UnsignedIntegerWriter.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/UnsignedIntegerWriter.java Sun Dec 11 16:01:06 2016
@@ -21,127 +21,89 @@
 
 package org.apache.qpid.server.protocol.v1_0.codec;
 
-import org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger;
 import org.apache.qpid.bytebuffer.QpidByteBuffer;
+import org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger;
 
-public class UnsignedIntegerWriter implements ValueWriter<UnsignedInteger>
+public class UnsignedIntegerWriter
 {
     private static final byte EIGHT_BYTE_FORMAT_CODE = (byte)0x70;
     private static final byte ONE_BYTE_FORMAT_CODE = (byte) 0x52;
     private static final byte ZERO_BYTE_FORMAT_CODE = (byte) 0x43;
 
-    private ValueWriter<UnsignedInteger> _delegate;
 
-    private final FixedFourWriter<UnsignedInteger> _eightByteWriter = new FixedFourWriter<UnsignedInteger>()
-    {
-
-        @Override
-        byte getFormatCode()
+    private static final ValueWriter<UnsignedInteger> ZERO_BYTE_WRITER = new ValueWriter<UnsignedInteger>()
         {
-            return EIGHT_BYTE_FORMAT_CODE;
-        }
 
-        @Override
-        int convertValueToInt(UnsignedInteger value)
-        {
-            return value.intValue();
-        }
-    };
-
-    private final ValueWriter<UnsignedInteger> _oneByteWriter = new FixedOneWriter<UnsignedInteger>()
-    {
-
-        @Override protected byte getFormatCode()
-        {
-            return ONE_BYTE_FORMAT_CODE;
-        }
-
-        @Override protected byte convertToByte(final UnsignedInteger value)
-        {
-            return value.byteValue();
-        }
-    };
-
-    private final ValueWriter<UnsignedInteger> _zeroByteWriter = new ValueWriter<UnsignedInteger>()
-        {
-            private boolean _complete;
-
-
-            public int writeToBuffer(QpidByteBuffer buffer)
+            @Override
+            public int getEncodedSize()
             {
-
-                if(!_complete && buffer.hasRemaining())
-                {
-                    buffer.put(ZERO_BYTE_FORMAT_CODE);
-                    _complete = true;
-                }
-
                 return 1;
             }
 
-            public void setValue(UnsignedInteger uint)
+            public void writeToBuffer(QpidByteBuffer buffer)
             {
-                _complete = false;
+                buffer.put(ZERO_BYTE_FORMAT_CODE);
             }
+        };
 
-            public boolean isCacheable()
-            {
-                return true;
-            }
 
-            public boolean isComplete()
-            {
-                return _complete;
-            }
 
-        };
 
 
+    private static ValueWriter.Factory<UnsignedInteger> FACTORY = new ValueWriter.Factory<UnsignedInteger>()
+                                            {
+
+                                                @Override
+                                                public ValueWriter<UnsignedInteger> newInstance(final ValueWriter.Registry registry,
+                                                                                                final UnsignedInteger uint)
+                                                {
+                                                    if(uint.equals(UnsignedInteger.ZERO))
+                                                    {
+                                                        return ZERO_BYTE_WRITER;
+                                                    }
+                                                    else if(uint.compareTo(UnsignedInteger.valueOf(256))<0)
+                                                    {
+                                                        return new UnsignedIntegerFixedOneWriter(uint);
+                                                    }
+                                                    else
+                                                    {
+                                                        return new UnsignedIntegerFixedFourWriter(uint);
+                                                    }
+                                                }
+                                            };
 
-    public int writeToBuffer(final QpidByteBuffer buffer)
+    public static void register(ValueWriter.Registry registry)
     {
-        return _delegate.writeToBuffer(buffer);
+        registry.register(UnsignedInteger.class, FACTORY);
     }
 
-    public void setValue(final UnsignedInteger uint)
+    private static class UnsignedIntegerFixedFourWriter extends FixedFourWriter<UnsignedInteger>
     {
-        if(uint.equals(UnsignedInteger.ZERO))
-        {
-            _delegate = _zeroByteWriter;
-        }
-        else if(uint.compareTo(UnsignedInteger.valueOf(256))<0)
+
+        UnsignedIntegerFixedFourWriter(final UnsignedInteger object)
         {
-            _delegate = _oneByteWriter;
+            super(object.intValue());
         }
-        else
+
+        @Override
+        byte getFormatCode()
         {
-            _delegate = _eightByteWriter;
+            return EIGHT_BYTE_FORMAT_CODE;
         }
-        _delegate.setValue(uint);
-    }
 
-    public boolean isComplete()
-    {
-        return _delegate.isComplete();
     }
 
-    public boolean isCacheable()
+    private static class UnsignedIntegerFixedOneWriter extends FixedOneWriter<UnsignedInteger>
     {
-        return false;
-    }
-
-
-    private static Factory<UnsignedInteger> FACTORY = new Factory<UnsignedInteger>()
-                                            {
 
-                                                public ValueWriter<UnsignedInteger> newInstance(Registry registry)
-                                                {
-                                                    return new UnsignedIntegerWriter();
-                                                }
-                                            };
+        UnsignedIntegerFixedOneWriter(final UnsignedInteger value)
+        {
+            super(value.byteValue());
+        }
 
-    public static void register(ValueWriter.Registry registry)
-    {
-        registry.register(UnsignedInteger.class, FACTORY);
+        @Override protected byte getFormatCode()
+        {
+            return ONE_BYTE_FORMAT_CODE;
+        }
     }
 }

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/UnsignedLongWriter.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/UnsignedLongWriter.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/UnsignedLongWriter.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/UnsignedLongWriter.java Sun Dec 11 16:01:06 2016
@@ -21,131 +21,104 @@
 
 package org.apache.qpid.server.protocol.v1_0.codec;
 
-import org.apache.qpid.server.protocol.v1_0.type.UnsignedLong;
 import org.apache.qpid.bytebuffer.QpidByteBuffer;
+import org.apache.qpid.server.protocol.v1_0.type.UnsignedLong;
 
-public class UnsignedLongWriter implements ValueWriter<UnsignedLong>
+public class UnsignedLongWriter
 {
-
-
     private static final byte EIGHT_BYTE_FORMAT_CODE = (byte) 0x80;
     private static final byte ONE_BYTE_FORMAT_CODE = (byte) 0x53;
     private static final byte ZERO_BYTE_FORMAT_CODE = (byte) 0x44;
 
-    private ValueWriter<UnsignedLong> _delegate;
 
-    private final FixedEightWriter<UnsignedLong> _eightByteWriter = new FixedEightWriter<UnsignedLong>()
+    private static final ValueWriter<UnsignedLong> ZERO_BYTE_WRITER = new ValueWriter<UnsignedLong>()
     {
-
-        @Override
-        byte getFormatCode()
-        {
-            return EIGHT_BYTE_FORMAT_CODE;
-        }
-
         @Override
-        long convertValueToLong(UnsignedLong value)
+        public int getEncodedSize()
         {
-            return value.longValue();
-        }
-
-    };
-
-    private final ValueWriter<UnsignedLong> _oneByteWriter = new FixedOneWriter<UnsignedLong>()
-    {
-
-        @Override protected byte getFormatCode()
-        {
-            return ONE_BYTE_FORMAT_CODE;
+            return 1;
         }
 
-        @Override protected byte convertToByte(final UnsignedLong value)
+        public void writeToBuffer(QpidByteBuffer buffer)
         {
-            return value.byteValue();
+            buffer.put(ZERO_BYTE_FORMAT_CODE);
         }
     };
 
-    private final ValueWriter<UnsignedLong> _zeroByteWriter = new ValueWriter<UnsignedLong>()
-    {
-        private boolean _complete;
-
 
-        public int writeToBuffer(QpidByteBuffer buffer)
-        {
 
-            if(!_complete && buffer.hasRemaining())
+    private static ValueWriter.Factory<UnsignedLong> FACTORY =
+            new ValueWriter.Factory<UnsignedLong>()
             {
-                buffer.put(ZERO_BYTE_FORMAT_CODE);
-                _complete = true;
-            }
 
-            return 1;
-        }
+                @Override
+                public ValueWriter<UnsignedLong> newInstance(final ValueWriter.Registry registry,
+                                                             final UnsignedLong object)
+                {
+                    if (object.equals(UnsignedLong.ZERO))
+                    {
+                        return ZERO_BYTE_WRITER;
+                    }
+                    else if ((object.longValue() & 0xffL) == object.longValue())
+                    {
+                        return new UnsignedLongFixedOneWriter(object);
+                    }
+                    else
+                    {
+                        return new UnsignedLongFixedEightWriter(object);
+                    }
+                }
+            };
+
+    public static void register(ValueWriter.Registry registry)
+    {
+        registry.register(UnsignedLong.class, FACTORY);
+    }
 
-        public void setValue(UnsignedLong ulong)
+    private static class UnsignedLongFixedOneWriter extends FixedOneWriter<UnsignedLong>
+    {
+        UnsignedLongFixedOneWriter(final UnsignedLong value)
         {
-            _complete = false;
+            super(value.byteValue());
         }
 
-        public boolean isCacheable()
+        UnsignedLongFixedOneWriter(byte value)
         {
-            return true;
+            super(value);
         }
 
-        public boolean isComplete()
+        @Override protected byte getFormatCode()
         {
-            return _complete;
+            return ONE_BYTE_FORMAT_CODE;
         }
-
-    };
-
-
-
-    private static Factory<UnsignedLong> FACTORY = new Factory<UnsignedLong>()
-                                            {
-
-                                                public ValueWriter<UnsignedLong> newInstance(Registry registry)
-                                                {
-                                                    return new UnsignedLongWriter();
-                                                }
-                                            };
-
-    public static void register(ValueWriter.Registry registry)
-    {
-        registry.register(UnsignedLong.class, FACTORY);
     }
 
-    public int writeToBuffer(final QpidByteBuffer buffer)
+    private static class UnsignedLongFixedEightWriter extends FixedEightWriter<UnsignedLong>
     {
-        return _delegate.writeToBuffer(buffer);
-    }
-
-    public void setValue(final UnsignedLong ulong)
-    {
-        if(ulong.equals(UnsignedLong.ZERO))
+        public UnsignedLongFixedEightWriter(final UnsignedLong object)
         {
-            _delegate = _zeroByteWriter;
+            super(object.longValue());
         }
-        else if((ulong.longValue() & 0xffL) == ulong.longValue())
+        public UnsignedLongFixedEightWriter(final long value)
         {
-            _delegate = _oneByteWriter;
+            super(value);
         }
-        else
+
+        @Override
+        byte getFormatCode()
         {
-            _delegate = _eightByteWriter;
+            return EIGHT_BYTE_FORMAT_CODE;
         }
-
-        _delegate.setValue(ulong);
     }
 
-    public boolean isComplete()
+    public static ValueWriter<UnsignedLong> getWriter(byte value)
     {
-        return _delegate.isComplete();
+        return new UnsignedLongFixedOneWriter(value);
     }
 
-    public boolean isCacheable()
+
+    public static ValueWriter<UnsignedLong> getWriter(long value)
     {
-        return false;
+        return new UnsignedLongFixedEightWriter(value);
     }
-
 }

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/UnsignedShortWriter.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/UnsignedShortWriter.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/UnsignedShortWriter.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/UnsignedShortWriter.java Sun Dec 11 16:01:06 2016
@@ -27,6 +27,14 @@ public class UnsignedShortWriter extends
 {
     private static final byte FORMAT_CODE = (byte)0x60;
 
+    public UnsignedShortWriter()
+    {
+    }
+
+    public UnsignedShortWriter(final UnsignedShort object)
+    {
+        super(object);
+    }
 
     @Override
     short convertValueToShort(UnsignedShort value)
@@ -43,9 +51,11 @@ public class UnsignedShortWriter extends
     private static Factory<UnsignedShort> FACTORY = new Factory<UnsignedShort>()
                                             {
 
-                                                public ValueWriter<UnsignedShort> newInstance(Registry registry)
+                                                @Override
+                                                public ValueWriter<UnsignedShort> newInstance(final Registry registry,
+                                                                                              final UnsignedShort object)
                                                 {
-                                                    return new UnsignedShortWriter();
+                                                    return new UnsignedShortWriter(object);
                                                 }
                                             };
 

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/ValueWriter.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/ValueWriter.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/ValueWriter.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/ValueWriter.java Sun Dec 11 16:01:06 2016
@@ -21,8 +21,6 @@
 
 package org.apache.qpid.server.protocol.v1_0.codec;
 
-import java.util.Map;
-
 import org.apache.qpid.bytebuffer.QpidByteBuffer;
 
 public interface ValueWriter<T extends Object>
@@ -30,30 +28,25 @@ public interface ValueWriter<T extends O
 
 
 
-    public static interface Factory<V extends Object>
+    interface Factory<V extends Object>
     {
-        ValueWriter<V> newInstance(Registry registry);
+        ValueWriter<V> newInstance(Registry registry, V object);
     }
 
-    public static interface Registry
+    interface Registry
     {
-        public static interface Source
+        interface Source
         {
-            public Registry getDescribedTypeRegistry();
+            Registry getDescribedTypeRegistry();
         }
 
         <V extends Object> ValueWriter<V> getValueWriter(V value);
-        <V extends Object> ValueWriter<V> getValueWriter(V value, Map<Class, ValueWriter> localCache);
+
         <V extends Object> ValueWriter<V> register(Class<V> clazz, ValueWriter.Factory<V> writer);
 
     }
 
+    int getEncodedSize();
 
-    int writeToBuffer(QpidByteBuffer buffer);
-
-    void setValue(T frameBody);
-
-    boolean isComplete();
-
-    boolean isCacheable();
+    void writeToBuffer(QpidByteBuffer buffer);
 }

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/VariableWidthWriter.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/VariableWidthWriter.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/VariableWidthWriter.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/VariableWidthWriter.java Sun Dec 11 16:01:06 2016
@@ -25,145 +25,48 @@ import org.apache.qpid.bytebuffer.QpidBy
 
 public abstract class VariableWidthWriter<V> implements ValueWriter<V>
 {
-    private int _written;
-    private int _size;
+    private final int _length;
+    private final int _size;
 
-    public int writeToBuffer(QpidByteBuffer buffer)
+    public VariableWidthWriter(int length)
+    {
+        _length = length;
+        _size = (_length & 0xFFFFFF00) == 0 ? 1 : 4;
+    }
+
+    public void writeToBuffer(QpidByteBuffer buffer)
     {
 
-        int written = _written;
         final int length = getLength();
         boolean singleOctetSize = _size == 1;
         if(singleOctetSize)
         {
-            switch(written)
-            {
-                case 0:
-                    if(buffer.hasRemaining())
-                    {
-                        buffer.put(getSingleOctetEncodingCode());
-                    }
-                    else
-                    {
-                        break;
-                    }
-                case 1:
-                    if(buffer.hasRemaining())
-                    {
-                        buffer.put((byte)length);
-                        written = 2;
-                    }
-                    else
-                    {
-                        written = 1;
-                        break;
-                    }
-                default:
-
-                    final int toWrite = 2 + length - written;
-                    if(buffer.remaining() >= toWrite)
-                    {
-                        writeBytes(buffer, written-2,toWrite);
-                        written = length + 2;
-                        clearValue();
-                    }
-                    else
-                    {
-                        final int remaining = buffer.remaining();
-
-                        writeBytes(buffer, written-2, remaining);
-                        written += remaining;
-                    }
-
-            }
+            buffer.put(getSingleOctetEncodingCode());
+            buffer.put((byte)length);
         }
         else
         {
 
-            int remaining = buffer.remaining();
-
-            switch(written)
-            {
-
-                case 0:
-                    if(buffer.hasRemaining())
-                    {
-                        buffer.put(getFourOctetEncodingCode());
-                        remaining--;
-                        written = 1;
-                    }
-                    else
-                    {
-                        break;
-                    }
-                case 1:
-                    if(remaining >= 4)
-                    {
-                        buffer.putInt(length);
-                        remaining-=4;
-                        written+=4;
-                    }
-                case 2:
-                case 3:
-                    if(remaining >= 2 && written <= 3)
-                    {
-                        buffer.putShort((short)((length >> ((3-written)<<3)) & 0xFFFF ));
-                        remaining -= 2;
-                        written += 2;
-                    }
-                case 4:
-                    if(remaining >=1 && written <=4)
-                    {
-                        buffer.put((byte)((length>> ((4-written)<<3)) & 0xFF ));
-                        written++;
-                    }
-
-                default:
-
-                    final int toWrite = 5 + length - written;
-                    if(buffer.remaining() >= toWrite)
-                    {
-                        writeBytes(buffer, written-5,toWrite);
-                        written = length + 5;
-                        clearValue();
-                    }
-                    else if(buffer.hasRemaining())
-                    {
-                        written += buffer.remaining();
-                        writeBytes(buffer, written-5, buffer.remaining());
-                    }
-
-            }
-
+            buffer.put(getFourOctetEncodingCode());
+            buffer.putInt(length);
         }
-
-        _written = written;
-        return 1 + _size + length;
+        writeBytes(buffer, 0,length);
     }
 
-    protected abstract void clearValue();
-
-    protected abstract boolean hasValue();
+    @Override
+    public int getEncodedSize()
+    {
+        return 1 + _size + getLength();
+    }
 
     protected abstract byte getFourOctetEncodingCode();
 
     protected abstract byte getSingleOctetEncodingCode();
 
-    public void setValue(V value)
+    protected final int getLength()
     {
-        _written = 0;
-        _size = (getLength() & 0xFFFFFF00) == 0 ? 1 : 4;
+        return _length;
     }
 
-    protected abstract int getLength();
-
     protected abstract void writeBytes(QpidByteBuffer buf, int offset, int length);
-
-
-    public boolean isComplete()
-    {
-        return !hasValue() || _written == getLength() + _size + 1;
-    }
-
-
 }

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/framing/FrameHandler.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/framing/FrameHandler.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/framing/FrameHandler.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/framing/FrameHandler.java Sun Dec 11 16:01:06 2016
@@ -46,14 +46,22 @@ public class FrameHandler implements Pro
     private ValueHandler _typeHandler;
     private boolean _errored = false;
 
-    public FrameHandler(final AMQPConnection_1_0 connection, final boolean sasl)
+    public FrameHandler(final ValueHandler typeHandler, final ConnectionHandler connection, final boolean isSasl)
     {
+        _typeHandler = typeHandler;
         _connection = connection;
-        _typeHandler = new ValueHandler(connection.getDescribedTypeRegistry());
-        _isSasl = sasl;
+        _isSasl = isSasl;
+    }
+
+    public FrameHandler(final AMQPConnection_1_0 connection, final boolean sasl)
+    {
+        this(new ValueHandler(connection.getDescribedTypeRegistry()), connection, sasl);
 
     }
 
+
+
+
     public ProtocolHandler parse(QpidByteBuffer in)
     {
         try

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/messaging/SectionEncoderImpl.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/messaging/SectionEncoderImpl.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/messaging/SectionEncoderImpl.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/messaging/SectionEncoderImpl.java Sun Dec 11 16:01:06 2016
@@ -26,7 +26,6 @@ import org.apache.qpid.server.protocol.v
 
 public class SectionEncoderImpl implements SectionEncoder
 {
-    private static final QpidByteBuffer EMPTY_BYTE_BUFFER = QpidByteBuffer.wrap(new byte[0]);
     private AMQPDescribedTypeRegistry _registry;
 
     public SectionEncoderImpl(final AMQPDescribedTypeRegistry describedTypeRegistry)
@@ -37,8 +36,7 @@ public class SectionEncoderImpl implemen
     public QpidByteBuffer encodeObject(Object obj)
     {
         final ValueWriter<Object> valueWriter = _registry.getValueWriter(obj);
-        valueWriter.setValue(obj);
-        int size = valueWriter.writeToBuffer(EMPTY_BYTE_BUFFER);
+        int size = valueWriter.getEncodedSize();
         final QpidByteBuffer buf = QpidByteBuffer.allocateDirect(size);
         valueWriter.writeToBuffer(buf);
         buf.flip();

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/Binary.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/type/Binary.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/type/Binary.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/Binary.java Sun Dec 11 16:01:06 2016
@@ -21,38 +21,28 @@
 package org.apache.qpid.server.protocol.v1_0.type;
 
 import java.nio.ByteBuffer;
-import java.util.Collection;
+import java.util.Arrays;
 
 public class Binary
 {
 
     private final byte[] _data;
-    private final int _offset;
-    private final int _length;
     private final int _hashCode;
 
     public Binary(final byte[] data)
     {
-        this(data, 0, data.length);
-    }
-
-    public Binary(final byte[] data, final int offset, final int length)
-    {
-
         _data = data;
-        _offset = offset;
-        _length = length;
         int hc = 0;
-        for (int i = 0; i < length; i++)
+        for (int i = 0; i < _data.length; i++)
         {
-            hc = 31*hc + (0xFF & data[offset + i]);
+            hc = 31*hc + (0xFF & data[i]);
         }
         _hashCode = hc;
     }
 
     public ByteBuffer asByteBuffer()
     {
-        return ByteBuffer.wrap(_data, _offset, _length);
+        return ByteBuffer.wrap(_data);
     }
 
     public final int hashCode()
@@ -65,53 +55,26 @@ public class Binary
         if(o instanceof Binary)
         {
             Binary buf = (Binary) o;
-
-            final int size = _length;
-            if (size == buf._length)
-            {
-                final byte[] myData = _data;
-                final byte[] theirData = buf._data;
-                int myOffset = _offset;
-                int theirOffset = buf._offset;
-                final int myLimit = myOffset + size;
-
-                while (myOffset < myLimit)
-                {
-                    if (myData[myOffset++] != theirData[theirOffset++])
-                    {
-                        return false;
-                    }
-                }
-
-                return true;
-            }
+            return Arrays.equals(_data, buf._data);
         }
 
         return false;
     }
 
 
-    public int getArrayOffset()
-    {
-        return _offset;
-    }
 
     public byte[] getArray()
     {
         return _data;
     }
 
-    public int getLength()
-    {
-        return _length;
-    }
 
     public String toString()
     {
         StringBuilder str = new StringBuilder();
 
 
-        for (int i = _offset; i < _length; i++)
+        for (int i = 0; i < _data.length; i++)
         {
             byte c = _data[i];
 
@@ -128,32 +91,4 @@ public class Binary
         return str.toString();
 
     }
-
-    public static Binary combine(final Collection<Binary> binaries)
-    {
-
-        if(binaries.size() == 1)
-        {
-            return binaries.iterator().next();
-        }
-
-        int size = 0;
-        for(Binary binary : binaries)
-        {
-            size += binary.getLength();
-        }
-        byte[] data = new byte[size];
-        int offset = 0;
-        for(Binary binary : binaries)
-        {
-            System.arraycopy(binary._data, binary._offset, data, offset, binary._length);
-            offset += binary._length;
-        }
-        return new Binary(data);
-    }
-
-    public Binary subBinary(final int offset, final int length)
-    {
-        return new Binary(_data, _offset+offset, length);
-    }
 }

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/codec/AMQPDescribedTypeRegistry.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/type/codec/AMQPDescribedTypeRegistry.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/type/codec/AMQPDescribedTypeRegistry.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/codec/AMQPDescribedTypeRegistry.java Sun Dec 11 16:01:06 2016
@@ -307,12 +307,6 @@ public class AMQPDescribedTypeRegistry i
 
     private final Map<Class, ValueWriter.Factory> _writerMap = new HashMap<Class, ValueWriter.Factory>();
 
-    public <V extends Object> ValueWriter<V> getValueWriter(V value, Map<Class, ValueWriter> localCache)
-    {
-        return getValueWriter(value);
-
-    }
-
 
     public <V extends Object> ValueWriter<V> getValueWriter(V value)
     {
@@ -328,16 +322,14 @@ public class AMQPDescribedTypeRegistry i
             {
                 factory = _writerMap.get(List.class);
                 _writerMap.put(value.getClass(), factory);
-                writer = factory.newInstance(this);
-                writer.setValue(value);
+                writer = factory.newInstance(this, value);
 
             }
             else if(value instanceof Map)
             {
                 factory = _writerMap.get(Map.class);
                 _writerMap.put(value.getClass(), factory);
-                writer = factory.newInstance(this);
-                writer.setValue(value);
+                writer = factory.newInstance(this, value);
 
             }
             else if(value.getClass().isArray())
@@ -355,8 +347,7 @@ public class AMQPDescribedTypeRegistry i
                 }
                 // TODO primitive array types
                 factory = _writerMap.get(List.class);
-                writer = factory.newInstance(this);
-                writer.setValue(Arrays.asList((Object[])value));
+                writer = factory.newInstance(this, (V)Arrays.asList((Object[])value));
 
             }
             else
@@ -366,8 +357,7 @@ public class AMQPDescribedTypeRegistry i
         }
         else
         {
-            writer = factory.newInstance(this);
-            writer.setValue(value);
+            writer = factory.newInstance(this, value);
         }
 
 

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/AcceptedWriter.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/type/messaging/codec/AcceptedWriter.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/type/messaging/codec/AcceptedWriter.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/AcceptedWriter.java Sun Dec 11 16:01:06 2016
@@ -24,120 +24,26 @@
 package org.apache.qpid.server.protocol.v1_0.type.messaging.codec;
 
 import org.apache.qpid.server.protocol.v1_0.codec.AbstractDescribedTypeWriter;
-import org.apache.qpid.server.protocol.v1_0.codec.AbstractListWriter;
 import org.apache.qpid.server.protocol.v1_0.codec.ListWriter;
+import org.apache.qpid.server.protocol.v1_0.codec.UnsignedLongWriter;
 import org.apache.qpid.server.protocol.v1_0.codec.ValueWriter;
-
 import org.apache.qpid.server.protocol.v1_0.type.UnsignedLong;
 import org.apache.qpid.server.protocol.v1_0.type.messaging.Accepted;
 
 public class AcceptedWriter extends AbstractDescribedTypeWriter<Accepted>
 {
-    private Accepted _value;
-    private int _count = -1;
+    private static final ValueWriter<UnsignedLong> DESCRIPTOR_WRITER = UnsignedLongWriter.getWriter((byte) 0x24);
 
     public AcceptedWriter(final Registry registry)
     {
-        super(registry);
-    }
-
-    @Override
-    protected void onSetValue(final Accepted value)
-    {
-        _value = value;
-        _count = calculateCount();
-    }
-
-    private int calculateCount()
-    {
-
-
-        return 0;
-    }
-
-    @Override
-    protected void clear()
-    {
-        _value = null;
-        _count = -1;
-    }
-
-
-    protected Object getDescriptor()
-    {
-        return UnsignedLong.valueOf(0x0000000000000024L);
-    }
-
-    @Override
-    protected ValueWriter createDescribedWriter()
-    {
-        if(_count != 0)
-        {
-            final Writer writer = new Writer(getRegistry());
-            writer.setValue(_value);
-            return writer;
-        }
-        else
-        {
-            return new ListWriter.EmptyListValueWriter();
-        }
-
-    }
-
-    private class Writer extends AbstractListWriter<Accepted>
-    {
-        private int _field;
-
-        public Writer(final Registry registry)
-        {
-            super(registry);
-        }
-
-        @Override
-        protected void onSetValue(final Accepted value)
-        {
-            reset();
-        }
-
-        @Override
-        protected int getCount()
-        {
-            return _count;
-        }
-
-        @Override
-        protected boolean hasNext()
-        {
-            return _field < _count;
-        }
-
-        @Override
-        protected Object next()
-        {
-            switch(_field++)
-            {
-
-                default:
-                    return null;
-            }
-        }
-
-        @Override
-        protected void clear()
-        {
-        }
-
-        @Override
-        protected void reset()
-        {
-            _field = 0;
-        }
+        super(DESCRIPTOR_WRITER, ListWriter.EMPTY_LIST_WRITER);
     }
 
     private static Factory<Accepted> FACTORY = new Factory<Accepted>()
     {
 
-        public ValueWriter<Accepted> newInstance(Registry registry)
+        @Override
+        public ValueWriter<Accepted> newInstance(final Registry registry, final Accepted object)
         {
             return new AcceptedWriter(registry);
         }

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/AmqpSequenceWriter.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/type/messaging/codec/AmqpSequenceWriter.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/type/messaging/codec/AmqpSequenceWriter.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/AmqpSequenceWriter.java Sun Dec 11 16:01:06 2016
@@ -24,6 +24,7 @@
 package org.apache.qpid.server.protocol.v1_0.type.messaging.codec;
 
 import org.apache.qpid.server.protocol.v1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.server.protocol.v1_0.codec.UnsignedLongWriter;
 import org.apache.qpid.server.protocol.v1_0.codec.ValueWriter;
 
 import org.apache.qpid.server.protocol.v1_0.type.UnsignedLong;
@@ -31,44 +32,21 @@ import org.apache.qpid.server.protocol.v
 
 public class AmqpSequenceWriter extends AbstractDescribedTypeWriter<AmqpSequence>
 {
-    private AmqpSequence _value;
+    private static final ValueWriter<UnsignedLong> DESCRIPTOR_WRITER = UnsignedLongWriter.getWriter((byte) 0x76);
 
 
-
-    public AmqpSequenceWriter(final Registry registry)
-    {
-        super(registry);
-    }
-
-    @Override
-    protected void onSetValue(final AmqpSequence value)
-    {
-        _value = value;
-    }
-
-    @Override
-    protected void clear()
-    {
-        _value = null;
-    }
-
-    protected Object getDescriptor()
-    {
-        return UnsignedLong.valueOf(0x0000000000000076L);
-    }
-
-    @Override
-    protected ValueWriter createDescribedWriter()
+    public AmqpSequenceWriter(final Registry registry, final AmqpSequence object)
     {
-        return getRegistry().getValueWriter(_value);
+        super(DESCRIPTOR_WRITER, registry.getValueWriter(object.getValue()));
     }
 
     private static Factory<AmqpSequence> FACTORY = new Factory<AmqpSequence>()
     {
 
-        public ValueWriter<AmqpSequence> newInstance(Registry registry)
+        @Override
+        public ValueWriter<AmqpSequence> newInstance(final Registry registry, final AmqpSequence object)
         {
-            return new AmqpSequenceWriter(registry);
+            return new AmqpSequenceWriter(registry, object);
         }
     };
 

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/AmqpValueWriter.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/type/messaging/codec/AmqpValueWriter.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/type/messaging/codec/AmqpValueWriter.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/AmqpValueWriter.java Sun Dec 11 16:01:06 2016
@@ -24,6 +24,7 @@
 package org.apache.qpid.server.protocol.v1_0.type.messaging.codec;
 
 import org.apache.qpid.server.protocol.v1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.server.protocol.v1_0.codec.UnsignedLongWriter;
 import org.apache.qpid.server.protocol.v1_0.codec.ValueWriter;
 
 import org.apache.qpid.server.protocol.v1_0.type.UnsignedLong;
@@ -31,44 +32,20 @@ import org.apache.qpid.server.protocol.v
 
 public class AmqpValueWriter extends AbstractDescribedTypeWriter<AmqpValue>
 {
-    private AmqpValue _value;
+    private static final ValueWriter<UnsignedLong> DESCRIPTOR_WRITER = UnsignedLongWriter.getWriter((byte) 0x77);
 
-
-
-    public AmqpValueWriter(final Registry registry)
-    {
-        super(registry);
-    }
-
-    @Override
-    protected void onSetValue(final AmqpValue value)
-    {
-        _value = value;
-    }
-
-    @Override
-    protected void clear()
-    {
-        _value = null;
-    }
-
-    protected Object getDescriptor()
-    {
-        return UnsignedLong.valueOf(0x0000000000000077L);
-    }
-
-    @Override
-    protected ValueWriter createDescribedWriter()
+    private AmqpValueWriter(final Registry registry, final AmqpValue object)
     {
-        return getRegistry().getValueWriter(_value.getValue());
+        super(DESCRIPTOR_WRITER, registry.getValueWriter(object.getValue()));
     }
 
     private static Factory<AmqpValue> FACTORY = new Factory<AmqpValue>()
     {
 
-        public ValueWriter<AmqpValue> newInstance(Registry registry)
+        @Override
+        public ValueWriter<AmqpValue> newInstance(final Registry registry, final AmqpValue object)
         {
-            return new AmqpValueWriter(registry);
+            return new AmqpValueWriter(registry, object);
         }
     };
 

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/ApplicationPropertiesWriter.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/type/messaging/codec/ApplicationPropertiesWriter.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/type/messaging/codec/ApplicationPropertiesWriter.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/ApplicationPropertiesWriter.java Sun Dec 11 16:01:06 2016
@@ -24,6 +24,7 @@
 package org.apache.qpid.server.protocol.v1_0.type.messaging.codec;
 
 import org.apache.qpid.server.protocol.v1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.server.protocol.v1_0.codec.UnsignedLongWriter;
 import org.apache.qpid.server.protocol.v1_0.codec.ValueWriter;
 
 import org.apache.qpid.server.protocol.v1_0.type.UnsignedLong;
@@ -31,44 +32,21 @@ import org.apache.qpid.server.protocol.v
 
 public class ApplicationPropertiesWriter extends AbstractDescribedTypeWriter<ApplicationProperties>
 {
-    private ApplicationProperties _value;
+    private static final ValueWriter<UnsignedLong> DESCRIPTOR_WRITER = UnsignedLongWriter.getWriter((byte) 0x74);
 
-
-
-    public ApplicationPropertiesWriter(final Registry registry)
-    {
-        super(registry);
-    }
-
-    @Override
-    protected void onSetValue(final ApplicationProperties value)
-    {
-        _value = value;
-    }
-
-    @Override
-    protected void clear()
-    {
-        _value = null;
-    }
-
-    protected Object getDescriptor()
-    {
-        return UnsignedLong.valueOf(0x0000000000000074L);
-    }
-
-    @Override
-    protected ValueWriter createDescribedWriter()
+    private ApplicationPropertiesWriter(final Registry registry, final ApplicationProperties object)
     {
-        return getRegistry().getValueWriter(_value.getValue());
+        super(DESCRIPTOR_WRITER, registry.getValueWriter(object.getValue()));
     }
 
     private static Factory<ApplicationProperties> FACTORY = new Factory<ApplicationProperties>()
     {
 
-        public ValueWriter<ApplicationProperties> newInstance(Registry registry)
+        @Override
+        public ValueWriter<ApplicationProperties> newInstance(final Registry registry,
+                                                              final ApplicationProperties object)
         {
-            return new ApplicationPropertiesWriter(registry);
+            return new ApplicationPropertiesWriter(registry, object);
         }
     };
 

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/DataWriter.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/type/messaging/codec/DataWriter.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/type/messaging/codec/DataWriter.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/DataWriter.java Sun Dec 11 16:01:06 2016
@@ -24,6 +24,7 @@
 package org.apache.qpid.server.protocol.v1_0.type.messaging.codec;
 
 import org.apache.qpid.server.protocol.v1_0.codec.AbstractDescribedTypeWriter;
+import org.apache.qpid.server.protocol.v1_0.codec.UnsignedLongWriter;
 import org.apache.qpid.server.protocol.v1_0.codec.ValueWriter;
 
 import org.apache.qpid.server.protocol.v1_0.type.UnsignedLong;
@@ -31,44 +32,20 @@ import org.apache.qpid.server.protocol.v
 
 public class DataWriter extends AbstractDescribedTypeWriter<Data>
 {
-    private Data _value;
+    private static final ValueWriter<UnsignedLong> DESCRIPTOR_WRITER = UnsignedLongWriter.getWriter((byte) 0x75);
 
-
-
-    public DataWriter(final Registry registry)
-    {
-        super(registry);
-    }
-
-    @Override
-    protected void onSetValue(final Data value)
-    {
-        _value = value;
-    }
-
-    @Override
-    protected void clear()
-    {
-        _value = null;
-    }
-
-    protected Object getDescriptor()
-    {
-        return UnsignedLong.valueOf(0x0000000000000075L);
-    }
-
-    @Override
-    protected ValueWriter createDescribedWriter()
+    public DataWriter(final Registry registry, final Data object)
     {
-        return getRegistry().getValueWriter(_value.getValue());
+        super(DESCRIPTOR_WRITER, registry.getValueWriter(object.getValue()));
     }
 
     private static Factory<Data> FACTORY = new Factory<Data>()
     {
 
-        public ValueWriter<Data> newInstance(Registry registry)
+        @Override
+        public ValueWriter<Data> newInstance(final Registry registry, final Data object)
         {
-            return new DataWriter(registry);
+            return new DataWriter(registry, object);
         }
     };
 

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/DeleteOnCloseWriter.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/type/messaging/codec/DeleteOnCloseWriter.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/type/messaging/codec/DeleteOnCloseWriter.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/DeleteOnCloseWriter.java Sun Dec 11 16:01:06 2016
@@ -24,111 +24,27 @@
 package org.apache.qpid.server.protocol.v1_0.type.messaging.codec;
 
 import org.apache.qpid.server.protocol.v1_0.codec.AbstractDescribedTypeWriter;
-import org.apache.qpid.server.protocol.v1_0.codec.AbstractListWriter;
+import org.apache.qpid.server.protocol.v1_0.codec.ListWriter;
+import org.apache.qpid.server.protocol.v1_0.codec.UnsignedLongWriter;
 import org.apache.qpid.server.protocol.v1_0.codec.ValueWriter;
-
 import org.apache.qpid.server.protocol.v1_0.type.UnsignedLong;
 import org.apache.qpid.server.protocol.v1_0.type.messaging.DeleteOnClose;
 
 public class DeleteOnCloseWriter extends AbstractDescribedTypeWriter<DeleteOnClose>
 {
-    private DeleteOnClose _value;
-    private int _count = -1;
+    private static final ValueWriter<UnsignedLong> DESCRIPTOR_WRITER = UnsignedLongWriter.getWriter((byte) 0x2B);
 
     public DeleteOnCloseWriter(final Registry registry)
     {
-        super(registry);
-    }
-
-    @Override
-    protected void onSetValue(final DeleteOnClose value)
-    {
-        _value = value;
-        _count = calculateCount();
+        super(DESCRIPTOR_WRITER, ListWriter.EMPTY_LIST_WRITER);
     }
 
-    private int calculateCount()
-    {
-
-
-        return 0;
-    }
-
-    @Override
-    protected void clear()
-    {
-        _value = null;
-        _count = -1;
-    }
-
-
-    protected Object getDescriptor()
-    {
-        return UnsignedLong.valueOf(0x000000000000002bL);
-    }
-
-    @Override
-    protected ValueWriter createDescribedWriter()
-    {
-        final Writer writer = new Writer(getRegistry());
-        writer.setValue(_value);
-        return writer;
-    }
-
-    private class Writer extends AbstractListWriter<DeleteOnClose>
-    {
-        private int _field;
-
-        public Writer(final Registry registry)
-        {
-            super(registry);
-        }
-
-        @Override
-        protected void onSetValue(final DeleteOnClose value)
-        {
-            reset();
-        }
-
-        @Override
-        protected int getCount()
-        {
-            return _count;
-        }
-
-        @Override
-        protected boolean hasNext()
-        {
-            return _field < _count;
-        }
-
-        @Override
-        protected Object next()
-        {
-            switch(_field++)
-            {
-
-                default:
-                    return null;
-            }
-        }
-
-        @Override
-        protected void clear()
-        {
-        }
-
-        @Override
-        protected void reset()
-        {
-            _field = 0;
-        }
-    }
 
     private static Factory<DeleteOnClose> FACTORY = new Factory<DeleteOnClose>()
     {
 
-        public ValueWriter<DeleteOnClose> newInstance(Registry registry)
+        @Override
+        public ValueWriter<DeleteOnClose> newInstance(final Registry registry, final DeleteOnClose object)
         {
             return new DeleteOnCloseWriter(registry);
         }

Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/DeleteOnNoLinksOrMessagesWriter.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/type/messaging/codec/DeleteOnNoLinksOrMessagesWriter.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/type/messaging/codec/DeleteOnNoLinksOrMessagesWriter.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/DeleteOnNoLinksOrMessagesWriter.java Sun Dec 11 16:01:06 2016
@@ -24,111 +24,27 @@
 package org.apache.qpid.server.protocol.v1_0.type.messaging.codec;
 
 import org.apache.qpid.server.protocol.v1_0.codec.AbstractDescribedTypeWriter;
-import org.apache.qpid.server.protocol.v1_0.codec.AbstractListWriter;
+import org.apache.qpid.server.protocol.v1_0.codec.ListWriter;
+import org.apache.qpid.server.protocol.v1_0.codec.UnsignedLongWriter;
 import org.apache.qpid.server.protocol.v1_0.codec.ValueWriter;
-
 import org.apache.qpid.server.protocol.v1_0.type.UnsignedLong;
 import org.apache.qpid.server.protocol.v1_0.type.messaging.DeleteOnNoLinksOrMessages;
 
 public class DeleteOnNoLinksOrMessagesWriter extends AbstractDescribedTypeWriter<DeleteOnNoLinksOrMessages>
 {
-    private DeleteOnNoLinksOrMessages _value;
-    private int _count = -1;
+    private static final ValueWriter<UnsignedLong> DESCRIPTOR_WRITER = UnsignedLongWriter.getWriter((byte) 0x2E);
 
     public DeleteOnNoLinksOrMessagesWriter(final Registry registry)
     {
-        super(registry);
-    }
-
-    @Override
-    protected void onSetValue(final DeleteOnNoLinksOrMessages value)
-    {
-        _value = value;
-        _count = calculateCount();
-    }
-
-    private int calculateCount()
-    {
-
-
-        return 0;
-    }
-
-    @Override
-    protected void clear()
-    {
-        _value = null;
-        _count = -1;
-    }
-
-
-    protected Object getDescriptor()
-    {
-        return UnsignedLong.valueOf(0x000000000000002eL);
-    }
-
-    @Override
-    protected ValueWriter createDescribedWriter()
-    {
-        final Writer writer = new Writer(getRegistry());
-        writer.setValue(_value);
-        return writer;
-    }
-
-    private class Writer extends AbstractListWriter<DeleteOnNoLinksOrMessages>
-    {
-        private int _field;
-
-        public Writer(final Registry registry)
-        {
-            super(registry);
-        }
-
-        @Override
-        protected void onSetValue(final DeleteOnNoLinksOrMessages value)
-        {
-            reset();
-        }
-
-        @Override
-        protected int getCount()
-        {
-            return _count;
-        }
-
-        @Override
-        protected boolean hasNext()
-        {
-            return _field < _count;
-        }
-
-        @Override
-        protected Object next()
-        {
-            switch(_field++)
-            {
-
-                default:
-                    return null;
-            }
-        }
-
-        @Override
-        protected void clear()
-        {
-        }
-
-        @Override
-        protected void reset()
-        {
-            _field = 0;
-        }
+        super(DESCRIPTOR_WRITER, ListWriter.EMPTY_LIST_WRITER);
     }
 
     private static Factory<DeleteOnNoLinksOrMessages> FACTORY = new Factory<DeleteOnNoLinksOrMessages>()
     {
 
-        public ValueWriter<DeleteOnNoLinksOrMessages> newInstance(Registry registry)
+        @Override
+        public ValueWriter<DeleteOnNoLinksOrMessages> newInstance(final Registry registry,
+                                                                  final DeleteOnNoLinksOrMessages object)
         {
             return new DeleteOnNoLinksOrMessagesWriter(registry);
         }



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


Mime
View raw message