You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by rg...@apache.org on 2016/12/06 14:23:00 UTC
svn commit: r1772901 [3/5] - in /qpid/java/trunk:
broker-core/src/main/java/org/apache/qpid/server/queue/
broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/
broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpi...
Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/SymbolTypeConstructor.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/SymbolTypeConstructor.java?rev=1772901&r1=1772900&r2=1772901&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/SymbolTypeConstructor.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/SymbolTypeConstructor.java Tue Dec 6 14:22:59 2016
@@ -22,14 +22,16 @@ package org.apache.qpid.server.protocol.
import java.nio.CharBuffer;
import java.nio.charset.Charset;
+import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException;
import org.apache.qpid.server.protocol.v1_0.type.Symbol;
import org.apache.qpid.bytebuffer.QpidByteBuffer;
+import org.apache.qpid.server.protocol.v1_0.type.transport.ConnectionError;
-public class SymbolTypeConstructor extends VariableWidthTypeConstructor
+public class SymbolTypeConstructor extends VariableWidthTypeConstructor<Symbol>
{
private static final Charset ASCII = Charset.forName("US-ASCII");
@@ -47,20 +49,8 @@ public class SymbolTypeConstructor exten
super(size);
}
- @Override
- public Object construct(final QpidByteBuffer in, boolean isCopy, ValueHandler handler) throws AmqpErrorException
+ private Symbol constructFromSingleBuffer(final QpidByteBuffer in, final int size)
{
- int size;
-
- if(getSize() == 1)
- {
- size = in.get() & 0xFF;
- }
- else
- {
- size = in.getInt();
- }
-
BinaryString binaryStr;
if (in.hasArray())
{
@@ -96,7 +86,55 @@ public class SymbolTypeConstructor exten
}
return symbolVal;
-
}
+ @Override
+ public Symbol construct(final List<QpidByteBuffer> in, final ValueHandler handler) throws AmqpErrorException
+ {
+
+ int size;
+
+ if(getSize() == 1)
+ {
+ size = QpidByteBufferUtils.get(in) & 0xFF;
+ }
+ else
+ {
+ size = QpidByteBufferUtils.getInt(in);
+ }
+
+ if(!QpidByteBufferUtils.hasRemaining(in, size))
+ {
+ org.apache.qpid.server.protocol.v1_0.type.transport.Error error = new org.apache.qpid.server.protocol.v1_0.type.transport.Error();
+ error.setCondition(ConnectionError.FRAMING_ERROR);
+ error.setDescription("Cannot construct symbol: insufficient input data");
+ throw new AmqpErrorException(error);
+ }
+
+ for(int i = 0; i<in.size(); i++)
+ {
+ QpidByteBuffer buf = in.get(i);
+ if(buf.hasRemaining())
+ {
+ if(buf.remaining() >= size)
+ {
+ return constructFromSingleBuffer(buf, size);
+ }
+ break;
+ }
+ }
+
+ byte[] data = new byte[size];
+ QpidByteBufferUtils.get(in, data);
+ final BinaryString binaryStr = new BinaryString(data);
+
+ Symbol symbolVal = SYMBOL_MAP.get(binaryStr);
+ if(symbolVal == null)
+ {
+ symbolVal = Symbol.valueOf(new String(data, ASCII));
+ SYMBOL_MAP.putIfAbsent(binaryStr, symbolVal);
+ }
+
+ return symbolVal;
+ }
}
Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/TimestampTypeConstructor.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/TimestampTypeConstructor.java?rev=1772901&r1=1772900&r2=1772901&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/TimestampTypeConstructor.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/TimestampTypeConstructor.java Tue Dec 6 14:22:59 2016
@@ -20,13 +20,14 @@
*/
package org.apache.qpid.server.protocol.v1_0.codec;
-import org.apache.qpid.server.protocol.v1_0.type.*;
-import org.apache.qpid.server.protocol.v1_0.type.transport.ConnectionError;
-import org.apache.qpid.bytebuffer.QpidByteBuffer;
-
import java.util.Date;
+import java.util.List;
-public class TimestampTypeConstructor implements TypeConstructor
+import org.apache.qpid.bytebuffer.QpidByteBuffer;
+import org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException;
+import org.apache.qpid.server.protocol.v1_0.type.transport.ConnectionError;
+
+public class TimestampTypeConstructor implements TypeConstructor<Date>
{
private static final TimestampTypeConstructor INSTANCE = new TimestampTypeConstructor();
@@ -40,11 +41,12 @@ public class TimestampTypeConstructor im
{
}
- public Object construct(final QpidByteBuffer in, ValueHandler handler) throws AmqpErrorException
+ @Override
+ public Date construct(final List<QpidByteBuffer> in, final ValueHandler handler) throws AmqpErrorException
{
- if(in.remaining()>=8)
+ if(QpidByteBufferUtils.hasRemaining(in, 8))
{
- long l = in.getLong();
+ long l = QpidByteBufferUtils.getLong(in);
return new Date(l);
}
else
@@ -56,5 +58,4 @@ public class TimestampTypeConstructor im
}
}
-
}
Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/TypeConstructor.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/TypeConstructor.java?rev=1772901&r1=1772900&r2=1772901&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/TypeConstructor.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/TypeConstructor.java Tue Dec 6 14:22:59 2016
@@ -20,12 +20,14 @@
*/
package org.apache.qpid.server.protocol.v1_0.codec;
-import org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException;
+import java.util.List;
+
import org.apache.qpid.bytebuffer.QpidByteBuffer;
+import org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException;
public interface TypeConstructor<T>
{
- public T construct(final QpidByteBuffer in, ValueHandler handler) throws AmqpErrorException;
+ T construct(final List<QpidByteBuffer> in, ValueHandler handler) throws AmqpErrorException;
}
Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/UByteTypeConstructor.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/UByteTypeConstructor.java?rev=1772901&r1=1772900&r2=1772901&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/UByteTypeConstructor.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/UByteTypeConstructor.java Tue Dec 6 14:22:59 2016
@@ -20,12 +20,14 @@
*/
package org.apache.qpid.server.protocol.v1_0.codec;
+import java.util.List;
+
import org.apache.qpid.server.protocol.v1_0.type.*;
import org.apache.qpid.server.protocol.v1_0.type.transport.Error;
import org.apache.qpid.server.protocol.v1_0.type.transport.ConnectionError;
import org.apache.qpid.bytebuffer.QpidByteBuffer;
-public class UByteTypeConstructor implements TypeConstructor
+public class UByteTypeConstructor implements TypeConstructor<UnsignedByte>
{
private static final UByteTypeConstructor INSTANCE = new UByteTypeConstructor();
@@ -39,11 +41,12 @@ public class UByteTypeConstructor implem
{
}
- public Object construct(final QpidByteBuffer in, ValueHandler handler) throws AmqpErrorException
+ @Override
+ public UnsignedByte construct(final List<QpidByteBuffer> in, final ValueHandler handler) throws AmqpErrorException
{
- if(in.hasRemaining())
+ if(QpidByteBufferUtils.hasRemaining(in))
{
- byte b = in.get();
+ byte b = QpidByteBufferUtils.get(in);
return UnsignedByte.valueOf(b);
}
else
@@ -54,5 +57,4 @@ public class UByteTypeConstructor implem
throw new AmqpErrorException(error);
}
}
-
}
Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/UIntTypeConstructor.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/UIntTypeConstructor.java?rev=1772901&r1=1772900&r2=1772901&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/UIntTypeConstructor.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/UIntTypeConstructor.java Tue Dec 6 14:22:59 2016
@@ -20,11 +20,13 @@
*/
package org.apache.qpid.server.protocol.v1_0.codec;
+import java.util.List;
+
import org.apache.qpid.server.protocol.v1_0.type.*;
import org.apache.qpid.server.protocol.v1_0.type.transport.ConnectionError;
import org.apache.qpid.bytebuffer.QpidByteBuffer;
-public class UIntTypeConstructor implements TypeConstructor
+public class UIntTypeConstructor implements TypeConstructor<UnsignedInteger>
{
private static final UIntTypeConstructor INSTANCE = new UIntTypeConstructor();
@@ -38,11 +40,13 @@ public class UIntTypeConstructor impleme
{
}
- public Object construct(final QpidByteBuffer in, ValueHandler handler) throws AmqpErrorException
+ @Override
+ public UnsignedInteger construct(final List<QpidByteBuffer> in, final ValueHandler handler)
+ throws AmqpErrorException
{
- if(in.remaining()>=4)
+ if(QpidByteBufferUtils.hasRemaining(in, 4))
{
- final int i = in.getInt();
+ final int i = QpidByteBufferUtils.getInt(in);
return UnsignedInteger.valueOf(i);
}
else
@@ -54,5 +58,4 @@ public class UIntTypeConstructor impleme
}
}
-
}
Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/ULongTypeConstructor.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/ULongTypeConstructor.java?rev=1772901&r1=1772900&r2=1772901&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/ULongTypeConstructor.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/ULongTypeConstructor.java Tue Dec 6 14:22:59 2016
@@ -20,11 +20,13 @@
*/
package org.apache.qpid.server.protocol.v1_0.codec;
+import java.util.List;
+
import org.apache.qpid.server.protocol.v1_0.type.*;
import org.apache.qpid.server.protocol.v1_0.type.transport.ConnectionError;
import org.apache.qpid.bytebuffer.QpidByteBuffer;
-public class ULongTypeConstructor implements TypeConstructor
+public class ULongTypeConstructor implements TypeConstructor<UnsignedLong>
{
private static final ULongTypeConstructor INSTANCE = new ULongTypeConstructor();
@@ -38,11 +40,12 @@ public class ULongTypeConstructor implem
{
}
- public Object construct(final QpidByteBuffer in, ValueHandler handler) throws AmqpErrorException
+ @Override
+ public UnsignedLong construct(final List<QpidByteBuffer> in, final ValueHandler handler) throws AmqpErrorException
{
- if(in.remaining()>=8)
+ if(QpidByteBufferUtils.hasRemaining(in, 8))
{
- long l = in.getLong();
+ long l = QpidByteBufferUtils.getLong(in);
return UnsignedLong.valueOf(l);
@@ -56,5 +59,4 @@ public class ULongTypeConstructor implem
}
}
-
}
Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/UShortTypeConstructor.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/UShortTypeConstructor.java?rev=1772901&r1=1772900&r2=1772901&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/UShortTypeConstructor.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/UShortTypeConstructor.java Tue Dec 6 14:22:59 2016
@@ -20,12 +20,14 @@
*/
package org.apache.qpid.server.protocol.v1_0.codec;
+import java.util.List;
+
import org.apache.qpid.server.protocol.v1_0.type.*;
import org.apache.qpid.server.protocol.v1_0.type.transport.Error;
import org.apache.qpid.server.protocol.v1_0.type.transport.ConnectionError;
import org.apache.qpid.bytebuffer.QpidByteBuffer;
-public class UShortTypeConstructor implements TypeConstructor
+public class UShortTypeConstructor implements TypeConstructor<UnsignedShort>
{
private static final UShortTypeConstructor INSTANCE = new UShortTypeConstructor();
@@ -39,11 +41,12 @@ public class UShortTypeConstructor imple
{
}
- public Object construct(final QpidByteBuffer in, ValueHandler handler) throws AmqpErrorException
+ @Override
+ public UnsignedShort construct(final List<QpidByteBuffer> in, final ValueHandler handler) throws AmqpErrorException
{
- if(in.remaining()>=2)
+ if(QpidByteBufferUtils.hasRemaining(in, 2))
{
- short s = in.getShort();
+ short s = QpidByteBufferUtils.getShort(in);
return UnsignedShort.valueOf(s);
}
else
@@ -55,5 +58,4 @@ public class UShortTypeConstructor imple
}
}
-
}
Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/UUIDTypeConstructor.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/UUIDTypeConstructor.java?rev=1772901&r1=1772900&r2=1772901&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/UUIDTypeConstructor.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/UUIDTypeConstructor.java Tue Dec 6 14:22:59 2016
@@ -20,14 +20,15 @@
*/
package org.apache.qpid.server.protocol.v1_0.codec;
-import org.apache.qpid.server.protocol.v1_0.type.*;
-import org.apache.qpid.server.protocol.v1_0.type.transport.Error;
-import org.apache.qpid.server.protocol.v1_0.type.transport.ConnectionError;
-import org.apache.qpid.bytebuffer.QpidByteBuffer;
-
+import java.util.List;
import java.util.UUID;
-public class UUIDTypeConstructor implements TypeConstructor
+import org.apache.qpid.bytebuffer.QpidByteBuffer;
+import org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException;
+import org.apache.qpid.server.protocol.v1_0.type.transport.ConnectionError;
+import org.apache.qpid.server.protocol.v1_0.type.transport.Error;
+
+public class UUIDTypeConstructor implements TypeConstructor<UUID>
{
private static final UUIDTypeConstructor INSTANCE = new UUIDTypeConstructor();
@@ -41,12 +42,13 @@ public class UUIDTypeConstructor impleme
{
}
- public Object construct(final QpidByteBuffer in, ValueHandler handler) throws AmqpErrorException
+ @Override
+ public UUID construct(final List<QpidByteBuffer> in, final ValueHandler handler) throws AmqpErrorException
{
- if(in.remaining()>=16)
+ if(QpidByteBufferUtils.hasRemaining(in, 16))
{
- long msb = in.getLong();
- long lsb = in.getLong();
+ long msb = QpidByteBufferUtils.getLong(in);
+ long lsb = QpidByteBufferUtils.getLong(in);
return new UUID(msb, lsb);
}
else
@@ -58,5 +60,4 @@ public class UUIDTypeConstructor impleme
}
}
-
}
Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/ValueHandler.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/ValueHandler.java?rev=1772901&r1=1772900&r2=1772901&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/ValueHandler.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/ValueHandler.java Tue Dec 6 14:22:59 2016
@@ -20,12 +20,15 @@
*/
package org.apache.qpid.server.protocol.v1_0.codec;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.qpid.bytebuffer.QpidByteBuffer;
import org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException;
import org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError;
import org.apache.qpid.server.protocol.v1_0.type.transport.ConnectionError;
-import org.apache.qpid.bytebuffer.QpidByteBuffer;
-
-import java.nio.charset.Charset;
public class ValueHandler implements DescribedTypeConstructorRegistry.Source
{
@@ -85,32 +88,60 @@ public class ValueHandler implements Des
_describedTypeConstructorRegistry = registry;
}
- public Object parse(final QpidByteBuffer in) throws AmqpErrorException
+
+ public Object parse(QpidByteBuffer in) throws AmqpErrorException
+ {
+ return parse(new ArrayList<>(Arrays.asList(in)));
+ }
+ public Object parse(final List<QpidByteBuffer> in) throws AmqpErrorException
{
TypeConstructor constructor = readConstructor(in);
return constructor.construct(in, this);
}
- public TypeConstructor readConstructor(QpidByteBuffer in) throws AmqpErrorException
+ public TypeConstructor readConstructor(List<QpidByteBuffer> in) throws AmqpErrorException
{
- if(!in.hasRemaining())
+ if(!QpidByteBufferUtils.hasRemaining(in))
{
throw new AmqpErrorException(AmqpError.DECODE_ERROR, "Insufficient data - expected type, no data remaining");
}
- byte formatCode = in.get();
+ int firstBufferWithAvailable = 0;
+ if(in.size() > 1)
+ {
+ for(int i = 0; i < in.size(); i++)
+ {
+ if(in.get(i).hasRemaining())
+ {
+ firstBufferWithAvailable = i;
+ break;
+ }
+ }
+ }
+ byte formatCode = QpidByteBufferUtils.get(in);
if(formatCode == DESCRIBED_TYPE)
{
+ int[] originalPositions = new int[in.size()-firstBufferWithAvailable];
+
+ for(int i = firstBufferWithAvailable; i < in.size(); i++)
+ {
+ int position = in.get(i).position();
+ if(i==firstBufferWithAvailable)
+ {
+ position--;
+ }
+ originalPositions[i] = position;
+ }
+
Object descriptor = parse(in);
DescribedTypeConstructor describedTypeConstructor = _describedTypeConstructorRegistry.getConstructor(descriptor);
if(describedTypeConstructor==null)
{
describedTypeConstructor=new DefaultDescribedTypeConstructor(descriptor);
}
- TypeConstructor typeConstructor = readConstructor(in);
- return describedTypeConstructor.construct(typeConstructor);
+ return describedTypeConstructor.construct(descriptor, in, originalPositions, this);
}
else
@@ -138,9 +169,6 @@ public class ValueHandler implements Des
}
-
-
-
@Override
public String toString()
{
Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/VariableWidthTypeConstructor.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/VariableWidthTypeConstructor.java?rev=1772901&r1=1772900&r2=1772901&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/VariableWidthTypeConstructor.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/VariableWidthTypeConstructor.java Tue Dec 6 14:22:59 2016
@@ -20,10 +20,7 @@
*/
package org.apache.qpid.server.protocol.v1_0.codec;
-import org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException;
-import org.apache.qpid.bytebuffer.QpidByteBuffer;
-
-public abstract class VariableWidthTypeConstructor implements TypeConstructor
+public abstract class VariableWidthTypeConstructor<T> implements TypeConstructor<T>
{
protected int _size;
@@ -32,16 +29,10 @@ public abstract class VariableWidthTypeC
_size = size;
}
- public Object construct(final QpidByteBuffer in, ValueHandler handler) throws AmqpErrorException
- {
- return construct(in, false, handler);
- }
-
public int getSize()
{
return _size;
}
- public abstract Object construct(QpidByteBuffer in, boolean isCopy, ValueHandler handler) throws AmqpErrorException;
}
Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/ZeroListConstructor.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/ZeroListConstructor.java?rev=1772901&r1=1772900&r2=1772901&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/ZeroListConstructor.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/ZeroListConstructor.java Tue Dec 6 14:22:59 2016
@@ -19,12 +19,12 @@
package org.apache.qpid.server.protocol.v1_0.codec;
-import org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException;
-import org.apache.qpid.bytebuffer.QpidByteBuffer;
-
import java.util.Collections;
import java.util.List;
+import org.apache.qpid.bytebuffer.QpidByteBuffer;
+import org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException;
+
class ZeroListConstructor implements TypeConstructor<List>
{
private static final ZeroListConstructor INSTANCE = new ZeroListConstructor();
@@ -33,7 +33,8 @@ class ZeroListConstructor implements Typ
{
}
- public List construct(final QpidByteBuffer in, final ValueHandler handler) throws AmqpErrorException
+ @Override
+ public List construct(final List<QpidByteBuffer> in, final ValueHandler handler) throws AmqpErrorException
{
return Collections.EMPTY_LIST;
}
Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/ZeroUIntConstructor.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/ZeroUIntConstructor.java?rev=1772901&r1=1772900&r2=1772901&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/ZeroUIntConstructor.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/ZeroUIntConstructor.java Tue Dec 6 14:22:59 2016
@@ -19,6 +19,8 @@
package org.apache.qpid.server.protocol.v1_0.codec;
+import java.util.List;
+
import org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException;
import org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger;
import org.apache.qpid.bytebuffer.QpidByteBuffer;
@@ -31,7 +33,9 @@ class ZeroUIntConstructor implements Typ
{
}
- public UnsignedInteger construct(final QpidByteBuffer in, final ValueHandler handler) throws AmqpErrorException
+ @Override
+ public UnsignedInteger construct(final List<QpidByteBuffer> in, final ValueHandler handler)
+ throws AmqpErrorException
{
return UnsignedInteger.ZERO;
}
Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/ZeroULongConstructor.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/ZeroULongConstructor.java?rev=1772901&r1=1772900&r2=1772901&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/ZeroULongConstructor.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/codec/ZeroULongConstructor.java Tue Dec 6 14:22:59 2016
@@ -19,6 +19,8 @@
package org.apache.qpid.server.protocol.v1_0.codec;
+import java.util.List;
+
import org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException;
import org.apache.qpid.server.protocol.v1_0.type.UnsignedLong;
import org.apache.qpid.bytebuffer.QpidByteBuffer;
@@ -31,7 +33,8 @@ class ZeroULongConstructor implements Ty
{
}
- public UnsignedLong construct(final QpidByteBuffer in, final ValueHandler handler) throws AmqpErrorException
+ @Override
+ public UnsignedLong construct(final List<QpidByteBuffer> in, final ValueHandler handler) throws AmqpErrorException
{
return UnsignedLong.ZERO;
}
Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/framing/AMQFrame.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/AMQFrame.java?rev=1772901&r1=1772900&r2=1772901&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/framing/AMQFrame.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/framing/AMQFrame.java Tue Dec 6 14:22:59 2016
@@ -21,26 +21,28 @@
package org.apache.qpid.server.protocol.v1_0.framing;
-import org.apache.qpid.server.protocol.v1_0.type.FrameBody;
+import java.util.List;
+
import org.apache.qpid.bytebuffer.QpidByteBuffer;
+import org.apache.qpid.server.protocol.v1_0.type.FrameBody;
public abstract class AMQFrame<T>
{
private T _frameBody;
- private QpidByteBuffer _payload;
+ private List<QpidByteBuffer> _payload;
AMQFrame(T frameBody)
{
_frameBody = frameBody;
}
- protected AMQFrame(T frameBody, QpidByteBuffer payload)
+ protected AMQFrame(T frameBody, List<QpidByteBuffer> payload)
{
_frameBody = frameBody;
_payload = payload;
}
- public QpidByteBuffer getPayload()
+ public List<QpidByteBuffer> getPayload()
{
return _payload;
}
@@ -50,7 +52,7 @@ public abstract class AMQFrame<T>
return createAMQFrame(channel, frameBody, null);
}
- public static TransportFrame createAMQFrame(short channel, FrameBody frameBody, QpidByteBuffer payload)
+ public static TransportFrame createAMQFrame(short channel, FrameBody frameBody, List<QpidByteBuffer> payload)
{
return new TransportFrame(channel, frameBody, payload);
}
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=1772901&r1=1772900&r2=1772901&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 Tue Dec 6 14:22:59 2016
@@ -20,6 +20,7 @@
*/
package org.apache.qpid.server.protocol.v1_0.framing;
+import java.util.Collections;
import java.util.Formatter;
import org.slf4j.Logger;
@@ -153,7 +154,9 @@ public class FrameHandler implements Pro
{
if (val instanceof Transfer)
{
- ((Transfer) val).setPayload(dup.slice());
+ final QpidByteBuffer payload = dup.slice();
+ ((Transfer) val).setPayload(Collections.singletonList(payload));
+ payload.dispose();
}
else
{
Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/framing/TransportFrame.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/TransportFrame.java?rev=1772901&r1=1772900&r2=1772901&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/framing/TransportFrame.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/framing/TransportFrame.java Tue Dec 6 14:22:59 2016
@@ -18,8 +18,10 @@
*/
package org.apache.qpid.server.protocol.v1_0.framing;
-import org.apache.qpid.server.protocol.v1_0.type.FrameBody;
+import java.util.List;
+
import org.apache.qpid.bytebuffer.QpidByteBuffer;
+import org.apache.qpid.server.protocol.v1_0.type.FrameBody;
public final class TransportFrame extends AMQFrame<FrameBody>
{
@@ -32,7 +34,7 @@ public final class TransportFrame extend
_channel = channel;
}
- public TransportFrame(short channel, FrameBody frameBody, QpidByteBuffer payload)
+ public TransportFrame(short channel, FrameBody frameBody, List<QpidByteBuffer> payload)
{
super(frameBody, payload);
_channel = channel;
Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/messaging/SectionDecoder.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/SectionDecoder.java?rev=1772901&r1=1772900&r2=1772901&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/messaging/SectionDecoder.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/messaging/SectionDecoder.java Tue Dec 6 14:22:59 2016
@@ -19,17 +19,17 @@
package org.apache.qpid.server.protocol.v1_0.messaging;
-import org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException;
-import org.apache.qpid.server.protocol.v1_0.type.Section;
-import org.apache.qpid.bytebuffer.QpidByteBuffer;
-
import java.util.List;
+import org.apache.qpid.bytebuffer.QpidByteBuffer;
+import org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException;
+import org.apache.qpid.server.protocol.v1_0.type.messaging.AbstractSection;
+
public interface SectionDecoder
{
- List<Section> parseAll(QpidByteBuffer buf) throws AmqpErrorException;
- Section readSection(QpidByteBuffer buf) throws AmqpErrorException;
-
+ List<AbstractSection<?>> parseAll(List<QpidByteBuffer> buf) throws AmqpErrorException;
+
+ AbstractSection<?> readSection(List<QpidByteBuffer> buf) throws AmqpErrorException;
}
Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/messaging/SectionDecoderImpl.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/SectionDecoderImpl.java?rev=1772901&r1=1772900&r2=1772901&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/messaging/SectionDecoderImpl.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/messaging/SectionDecoderImpl.java Tue Dec 6 14:22:59 2016
@@ -19,44 +19,46 @@
package org.apache.qpid.server.protocol.v1_0.messaging;
-import org.apache.qpid.server.protocol.v1_0.codec.ValueHandler;
-
-import org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException;
-import org.apache.qpid.server.protocol.v1_0.type.Section;
-import org.apache.qpid.server.protocol.v1_0.type.codec.AMQPDescribedTypeRegistry;
-import org.apache.qpid.bytebuffer.QpidByteBuffer;
-
import java.util.ArrayList;
import java.util.List;
+import org.apache.qpid.bytebuffer.QpidByteBuffer;
+import org.apache.qpid.server.protocol.v1_0.codec.QpidByteBufferUtils;
+import org.apache.qpid.server.protocol.v1_0.codec.SectionDecoderRegistry;
+import org.apache.qpid.server.protocol.v1_0.codec.ValueHandler;
+import org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException;
+import org.apache.qpid.server.protocol.v1_0.type.messaging.AbstractSection;
+
public class SectionDecoderImpl implements SectionDecoder
{
private ValueHandler _valueHandler;
- public SectionDecoderImpl(final AMQPDescribedTypeRegistry describedTypeRegistry)
+ public SectionDecoderImpl(final SectionDecoderRegistry describedTypeRegistry)
{
_valueHandler = new ValueHandler(describedTypeRegistry);
}
- public List<Section> parseAll(QpidByteBuffer buf) throws AmqpErrorException
+ @Override
+ public List<AbstractSection<?>> parseAll(List<QpidByteBuffer> buf) throws AmqpErrorException
{
- List<Section> obj = new ArrayList<Section>();
- while(buf.hasRemaining())
+ List<AbstractSection<?>> obj = new ArrayList<>();
+ while(QpidByteBufferUtils.hasRemaining(buf))
{
- Section section = (Section) _valueHandler.parse(buf);
+ AbstractSection<?> section = (AbstractSection<?>) _valueHandler.parse(buf);
obj.add(section);
}
return obj;
}
- public Section readSection(QpidByteBuffer buf) throws AmqpErrorException
+
+ @Override
+ public AbstractSection<?> readSection(List<QpidByteBuffer> buf) throws AmqpErrorException
{
- return (Section) _valueHandler.parse(buf);
+ return (AbstractSection<?>) _valueHandler.parse(buf);
}
-
}
Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/messaging/SectionEncoder.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/SectionEncoder.java?rev=1772901&r1=1772900&r2=1772901&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/messaging/SectionEncoder.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/messaging/SectionEncoder.java Tue Dec 6 14:22:59 2016
@@ -19,6 +19,7 @@
package org.apache.qpid.server.protocol.v1_0.messaging;
+import org.apache.qpid.server.protocol.v1_0.codec.DescribedTypeConstructorRegistry;
import org.apache.qpid.server.protocol.v1_0.type.Binary;
@@ -31,4 +32,6 @@ public interface SectionEncoder
void encodeObject(Object obj);
void encodeRaw(byte[] data);
+
+ DescribedTypeConstructorRegistry getRegistry();
}
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=1772901&r1=1772900&r2=1772901&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 Tue Dec 6 14:22:59 2016
@@ -19,19 +19,19 @@
package org.apache.qpid.server.protocol.v1_0.messaging;
-import org.apache.qpid.server.protocol.v1_0.codec.ValueWriter;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.qpid.bytebuffer.QpidByteBuffer;
+import org.apache.qpid.server.protocol.v1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.server.protocol.v1_0.codec.ValueWriter;
import org.apache.qpid.server.protocol.v1_0.type.Binary;
import org.apache.qpid.server.protocol.v1_0.type.codec.AMQPDescribedTypeRegistry;
-import org.apache.qpid.bytebuffer.QpidByteBuffer;
-
-import java.util.ArrayList;
-import java.util.List;
public class SectionEncoderImpl implements SectionEncoder
{
private static final QpidByteBuffer EMPTY_BYTE_BUFFER = QpidByteBuffer.wrap(new byte[0]);
- private ValueWriter.Registry _registry;
+ private AMQPDescribedTypeRegistry _registry;
private int _totalSize = 0;
@@ -108,4 +108,9 @@ public class SectionEncoderImpl implemen
_totalSize += data.length;
}
+ @Override
+ public DescribedTypeConstructorRegistry getRegistry()
+ {
+ return _registry;
+ }
}
Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/Section.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/Section.java?rev=1772901&r1=1772900&r2=1772901&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/Section.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/Section.java Tue Dec 6 14:22:59 2016
@@ -18,10 +18,8 @@
*/
package org.apache.qpid.server.protocol.v1_0.type;
-import org.apache.qpid.server.protocol.v1_0.messaging.SectionEncoder;
-
-public interface Section
+public interface Section<T>
{
+ T getValue();
- Binary encode(SectionEncoder encoder);
}
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=1772901&r1=1772900&r2=1772901&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 Tue Dec 6 14:22:59 2016
@@ -69,13 +69,12 @@ public class AMQPDescribedTypeRegistry i
{
private final Map<Object, DescribedTypeConstructor> _constructorRegistry = new HashMap<Object, DescribedTypeConstructor>();
+ private final Map<Object, DescribedTypeConstructor> _sectionDecoderRegistryMap = new HashMap<Object, DescribedTypeConstructor>();
+
- public void register(Object descriptor, DescribedTypeConstructor constructor)
- {
- _constructorRegistry.put(descriptor, constructor);
- }
- public void register(Object descriptor, DescribedTypeConstructor constructor, TypeConstructor describedConstructor)
+
+ public void register(Object descriptor, DescribedTypeConstructor constructor)
{
_constructorRegistry.put(descriptor, constructor);
}
@@ -87,6 +86,17 @@ public class AMQPDescribedTypeRegistry i
private AMQPDescribedTypeRegistry()
{
+ PropertiesSectionConstructor.register(_sectionDecoderRegistry);
+ HeaderSectionConstructor.register(_sectionDecoderRegistry);
+ DeliveryAnnotationsSectionConstructor.register(_sectionDecoderRegistry);
+ MessageAnnotationsSectionConstructor.register(_sectionDecoderRegistry);
+ ApplicationPropertiesSectionConstructor.register(_sectionDecoderRegistry);
+
+ DataSectionConstructor.register(_sectionDecoderRegistry);
+ AmqpValueSectionConstructor.register(_sectionDecoderRegistry);
+ AmqpSequenceSectionConstructor.register(_sectionDecoderRegistry);
+
+ FooterSectionConstructor.register(_sectionDecoderRegistry);
}
public AMQPDescribedTypeRegistry registerTransportLayer()
@@ -370,5 +380,30 @@ public class AMQPDescribedTypeRegistry i
return (ValueWriter<V>) _writerMap.put(clazz, writer);
}
+ private final SectionDecoderRegistry _sectionDecoderRegistry = new SectionDecoderRegistry()
+ {
+ @Override
+ public DescribedTypeConstructorRegistry getUnderlyingRegistry()
+ {
+ return AMQPDescribedTypeRegistry.this;
+ }
+
+ @Override
+ public void register(final Object descriptor, final DescribedTypeConstructor constructor)
+ {
+ _sectionDecoderRegistryMap.put(descriptor, constructor);
+ }
+
+ @Override
+ public DescribedTypeConstructor getConstructor(final Object descriptor)
+ {
+ return _sectionDecoderRegistryMap.get(descriptor);
+ }
+ };
+
+ public SectionDecoderRegistry getSectionDecoderRegistry()
+ {
+ return _sectionDecoderRegistry;
+ }
}
Added: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/AbstractSection.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/AbstractSection.java?rev=1772901&view=auto
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/AbstractSection.java (added)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/AbstractSection.java Tue Dec 6 14:22:59 2016
@@ -0,0 +1,77 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.server.protocol.v1_0.type.messaging;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.qpid.bytebuffer.QpidByteBuffer;
+import org.apache.qpid.server.protocol.v1_0.codec.QpidByteBufferUtils;
+import org.apache.qpid.server.protocol.v1_0.type.Section;
+import org.apache.qpid.server.protocol.v1_0.type.messaging.codec.EncodingRetaining;
+
+public abstract class AbstractSection<T> implements Section<T>, EncodingRetaining
+{
+ private List<QpidByteBuffer> _encodedForm;
+
+ @Override
+ public final void setEncodedForm(final List<QpidByteBuffer> encodedForm)
+ {
+ _encodedForm = encodedForm;
+ }
+
+ @Override
+ public final List<QpidByteBuffer> getEncodedForm()
+ {
+ List<QpidByteBuffer> returnVal = new ArrayList<>(_encodedForm.size());
+ for(int i = 0; i < _encodedForm.size(); i++)
+ {
+ returnVal.add(_encodedForm.get(i).duplicate());
+ }
+ return returnVal;
+ }
+
+ @Override
+ public final void dispose()
+ {
+ for(int i = 0; i < _encodedForm.size(); i++)
+ {
+ _encodedForm.get(i).dispose();
+ }
+ _encodedForm = null;
+
+ }
+
+ @Override
+ public final long getEncodedSize()
+ {
+ return QpidByteBufferUtils.remaining(_encodedForm);
+ }
+
+ @Override
+ public void writeTo(final QpidByteBuffer dest)
+ {
+ for(QpidByteBuffer buf : _encodedForm)
+ {
+ dest.putCopyOf(buf);
+ }
+ }
+}
Propchange: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/AbstractSection.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/AmqpSequence.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/AmqpSequence.java?rev=1772901&r1=1772900&r2=1772901&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/AmqpSequence.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/AmqpSequence.java Tue Dec 6 14:22:59 2016
@@ -24,19 +24,12 @@
package org.apache.qpid.server.protocol.v1_0.type.messaging;
-import org.apache.qpid.server.protocol.v1_0.messaging.SectionEncoder;
-
-
import java.util.List;
+import org.apache.qpid.server.protocol.v1_0.type.Section;
-import org.apache.qpid.server.protocol.v1_0.type.*;
-
-public class AmqpSequence
- implements Section
- {
-
-
+public class AmqpSequence implements Section<List>
+{
private final List _value;
@@ -51,20 +44,10 @@ public class AmqpSequence
}
+ @Override
+ public String toString()
+ {
+ return "AmqpSequence{" + _value + '}';
+ }
-
- public Binary encode(final SectionEncoder encoder)
- {
- encoder.reset();
- encoder.encodeObject(this);
- return encoder.getEncoding();
- }
-
- @Override
- public String toString()
- {
- return "AmqpSequence{" +
- _value +
- '}';
- }
- }
+}
Added: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/AmqpSequenceSection.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/AmqpSequenceSection.java?rev=1772901&view=auto
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/AmqpSequenceSection.java (added)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/AmqpSequenceSection.java Tue Dec 6 14:22:59 2016
@@ -0,0 +1,98 @@
+/*
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*/
+
+package org.apache.qpid.server.protocol.v1_0.type.messaging;
+
+import java.util.List;
+
+import org.apache.qpid.bytebuffer.QpidByteBuffer;
+import org.apache.qpid.server.protocol.v1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.server.protocol.v1_0.codec.QpidByteBufferUtils;
+import org.apache.qpid.server.protocol.v1_0.codec.ValueHandler;
+import org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException;
+import org.apache.qpid.server.protocol.v1_0.type.messaging.codec.AmqpSequenceConstructor;
+
+public class AmqpSequenceSection extends AbstractSection<List>
+{
+
+ private final DescribedTypeConstructorRegistry _typeRegistry;
+ private List _value;
+
+ public AmqpSequenceSection(final DescribedTypeConstructorRegistry describedTypeRegistry)
+ {
+ _typeRegistry = describedTypeRegistry;
+ }
+
+ public AmqpSequenceSection(final AmqpSequence sequence,
+ final List<QpidByteBuffer> encodedForm,
+ final DescribedTypeConstructorRegistry registry)
+ {
+ _value = sequence.getValue();
+ _typeRegistry = registry;
+ setEncodedForm(encodedForm);
+ }
+
+ @Override
+ public String toString()
+ {
+ return getValue().toString();
+ }
+
+ @Override
+ public synchronized List getValue()
+ {
+ if(_value == null)
+ {
+ decode();
+ }
+ return _value;
+ }
+
+ private void decode()
+ {
+ try
+ {
+
+ List<QpidByteBuffer> input = getEncodedForm();
+ int[] originalPositions = new int[input.size()];
+ for(int i = 0; i < input.size(); i++)
+ {
+ originalPositions[i] = input.get(i).position();
+ }
+ int describedByte = QpidByteBufferUtils.get(input);
+ ValueHandler handler = new ValueHandler(_typeRegistry);
+ Object descriptor = handler.parse(input);
+ AmqpSequenceConstructor constructor = new AmqpSequenceConstructor();
+ _value = constructor.construct(descriptor, input, originalPositions, handler).construct(input, handler).getValue();
+ for(int i = 0; i < input.size(); i++)
+ {
+ input.get(i).dispose();
+ }
+
+ }
+ catch (AmqpErrorException e)
+ {
+ // TODO
+ e.printStackTrace();
+ }
+ // TODO
+ }
+}
Propchange: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/AmqpSequenceSection.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/AmqpValue.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/AmqpValue.java?rev=1772901&r1=1772900&r2=1772901&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/AmqpValue.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/AmqpValue.java Tue Dec 6 14:22:59 2016
@@ -24,15 +24,10 @@
package org.apache.qpid.server.protocol.v1_0.type.messaging;
-import org.apache.qpid.server.protocol.v1_0.messaging.SectionEncoder;
-
-
-import org.apache.qpid.server.protocol.v1_0.type.*;
-
-public class AmqpValue
- implements Section
- {
+import org.apache.qpid.server.protocol.v1_0.type.Section;
+public class AmqpValue implements Section<Object>
+{
private final Object _value;
@@ -42,25 +37,18 @@ public class AmqpValue
_value = value;
}
+ @Override
public Object getValue()
{
return _value;
}
+ @Override
+ public String toString()
+ {
+ return "AmqpValue{(" + _value.getClass().getName() + ')' + _value + '}';
+ }
- public Binary encode(final SectionEncoder encoder)
- {
- encoder.reset();
- encoder.encodeObject(this);
- return encoder.getEncoding();
- }
-
-
- @Override
- public String toString()
- {
- return "AmqpValue{(" + _value.getClass().getName() + ')' + _value + '}';
- }
- }
+}
Added: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/AmqpValueSection.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/AmqpValueSection.java?rev=1772901&view=auto
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/AmqpValueSection.java (added)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/AmqpValueSection.java Tue Dec 6 14:22:59 2016
@@ -0,0 +1,98 @@
+/*
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*/
+
+package org.apache.qpid.server.protocol.v1_0.type.messaging;
+
+import java.util.List;
+
+import org.apache.qpid.bytebuffer.QpidByteBuffer;
+import org.apache.qpid.server.protocol.v1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.server.protocol.v1_0.codec.QpidByteBufferUtils;
+import org.apache.qpid.server.protocol.v1_0.codec.ValueHandler;
+import org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException;
+import org.apache.qpid.server.protocol.v1_0.type.messaging.codec.AmqpValueConstructor;
+
+public class AmqpValueSection extends AbstractSection<Object>
+{
+
+ private final DescribedTypeConstructorRegistry _typeRegistry;
+ private Object _value;
+
+ public AmqpValueSection(final DescribedTypeConstructorRegistry describedTypeRegistry)
+ {
+ _typeRegistry = describedTypeRegistry;
+ }
+
+ public AmqpValueSection(final AmqpValue amqpValue,
+ final List<QpidByteBuffer> encodedForm,
+ final DescribedTypeConstructorRegistry registry)
+ {
+ _value = amqpValue.getValue();
+ _typeRegistry = registry;
+ setEncodedForm(encodedForm);
+ }
+
+ @Override
+ public String toString()
+ {
+ return getValue().toString();
+ }
+
+ @Override
+ public synchronized Object getValue()
+ {
+ if(_value == null)
+ {
+ decode();
+ }
+ return _value;
+ }
+
+ private void decode()
+ {
+ try
+ {
+
+ List<QpidByteBuffer> input = getEncodedForm();
+ int[] originalPositions = new int[input.size()];
+ for(int i = 0; i < input.size(); i++)
+ {
+ originalPositions[i] = input.get(i).position();
+ }
+ int describedByte = QpidByteBufferUtils.get(input);
+ ValueHandler handler = new ValueHandler(_typeRegistry);
+ Object descriptor = handler.parse(input);
+ AmqpValueConstructor constructor = new AmqpValueConstructor();
+ _value = constructor.construct(descriptor, input, originalPositions, handler).construct(input, handler).getValue();
+ for(int i = 0; i < input.size(); i++)
+ {
+ input.get(i).dispose();
+ }
+
+ }
+ catch (AmqpErrorException e)
+ {
+ // TODO
+ e.printStackTrace();
+ }
+ // TODO
+ }
+}
Propchange: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/AmqpValueSection.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/ApplicationProperties.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/ApplicationProperties.java?rev=1772901&r1=1772900&r2=1772901&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/ApplicationProperties.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/ApplicationProperties.java Tue Dec 6 14:22:59 2016
@@ -24,41 +24,23 @@
package org.apache.qpid.server.protocol.v1_0.type.messaging;
-import org.apache.qpid.server.protocol.v1_0.messaging.SectionEncoder;
-
-
import java.util.Map;
+import org.apache.qpid.server.protocol.v1_0.type.Section;
-import org.apache.qpid.server.protocol.v1_0.type.*;
-
-public class ApplicationProperties
- implements Section
- {
-
-
+public class ApplicationProperties implements Section<Map<String,Object>>
+{
- private final Map _value;
+ private final Map<String,Object> _value;
- public ApplicationProperties(Map value)
+ public ApplicationProperties(Map<String,Object> value)
{
_value = value;
}
- public Map getValue()
+ public Map<String,Object> getValue()
{
return _value;
}
-
-
-
- public Binary encode(final SectionEncoder encoder)
- {
- encoder.reset();
- encoder.encodeObject(this);
- return encoder.getEncoding();
- }
-
-
- }
+}
Added: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/ApplicationPropertiesSection.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/ApplicationPropertiesSection.java?rev=1772901&view=auto
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/ApplicationPropertiesSection.java (added)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/ApplicationPropertiesSection.java Tue Dec 6 14:22:59 2016
@@ -0,0 +1,93 @@
+/*
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*/
+
+package org.apache.qpid.server.protocol.v1_0.type.messaging;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.qpid.bytebuffer.QpidByteBuffer;
+import org.apache.qpid.server.protocol.v1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.server.protocol.v1_0.codec.QpidByteBufferUtils;
+import org.apache.qpid.server.protocol.v1_0.codec.ValueHandler;
+import org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException;
+import org.apache.qpid.server.protocol.v1_0.type.messaging.codec.ApplicationPropertiesConstructor;
+
+public class ApplicationPropertiesSection extends AbstractSection<Map<String,Object>>
+{
+ private Map<String,Object> _value;
+ private final DescribedTypeConstructorRegistry _typeRegistry;
+
+ public ApplicationPropertiesSection(DescribedTypeConstructorRegistry registry)
+ {
+ _typeRegistry = registry;
+ }
+
+ public ApplicationPropertiesSection(final ApplicationProperties applicationProperties,
+ final List<QpidByteBuffer> encodedForm,
+ final DescribedTypeConstructorRegistry registry)
+ {
+ _value = applicationProperties.getValue();
+ _typeRegistry = registry;
+ setEncodedForm(encodedForm);
+ }
+
+ @Override
+ public synchronized Map<String,Object> getValue()
+ {
+ if(_value == null)
+ {
+ decode();
+ }
+ return _value;
+ }
+
+
+ private void decode()
+ {
+ try
+ {
+
+ List<QpidByteBuffer> input = getEncodedForm();
+ int[] originalPositions = new int[input.size()];
+ for(int i = 0; i < input.size(); i++)
+ {
+ originalPositions[i] = input.get(i).position();
+ }
+ int describedByte = QpidByteBufferUtils.get(input);
+ ValueHandler handler = new ValueHandler(_typeRegistry);
+ Object descriptor = handler.parse(input);
+ ApplicationPropertiesConstructor constructor = new ApplicationPropertiesConstructor();
+ _value = constructor.construct(descriptor, input, originalPositions, handler).construct(input, handler).getValue();
+ for(int i = 0; i < input.size(); i++)
+ {
+ input.get(i).dispose();
+ }
+
+ }
+ catch (AmqpErrorException e)
+ {
+ // TODO
+ e.printStackTrace();
+ }
+ // TODO
+ }
+}
Propchange: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/ApplicationPropertiesSection.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/Data.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/Data.java?rev=1772901&r1=1772900&r2=1772901&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/Data.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/Data.java Tue Dec 6 14:22:59 2016
@@ -1,4 +1,3 @@
-
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -20,20 +19,13 @@
*
*/
-
package org.apache.qpid.server.protocol.v1_0.type.messaging;
+import org.apache.qpid.server.protocol.v1_0.type.Binary;
+import org.apache.qpid.server.protocol.v1_0.type.Section;
-import org.apache.qpid.server.protocol.v1_0.messaging.SectionEncoder;
-
-
-import org.apache.qpid.server.protocol.v1_0.type.*;
-
-public class Data
- implements Section
- {
-
-
+public class Data implements Section<Binary>
+{
private final Binary _value;
@@ -48,21 +40,9 @@ public class Data
}
-
-
- public Binary encode(final SectionEncoder encoder)
- {
- encoder.reset();
- encoder.encodeObject(this);
- return encoder.getEncoding();
- }
-
-
- @Override
- public String toString()
- {
- return "Data{" +
- _value +
- '}';
- }
- }
+ @Override
+ public String toString()
+ {
+ return "Data{" + _value + '}';
+ }
+}
Added: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/DataSection.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/DataSection.java?rev=1772901&view=auto
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/DataSection.java (added)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/DataSection.java Tue Dec 6 14:22:59 2016
@@ -0,0 +1,99 @@
+/*
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*/
+
+package org.apache.qpid.server.protocol.v1_0.type.messaging;
+
+import java.util.List;
+
+import org.apache.qpid.bytebuffer.QpidByteBuffer;
+import org.apache.qpid.server.protocol.v1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.server.protocol.v1_0.codec.QpidByteBufferUtils;
+import org.apache.qpid.server.protocol.v1_0.codec.ValueHandler;
+import org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException;
+import org.apache.qpid.server.protocol.v1_0.type.Binary;
+import org.apache.qpid.server.protocol.v1_0.type.messaging.codec.DataConstructor;
+
+public class DataSection extends AbstractSection<Binary>
+{
+
+ private final DescribedTypeConstructorRegistry _typeRegistry;
+ private Binary _value;
+
+ public DataSection(final DescribedTypeConstructorRegistry describedTypeRegistry)
+ {
+ _typeRegistry = describedTypeRegistry;
+ }
+
+ public DataSection(final Data data,
+ final List<QpidByteBuffer> encodedForm,
+ final DescribedTypeConstructorRegistry registry)
+ {
+ _value = data.getValue();
+ _typeRegistry = registry;
+ setEncodedForm(encodedForm);
+ }
+
+ @Override
+ public String toString()
+ {
+ return getValue().toString();
+ }
+
+ @Override
+ public synchronized Binary getValue()
+ {
+ if(_value == null)
+ {
+ decode();
+ }
+ return _value;
+ }
+
+ private void decode()
+ {
+ try
+ {
+
+ List<QpidByteBuffer> input = getEncodedForm();
+ int[] originalPositions = new int[input.size()];
+ for(int i = 0; i < input.size(); i++)
+ {
+ originalPositions[i] = input.get(i).position();
+ }
+ int describedByte = QpidByteBufferUtils.get(input);
+ ValueHandler handler = new ValueHandler(_typeRegistry);
+ Object descriptor = handler.parse(input);
+ DataConstructor constructor = new DataConstructor();
+ _value = constructor.construct(descriptor, input, originalPositions, handler).construct(input, handler).getValue();
+ for(int i = 0; i < input.size(); i++)
+ {
+ input.get(i).dispose();
+ }
+
+ }
+ catch (AmqpErrorException e)
+ {
+ // TODO
+ e.printStackTrace();
+ }
+ // TODO
+ }
+}
Propchange: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/DataSection.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/DeliveryAnnotations.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/DeliveryAnnotations.java?rev=1772901&r1=1772900&r2=1772901&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/DeliveryAnnotations.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/DeliveryAnnotations.java Tue Dec 6 14:22:59 2016
@@ -1,4 +1,3 @@
-
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -20,45 +19,26 @@
*
*/
-
package org.apache.qpid.server.protocol.v1_0.type.messaging;
-
-import org.apache.qpid.server.protocol.v1_0.messaging.SectionEncoder;
-
-
import java.util.Map;
+import org.apache.qpid.server.protocol.v1_0.type.Section;
+import org.apache.qpid.server.protocol.v1_0.type.Symbol;
-import org.apache.qpid.server.protocol.v1_0.type.*;
-
-public class DeliveryAnnotations
- implements Section
- {
-
+public class DeliveryAnnotations implements Section<Map<Symbol,Object>>
+{
+ private final Map<Symbol,Object> _value;
-
- private final Map _value;
-
- public DeliveryAnnotations(Map value)
+ public DeliveryAnnotations(Map<Symbol,Object> value)
{
_value = value;
}
- public Map getValue()
+ @Override
+ public Map<Symbol, Object> getValue()
{
return _value;
}
-
-
-
- public Binary encode(final SectionEncoder encoder)
- {
- encoder.reset();
- encoder.encodeObject(this);
- return encoder.getEncoding();
- }
-
-
- }
+}
Added: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/DeliveryAnnotationsSection.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/DeliveryAnnotationsSection.java?rev=1772901&view=auto
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/DeliveryAnnotationsSection.java (added)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/DeliveryAnnotationsSection.java Tue Dec 6 14:22:59 2016
@@ -0,0 +1,94 @@
+/*
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*/
+
+package org.apache.qpid.server.protocol.v1_0.type.messaging;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.qpid.bytebuffer.QpidByteBuffer;
+import org.apache.qpid.server.protocol.v1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.server.protocol.v1_0.codec.QpidByteBufferUtils;
+import org.apache.qpid.server.protocol.v1_0.codec.ValueHandler;
+import org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException;
+import org.apache.qpid.server.protocol.v1_0.type.Symbol;
+import org.apache.qpid.server.protocol.v1_0.type.messaging.codec.DeliveryAnnotationsConstructor;
+
+public class DeliveryAnnotationsSection extends AbstractSection<Map<Symbol,Object>>
+{
+ private Map<Symbol,Object> _value;
+ private final DescribedTypeConstructorRegistry _typeRegistry;
+
+ public DeliveryAnnotationsSection(DescribedTypeConstructorRegistry registry)
+ {
+ _typeRegistry = registry;
+ }
+
+ public DeliveryAnnotationsSection(final DeliveryAnnotations deliveryAnnotations,
+ final List<QpidByteBuffer> encodedForm,
+ final DescribedTypeConstructorRegistry registry)
+ {
+ _value = deliveryAnnotations.getValue();
+ _typeRegistry = registry;
+ setEncodedForm(encodedForm);
+ }
+
+ @Override
+ public synchronized Map<Symbol,Object> getValue()
+ {
+ if(_value == null)
+ {
+ decode();
+ }
+ return _value;
+ }
+
+
+ private void decode()
+ {
+ try
+ {
+
+ List<QpidByteBuffer> input = getEncodedForm();
+ int[] originalPositions = new int[input.size()];
+ for(int i = 0; i < input.size(); i++)
+ {
+ originalPositions[i] = input.get(i).position();
+ }
+ int describedByte = QpidByteBufferUtils.get(input);
+ ValueHandler handler = new ValueHandler(_typeRegistry);
+ Object descriptor = handler.parse(input);
+ DeliveryAnnotationsConstructor constructor = new DeliveryAnnotationsConstructor();
+ _value = constructor.construct(descriptor, input, originalPositions, handler).construct(input, handler).getValue();
+ for(int i = 0; i < input.size(); i++)
+ {
+ input.get(i).dispose();
+ }
+
+ }
+ catch (AmqpErrorException e)
+ {
+ // TODO
+ e.printStackTrace();
+ }
+ // TODO
+ }
+}
Propchange: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/DeliveryAnnotationsSection.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/Footer.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/Footer.java?rev=1772901&r1=1772900&r2=1772901&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/Footer.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/Footer.java Tue Dec 6 14:22:59 2016
@@ -1,4 +1,3 @@
-
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -20,51 +19,33 @@
*
*/
-
package org.apache.qpid.server.protocol.v1_0.type.messaging;
-
-import org.apache.qpid.server.protocol.v1_0.messaging.SectionEncoder;
-
-
import java.util.Map;
+import org.apache.qpid.server.protocol.v1_0.type.Section;
+import org.apache.qpid.server.protocol.v1_0.type.Symbol;
-import org.apache.qpid.server.protocol.v1_0.type.*;
-
-public class Footer
- implements Section
- {
+public class Footer implements Section<Map<Symbol,Object>>
+{
+ private final Map<Symbol,Object> _value;
+ public Footer(Map<Symbol,Object> value)
+ {
+ _value = value;
+ }
- private final Map _value;
-
- public Footer(Map value)
+ @Override
+ public Map<Symbol,Object> getValue()
{
- _value = value;
+ return _value;
}
- public Map getValue()
+ @Override
+ public String toString()
{
- return _value;
+ return "Footer{" + _value + '}';
}
-
-
-
- public Binary encode(final SectionEncoder encoder)
- {
- encoder.reset();
- encoder.encodeObject(this);
- return encoder.getEncoding();
- }
-
-
- @Override
- public String toString()
- {
- return "Footer{" + _value +
- '}';
- }
- }
+}
Added: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/FooterSection.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/FooterSection.java?rev=1772901&view=auto
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/FooterSection.java (added)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/FooterSection.java Tue Dec 6 14:22:59 2016
@@ -0,0 +1,98 @@
+/*
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*/
+
+package org.apache.qpid.server.protocol.v1_0.type.messaging;
+
+import java.util.List;
+
+import org.apache.qpid.bytebuffer.QpidByteBuffer;
+import org.apache.qpid.server.protocol.v1_0.codec.DescribedTypeConstructorRegistry;
+import org.apache.qpid.server.protocol.v1_0.codec.QpidByteBufferUtils;
+import org.apache.qpid.server.protocol.v1_0.codec.ValueHandler;
+import org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException;
+import org.apache.qpid.server.protocol.v1_0.type.messaging.codec.FooterConstructor;
+
+public class FooterSection extends AbstractSection<Footer>
+{
+
+ private final DescribedTypeConstructorRegistry _typeRegistry;
+ private Footer _footer;
+
+ public FooterSection(final DescribedTypeConstructorRegistry describedTypeRegistry)
+ {
+ _typeRegistry = describedTypeRegistry;
+ }
+
+ public FooterSection(final Footer footer,
+ final List<QpidByteBuffer> encodedForm,
+ final DescribedTypeConstructorRegistry registry)
+ {
+ _footer = footer;
+ _typeRegistry = registry;
+ setEncodedForm(encodedForm);
+ }
+
+ @Override
+ public String toString()
+ {
+ return getValue().toString();
+ }
+
+ @Override
+ public synchronized Footer getValue()
+ {
+ if(_footer == null)
+ {
+ decode();
+ }
+ return _footer;
+ }
+
+ private void decode()
+ {
+ try
+ {
+
+ List<QpidByteBuffer> input = getEncodedForm();
+ int[] originalPositions = new int[input.size()];
+ for(int i = 0; i < input.size(); i++)
+ {
+ originalPositions[i] = input.get(i).position();
+ }
+ int describedByte = QpidByteBufferUtils.get(input);
+ ValueHandler handler = new ValueHandler(_typeRegistry);
+ Object descriptor = handler.parse(input);
+ FooterConstructor constructor = new FooterConstructor();
+ _footer = constructor.construct(descriptor, input, originalPositions, handler).construct(input, handler);
+ for(int i = 0; i < input.size(); i++)
+ {
+ input.get(i).dispose();
+ }
+
+ }
+ catch (AmqpErrorException e)
+ {
+ // TODO
+ e.printStackTrace();
+ }
+ // TODO
+ }
+}
Propchange: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/FooterSection.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/Header.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/Header.java?rev=1772901&r1=1772900&r2=1772901&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/Header.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/Header.java Tue Dec 6 14:22:59 2016
@@ -24,15 +24,12 @@
package org.apache.qpid.server.protocol.v1_0.type.messaging;
-import org.apache.qpid.server.protocol.v1_0.messaging.SectionEncoder;
-
-
-import org.apache.qpid.server.protocol.v1_0.type.*;
-
-public class Header
- implements Section
- {
+import org.apache.qpid.server.protocol.v1_0.type.Section;
+import org.apache.qpid.server.protocol.v1_0.type.UnsignedByte;
+import org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger;
+public class Header implements Section<Header>
+{
private Boolean _durable;
@@ -100,45 +97,45 @@ public class Header
StringBuilder builder = new StringBuilder("Header{");
final int origLength = builder.length();
- if(_durable != null)
+ if (_durable != null)
{
- if(builder.length() != origLength)
+ if (builder.length() != origLength)
{
builder.append(',');
}
builder.append("durable=").append(_durable);
}
- if(_priority != null)
+ if (_priority != null)
{
- if(builder.length() != origLength)
+ if (builder.length() != origLength)
{
builder.append(',');
}
builder.append("priority=").append(_priority);
}
- if(_ttl != null)
+ if (_ttl != null)
{
- if(builder.length() != origLength)
+ if (builder.length() != origLength)
{
builder.append(',');
}
builder.append("ttl=").append(_ttl);
}
- if(_firstAcquirer != null)
+ if (_firstAcquirer != null)
{
- if(builder.length() != origLength)
+ if (builder.length() != origLength)
{
builder.append(',');
}
builder.append("firstAcquirer=").append(_firstAcquirer);
}
- if(_deliveryCount != null)
+ if (_deliveryCount != null)
{
- if(builder.length() != origLength)
+ if (builder.length() != origLength)
{
builder.append(',');
}
@@ -149,13 +146,10 @@ public class Header
return builder.toString();
}
+ @Override
+ public Header getValue()
+ {
+ return this;
+ }
- public Binary encode(final SectionEncoder encoder)
- {
- encoder.reset();
- encoder.encodeObject(this);
- return encoder.getEncoding();
- }
-
-
- }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org