Author: rhs
Date: Thu Jan 4 12:23:26 2007
New Revision: 492718
URL: http://svn.apache.org/viewvc?view=rev&rev=492718
Log:
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.
Modified:
incubator/qpid/trunk/qpid/java/broker/etc/config.xml
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQType.java
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQTypeMap.java
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java
Modified: incubator/qpid/trunk/qpid/java/broker/etc/config.xml
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/broker/etc/config.xml?view=diff&rev=492718&r1=492717&r2=492718
==============================================================================
--- incubator/qpid/trunk/qpid/java/broker/etc/config.xml (original)
+++ incubator/qpid/trunk/qpid/java/broker/etc/config.xml Thu Jan 4 12:23:26
2007
@@ -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>
Modified:
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQType.java
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQType.java?view=diff&rev=492718&r1=492717&r2=492718
==============================================================================
---
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQType.java
(original)
+++
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQType.java
Thu Jan 4 12:23:26 2007
@@ -28,35 +28,39 @@
//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 @@
throw new UnsupportedOperationException();
}
+
public Object toNativeValue(Object value)
{
// TODO : fixme
@@ -82,10 +87,9 @@
// TODO : fixme
throw new UnsupportedOperationException();
}
-
},
- UNSIGNED_INT('I')
+ DECIMAL('D')
{
public int getEncodingSize(Object value)
@@ -94,7 +98,6 @@
throw new UnsupportedOperationException();
}
-
public Object toNativeValue(Object value)
{
// TODO : fixme
@@ -114,7 +117,7 @@
}
},
- UNSIGNED_LONG('L')
+ TIMESTAMP('T')
{
public int getEncodingSize(Object value)
@@ -124,7 +127,7 @@
}
- public Long toNativeValue(Object value)
+ public Object toNativeValue(Object value)
{
// TODO : fixme
throw new UnsupportedOperationException();
@@ -143,9 +146,8 @@
}
},
- EXTTENDED('D')
+ FIELD_TABLE('F')
{
-
public int getEncodingSize(Object value)
{
// TODO : fixme
@@ -172,35 +174,39 @@
}
},
- 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 @@
}
},
- 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 @@
}
},
- 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')
Modified:
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQTypeMap.java
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQTypeMap.java?view=diff&rev=492718&r1=492717&r2=492718
==============================================================================
---
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQTypeMap.java
(original)
+++
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQTypeMap.java
Thu Jan 4 12:23:26 2007
@@ -37,7 +37,12 @@
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;
}
}
Modified:
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java?view=diff&rev=492718&r1=492717&r2=492718
==============================================================================
---
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java
(original)
+++
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java
Thu Jan 4 12:23:26 2007
@@ -257,7 +257,7 @@
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 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