summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael H. Schloming <rhs@apache.org>2007-01-04 20:23:26 +0000
committerRafael H. Schloming <rhs@apache.org>2007-01-04 20:23:26 +0000
commitb9baacb2a5fc1e508102750d6459a4dd7ad1c52b (patch)
treeb690efb1baa72109b0d8483efaef1ffd599f6ad1
parent1673795f3d86d51bbcbe8515e7b2f2f0f46657a2 (diff)
downloadqpid-python-b9baacb2a5fc1e508102750d6459a4dd7ad1c52b.tar.gz
QPID-248 Modified field table types to not conflict with the officially specified definitions. Also reorganized type definitions to clearly distinguish between official and extended types and reenabled the AmqPlain authentication mechanism. This change allows the python interop test suite to run.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@492718 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--java/broker/etc/config.xml2
-rw-r--r--java/common/src/main/java/org/apache/qpid/framing/AMQType.java138
-rw-r--r--java/common/src/main/java/org/apache/qpid/framing/AMQTypeMap.java7
-rw-r--r--java/common/src/main/java/org/apache/qpid/framing/FieldTable.java4
4 files changed, 65 insertions, 86 deletions
diff --git a/java/broker/etc/config.xml b/java/broker/etc/config.xml
index 7f3eb129d5..61e0e55138 100644
--- a/java/broker/etc/config.xml
+++ b/java/broker/etc/config.xml
@@ -69,7 +69,7 @@
<class>org.apache.qpid.server.security.auth.amqplain.AmqPlainInitialiser</class>
<principal-database>passwordfile</principal-database>
</initialiser>
- </mechanism>-->
+ </mechanism>
<mechanism>
<initialiser>
<class>org.apache.qpid.server.security.auth.plain.PlainInitialiser</class>
diff --git a/java/common/src/main/java/org/apache/qpid/framing/AMQType.java b/java/common/src/main/java/org/apache/qpid/framing/AMQType.java
index 4bce1ca5f0..ad07634554 100644
--- a/java/common/src/main/java/org/apache/qpid/framing/AMQType.java
+++ b/java/common/src/main/java/org/apache/qpid/framing/AMQType.java
@@ -28,35 +28,39 @@ public enum AMQType
//AMQP FieldTable Wire Types
- DECIMAL('D')
+ LONG_STRING('S')
{
-
public int getEncodingSize(Object value)
{
- // TODO : fixme
- throw new UnsupportedOperationException();
+ return EncodingUtils.encodedLongStringLength((String) value);
}
- public Object toNativeValue(Object value)
+
+ public String toNativeValue(Object value)
{
- // TODO : fixme
- throw new UnsupportedOperationException();
+ if (value != null)
+ {
+ return value.toString();
+ }
+ else
+ {
+ throw new NullPointerException("Cannot convert: null to String.");
+ }
}
public void writeValueImpl(Object value, ByteBuffer buffer)
{
- // TODO : fixme
- throw new UnsupportedOperationException();
+ EncodingUtils.writeLongStringBytes(buffer, (String) value);
}
public Object readValueFromBuffer(ByteBuffer buffer)
{
- // TODO : fixme
- throw new UnsupportedOperationException();
+ return EncodingUtils.readLongString(buffer);
}
+
},
- UNSIGNED_SHORT('S')
+ INTEGER('I')
{
public int getEncodingSize(Object value)
@@ -65,6 +69,7 @@ public enum AMQType
throw new UnsupportedOperationException();
}
+
public Object toNativeValue(Object value)
{
// TODO : fixme
@@ -82,10 +87,9 @@ public enum AMQType
// TODO : fixme
throw new UnsupportedOperationException();
}
-
},
- UNSIGNED_INT('I')
+ DECIMAL('D')
{
public int getEncodingSize(Object value)
@@ -94,7 +98,6 @@ public enum AMQType
throw new UnsupportedOperationException();
}
-
public Object toNativeValue(Object value)
{
// TODO : fixme
@@ -114,7 +117,7 @@ public enum AMQType
}
},
- UNSIGNED_LONG('L')
+ TIMESTAMP('T')
{
public int getEncodingSize(Object value)
@@ -124,7 +127,7 @@ public enum AMQType
}
- public Long toNativeValue(Object value)
+ public Object toNativeValue(Object value)
{
// TODO : fixme
throw new UnsupportedOperationException();
@@ -143,9 +146,8 @@ public enum AMQType
}
},
- EXTTENDED('D')
+ FIELD_TABLE('F')
{
-
public int getEncodingSize(Object value)
{
// TODO : fixme
@@ -172,35 +174,39 @@ public enum AMQType
}
},
- TIMESTAMP('T')
+ VOID('V')
{
-
public int getEncodingSize(Object value)
{
- // TODO : fixme
- throw new UnsupportedOperationException();
+ return 0;
}
public Object toNativeValue(Object value)
{
- // TODO : fixme
- throw new UnsupportedOperationException();
+ if (value == null)
+ {
+ return null;
+ }
+ else
+ {
+ throw new NumberFormatException("Cannot convert: " + value + "(" +
+ value.getClass().getName() + ") to null String.");
+ }
}
public void writeValueImpl(Object value, ByteBuffer buffer)
{
- // TODO : fixme
- throw new UnsupportedOperationException();
}
public Object readValueFromBuffer(ByteBuffer buffer)
{
- // TODO : fixme
- throw new UnsupportedOperationException();
+ return null;
}
},
+ // Extended types
+
BINARY('x')
{
public int getEncodingSize(Object value)
@@ -299,38 +305,6 @@ public enum AMQType
}
},
- NULL_STRING('n')
- {
-
- public int getEncodingSize(Object value)
- {
- return 0;
- }
-
-
- public String toNativeValue(Object value)
- {
- if (value == null)
- {
- return null;
- }
- else
- {
- throw new NumberFormatException("Cannot convert: " + value + "(" +
- value.getClass().getName() + ") to null String.");
- }
- }
-
- public void writeValueImpl(Object value, ByteBuffer buffer)
- {
- }
-
- public Object readValueFromBuffer(ByteBuffer buffer)
- {
- return null;
- }
- },
-
BOOLEAN('t')
{
public int getEncodingSize(Object value)
@@ -368,77 +342,77 @@ public enum AMQType
}
},
- BYTE('b')
+ ASCII_CHARACTER('k')
{
public int getEncodingSize(Object value)
{
- return EncodingUtils.encodedByteLength();
+ return EncodingUtils.encodedCharLength();
}
- public Byte toNativeValue(Object value)
+ public Character toNativeValue(Object value)
{
- if (value instanceof Byte)
+ if (value instanceof Character)
{
- return (Byte) value;
+ return (Character) value;
}
- else if ((value instanceof String) || (value == null))
+ else if (value == null)
{
- return Byte.valueOf((String)value);
+ throw new NullPointerException("Cannot convert null into char");
}
else
{
throw new NumberFormatException("Cannot convert: " + value + "(" +
- value.getClass().getName() + ") to byte.");
+ value.getClass().getName() + ") to char.");
}
}
public void writeValueImpl(Object value, ByteBuffer buffer)
{
- EncodingUtils.writeByte(buffer, (Byte) value);
+ EncodingUtils.writeChar(buffer, (Character) value);
}
public Object readValueFromBuffer(ByteBuffer buffer)
{
- return EncodingUtils.readByte(buffer);
+ return EncodingUtils.readChar(buffer);
}
+
},
- ASCII_CHARACTER('k')
+ BYTE('b')
{
public int getEncodingSize(Object value)
{
- return EncodingUtils.encodedCharLength();
+ return EncodingUtils.encodedByteLength();
}
- public Character toNativeValue(Object value)
+ public Byte toNativeValue(Object value)
{
- if (value instanceof Character)
+ if (value instanceof Byte)
{
- return (Character) value;
+ return (Byte) value;
}
- else if (value == null)
+ else if ((value instanceof String) || (value == null))
{
- throw new NullPointerException("Cannot convert null into char");
+ return Byte.valueOf((String)value);
}
else
{
throw new NumberFormatException("Cannot convert: " + value + "(" +
- value.getClass().getName() + ") to char.");
+ value.getClass().getName() + ") to byte.");
}
}
public void writeValueImpl(Object value, ByteBuffer buffer)
{
- EncodingUtils.writeChar(buffer, (Character) value);
+ EncodingUtils.writeByte(buffer, (Byte) value);
}
public Object readValueFromBuffer(ByteBuffer buffer)
{
- return EncodingUtils.readChar(buffer);
+ return EncodingUtils.readByte(buffer);
}
-
},
SHORT('s')
diff --git a/java/common/src/main/java/org/apache/qpid/framing/AMQTypeMap.java b/java/common/src/main/java/org/apache/qpid/framing/AMQTypeMap.java
index e24fd7efeb..5ac7f8827b 100644
--- a/java/common/src/main/java/org/apache/qpid/framing/AMQTypeMap.java
+++ b/java/common/src/main/java/org/apache/qpid/framing/AMQTypeMap.java
@@ -37,7 +37,12 @@ public class AMQTypeMap
public static AMQType getType(Byte identifier)
{
- return _reverseTypeMap.get(identifier);
+ AMQType result = _reverseTypeMap.get(identifier);
+ if (result == null) {
+ throw new IllegalArgumentException
+ ("no such type code: " + Integer.toHexString(identifier.intValue()));
+ }
+ return result;
}
}
diff --git a/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java b/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java
index 4d88009076..3c18683609 100644
--- a/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java
+++ b/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java
@@ -257,7 +257,7 @@ public class FieldTable
checkPropertyName(string);
if (value == null)
{
- return _properties.put(string, AMQType.NULL_STRING.asTypedValue(null));
+ return _properties.put(string, AMQType.VOID.asTypedValue(null));
}
else
{
@@ -344,7 +344,7 @@ public class FieldTable
public boolean isNullStringValue(String name)
{
AMQTypedValue value = _properties.get(name);
- return (value != null) && (value.getType() == AMQType.NULL_STRING);
+ return (value != null) && (value.getType() == AMQType.VOID);
}
// ***** Methods