diff options
author | Arnaud Simon <arnaudsimon@apache.org> | 2008-11-19 12:59:28 +0000 |
---|---|---|
committer | Arnaud Simon <arnaudsimon@apache.org> | 2008-11-19 12:59:28 +0000 |
commit | 6a42c34f84ad6fbafcd38ab6e06a2a234c85fdc8 (patch) | |
tree | f0ecda4484704f945eeab613f74bf95e67f057ca | |
parent | ce06bf4a1fa2390180ddb18b4ea87e88279b7d36 (diff) | |
download | qpid-python-6a42c34f84ad6fbafcd38ab6e06a2a234c85fdc8.tar.gz |
QPID-1463: Andrea's patches
- Added read / write methods on org.apache.qpid.transport.codec.Encoder / org.apache.qpid.transport.codec.Decoder;
- Added the corresponding implementation on org.apache.qpid.transport.codec.BBEncoder / org.apache.qpid.transport.codec.BBDecoder
- Added comments on org.apache.qpid.transport.codec.Encoder / org.apache.qpid.transport.codec.Decoder;
- Removed org.apache.qpid.transport.codec.ManagementEncoder / org.apache.qpid.transport.codec.ManagementDecoder.
- Added 6 data types (Int8, Int16, Int32, Int64, Double and Float);
- Added type mappings with the data types above according to management specifications;
- Removed all references to ManagementEncoder / Decoder classes; Now Qman is using (whenever is possible) Decoder / Encoder and when some specific method is needed then the BBDecoder / BBEncoder is used.
- Some test case adjustment;
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@718949 13f79535-47bb-0310-9956-ffa450edef68
46 files changed, 869 insertions, 474 deletions
diff --git a/java/common/src/main/java/org/apache/qpid/transport/codec/BBDecoder.java b/java/common/src/main/java/org/apache/qpid/transport/codec/BBDecoder.java index dd634eb94a..6f7a2fa3b2 100644 --- a/java/common/src/main/java/org/apache/qpid/transport/codec/BBDecoder.java +++ b/java/common/src/main/java/org/apache/qpid/transport/codec/BBDecoder.java @@ -25,16 +25,14 @@ import java.nio.ByteOrder; import org.apache.qpid.transport.Binary; - /** - * BBDecoder + * Byte Buffer Decoder. + * Decoder concrete implementor using a backing byte buffer for decoding data. * * @author Rafael H. Schloming */ - public final class BBDecoder extends AbstractDecoder { - private ByteBuffer in; public void init(ByteBuffer in) @@ -93,4 +91,54 @@ public final class BBDecoder extends AbstractDecoder return in.getLong(); } -} + public byte[] readBin128() + { + byte[] result = new byte[16]; + get(result); + return result; + } + + public byte[] readBytes(int howManyBytes) + { + byte[] result = new byte[howManyBytes]; + get(result); + return result; + } + + public double readDouble() + { + return in.getDouble(); + } + + public float readFloat() + { + return in.getFloat(); + } + + public short readInt16() + { + return in.getShort(); + } + + public int readInt32() + { + return in.getInt(); + } + + public byte readInt8() + { + return in.get(); + } + + public byte[] readReaminingBytes() + { + byte[] result = new byte[in.limit() - in.position()]; + get(result); + return result; + } + + public long readInt64() + { + return in.getLong(); + } +}
\ No newline at end of file diff --git a/java/common/src/main/java/org/apache/qpid/transport/codec/BBEncoder.java b/java/common/src/main/java/org/apache/qpid/transport/codec/BBEncoder.java index 390de881ab..532c19ec18 100644 --- a/java/common/src/main/java/org/apache/qpid/transport/codec/BBEncoder.java +++ b/java/common/src/main/java/org/apache/qpid/transport/codec/BBEncoder.java @@ -26,14 +26,13 @@ import java.nio.ByteOrder; /** - * BBEncoder - * + * Byte Buffer Encoder. + * Encoder concrete implementor using a backing byte buffer for encoding data. + * * @author Rafael H. Schloming */ - public final class BBEncoder extends AbstractEncoder { - private ByteBuffer out; private int segment; @@ -229,4 +228,96 @@ public final class BBEncoder extends AbstractEncoder out.putInt(pos, (cur - pos - 4)); } -} + public void writeDouble(double aDouble) + { + try + { + out.putDouble(aDouble); + } catch(BufferOverflowException exception) + { + grow(8); + out.putDouble(aDouble); + } + } + + public void writeInt16(short aShort) + { + try + { + out.putShort(aShort); + } catch(BufferOverflowException exception) + { + grow(2); + out.putShort(aShort); + } + } + + public void writeInt32(int anInt) + { + try + { + out.putInt(anInt); + } catch(BufferOverflowException exception) + { + grow(4); + out.putInt(anInt); + } + } + + public void writeInt64(long aLong) + { + try + { + out.putLong(aLong); + } catch(BufferOverflowException exception) + { + grow(8); + out.putLong(aLong); + } + } + + public void writeInt8(byte aByte) + { + try + { + out.put(aByte); + } catch(BufferOverflowException exception) + { + grow(1); + out.put(aByte); + } + } + + public void writeBin128(byte[] byteArray) + { + byteArray = (byteArray != null) ? byteArray : new byte [16]; + + assert byteArray.length == 16; + + try + { + out.put(byteArray); + } catch(BufferOverflowException exception) + { + grow(16); + out.put(byteArray); + } + } + + public void writeFloat(float aFloat) + { + try + { + out.putFloat(aFloat); + } catch(BufferOverflowException exception) + { + grow(4); + out.putFloat(aFloat); + } + } + + public void writeMagicNumber() + { + out.put("AM2".getBytes()); + } +}
\ No newline at end of file diff --git a/java/common/src/main/java/org/apache/qpid/transport/codec/Decoder.java b/java/common/src/main/java/org/apache/qpid/transport/codec/Decoder.java index 50e787ccb2..a4df5b5fcb 100644 --- a/java/common/src/main/java/org/apache/qpid/transport/codec/Decoder.java +++ b/java/common/src/main/java/org/apache/qpid/transport/codec/Decoder.java @@ -29,40 +29,255 @@ import org.apache.qpid.transport.Struct; /** - * Decoder - * + * Decoder interface. + * Each concrete implementor must specify how to decode given values. + * * @author Rafael H. Schloming */ - public interface Decoder { - + /** + * Tells whether there are any remaining byte(s) to be read. + * + * @return true if there are remaining bytes, false otherwise. + */ boolean hasRemaining(); + /** + * The uint8 type is an 8-bit unsigned integral value. + * + * @return an 8-bit unsigned integral value. + */ short readUint8(); + + /** + *The uint16 type is a 16-bit unsigned integral value encoded in network byte order. + * + * @return a 16-bit unsigned integral value encoded in network byte order. + */ int readUint16(); + + /** + *The uint32 type is a 32-bit unsigned integral value encoded in network byte order. + * + * @return a 32-bit unsigned integral value encoded in network byte order. + */ long readUint32(); + + /** + * The uint64 type is a 64-bit unsigned integral value encoded in network byte order. + * + * @return a 64-bit unsigned integral value encoded in network byte order. + */ long readUint64(); + /** + * The datetime type encodes a date and time using the 64 bit POSIX time_t format. + * + * @return a date and time using the 64 bit POSIX time_t format. + */ long readDatetime(); + + /** + * The uuid type encodes a universally unique id as defined by RFC-4122. + * The format and operations for this type can be found in section 4.1.2 of RFC-4122. + * + * return a universally unique id as defined by RFC-4122. + */ UUID readUuid(); + /** +// *The sequence-no type encodes, in network byte order, a serial number as defined in RFC-1982. + * + * @return a serial number as defined in RFC-1982. + */ int readSequenceNo(); + RangeSet readSequenceSet(); // XXX RangeSet readByteRanges(); // XXX + /** + * The str8 type encodes up to 255 octets worth of UTF-8 unicode. + * The number of octets of unicode is first encoded as an 8-bit unsigned integral value. + * This is followed by the actual UTF-8 unicode. + * Note that the encoded size refers to the number of octets of unicode, not necessarily the number of characters since + * the UTF-8 unicode may include multi-byte character sequences. + * + * @return a string. + */ String readStr8(); + + /** + * The str16 type encodes up to 65535 octets worth of UTF-8 unicode. + * The number of octets is first encoded as a 16-bit unsigned integral value in network byte order. + * This is followed by the actual UTF-8 unicode. + * Note that the encoded size refers to the number of octets of unicode, not necessarily the number of unicode + * characters since the UTF-8 unicode may include multi-byte character sequences. + * + * return a string. + */ String readStr16(); + /** + * The vbin8 type encodes up to 255 octets of opaque binary data. + * + * return a byte array. + */ byte[] readVbin8(); + + /** + * The vbin16 type encodes up to 65535 octets of opaque binary data. + * + * @return the corresponding byte array. + */ byte[] readVbin16(); + + /** + * The vbin32 type encodes up to 4294967295 octets of opaque binary data. + * + * @return the corresponding byte array. + */ byte[] readVbin32(); + /** + * The struct32 type describes any coded struct with a 32-bit (4 octet) size. + * The type is restricted to be only coded structs with a 32-bit size, consequently the first six octets of any encoded + * value for this type MUST always contain the size, class-code, and struct-code in that order. + * The size is encoded as a 32-bit unsigned integral value in network byte order that is equal to the size of the + * encoded field-data, packing-flags, class-code, and struct-code. The class-code is a single octet that may be set to any + * valid class code. + * The struct-code is a single octet that may be set to any valid struct code within the given class-code. + * The first six octets are then followed by the packing flags and encoded field data. + * The presence and quantity of packingflags, as well as the specific fields are determined by the struct definition + * identified with the encoded class-code and struct-code. + * + * @return the decoded struct. + */ Struct readStruct32(); + + /** + * A map is a set of distinct keys where each key has an associated (type,value) pair. + * The triple of the key, type, and value, form an entry within a map. Each entry within a given map MUST have a + * distinct key. + * A map is encoded as a size in octets, a count of the number of entries, followed by the encoded entries themselves. + * An encoded map may contain up to (4294967295 - 4) octets worth of encoded entries. + * The size is encoded as a 32-bit unsigned integral value in network byte order equal to the number of octets worth of + * encoded entries plus 4. (The extra 4 octets is added for the entry count.) + * The size is then followed by the number of entries encoded as a 32-bit unsigned integral value in network byte order. + * Finally the entries are encoded sequentially. + * An entry is encoded as the key, followed by the type, and then the value. The key is always a string encoded as a str8. + * The type is a single octet that may contain any valid AMQP type code. + * The value is encoded according to the rules defined by the type code for that entry. + * + * @return the decoded map. + */ Map<String,Object> readMap(); + + /** + * A list is an ordered sequence of (type, value) pairs. The (type, value) pair forms an item within the list. + * The list may contain items of many distinct types. A list is encoded as a size in octets, followed by a count of the + * number of items, followed by the items themselves encoded in their defined order. + * An encoded list may contain up to (4294967295 - 4) octets worth of encoded items. + * The size is encoded as a 32-bit unsigned integral value in network byte order equal to the number of octets worth + * of encoded items plus 4. (The extra4 octets is added for the item count.) + * The size is then followed by the number of items encoded as a 32-bit unsigned integral value in network byte order. + * Finally the items are encoded sequentially in their defined order. + * An item is encoded as the type followed by the value. The type is a single octet that may contain any valid AMQP type + * code. + * The value is encoded according to the rules defined by the type code for that item. + * + * @return the decoded list. + */ List<Object> readList(); + + /** + * An array is an ordered sequence of values of the same type. + * The array is encoded in as a size in octets, followed by a type code, then a count of the number values in the array, + * and finally the values encoded in their defined order. + * An encoded array may contain up to (4294967295 - 5) octets worth of encoded values. + * The size is encoded as a 32-bit unsigned integral value in network byte order equal to the number of octets worth of + * encoded values plus 5. (The extra 5 octets consist of 4 octets for the count of the number of values, and one octet to + * hold the type code for the items inthe array.) + * The size is then followed by a single octet that may contain any valid AMQP type code. + * The type code is then followed by the number of values encoded as a 32-bit unsigned integral value in network byte + * order. + * Finally the values are encoded sequentially in their defined order according to the rules defined by the type code for + * the array. + * + * @return the decoded array. + */ List<Object> readArray(); + /** + * + * @param type the type of the struct. + * @return the decoded struct. + */ Struct readStruct(int type); - -} + + /** + * The float type encodes a single precision 32-bit floating point number. + * The format and operations are defined by the IEEE 754 standard for 32-bit single precision floating point numbers. + * + * @return the decoded float. + */ + float readFloat(); + + /** + * The double type encodes a double precision 64-bit floating point number. + * The format and operations are defined by the IEEE 754 standard for 64-bit double precision floating point numbers. + * + * @return the decoded double + */ + double readDouble(); + + /** + * The int8 type is a signed integral value encoded using an 8-bit two's complement representation. + * + * @return the decoded integer. + */ + byte readInt8(); + + /** + * The int16 type is a signed integral value encoded using a 16-bit two's complement representation in network byte order. + * + * @return the decoded integer. + */ + short readInt16(); + + /** + * The int32 type is a signed integral value encoded using a 32-bit two's complement representation in network byte order. + * + * @return the decoded integer. + */ + int readInt32(); + + /** + * The int64 type is a signed integral value encoded using a 64-bit two's complement representation in network byte order. + * + * @return the decoded integer (as long). + */ + long readInt64(); + + /** + * The bin128 type consists of 16 consecutive octets of opaque binary data. + * + * @return the decoded byte array. + */ + byte [] readBin128(); + + /** + * Reads the remaining bytes on the underlying buffer. + * + * @return the remaining bytes on the underlying buffer. + */ + byte[] readReaminingBytes (); + + /** + * Reads the given number of bytes. + * + * @param howManyBytes how many bytes need to be read? + * @return a byte array containing the requested data. + */ + byte[] readBytes (int howManyBytes); +}
\ No newline at end of file diff --git a/java/common/src/main/java/org/apache/qpid/transport/codec/Encodable.java b/java/common/src/main/java/org/apache/qpid/transport/codec/Encodable.java index 2aefafd19c..37ce8a5cb7 100644 --- a/java/common/src/main/java/org/apache/qpid/transport/codec/Encodable.java +++ b/java/common/src/main/java/org/apache/qpid/transport/codec/Encodable.java @@ -26,12 +26,19 @@ package org.apache.qpid.transport.codec; * * @author Rafael H. Schloming */ - public interface Encodable { + /** + * Encodes this encodable using the given encoder. + * + * @param encoder the encoder. + */ + void write(Encoder encoder); - void write(Encoder enc); - - void read(Decoder dec); - -} + /** + * Decodes this encodable using the given decoder. + * + * @param decoder the decoder. + */ + void read(Decoder decoder); +}
\ No newline at end of file diff --git a/java/common/src/main/java/org/apache/qpid/transport/codec/Encoder.java b/java/common/src/main/java/org/apache/qpid/transport/codec/Encoder.java index 2d8d13e80a..7d4f02af31 100644 --- a/java/common/src/main/java/org/apache/qpid/transport/codec/Encoder.java +++ b/java/common/src/main/java/org/apache/qpid/transport/codec/Encoder.java @@ -29,38 +29,254 @@ import org.apache.qpid.transport.Struct; /** - * Encoder + * Encoder interface. + * Each concrete implementor must specify how to encode given values. * * @author Rafael H. Schloming */ - public interface Encoder { - + /** + * The uint8 type is an 8-bit unsigned integral value. + * + * @param b the unsigned integer to be encoded. + */ void writeUint8(short b); + + /** + *The uint16 type is a 16-bit unsigned integral value encoded in network byte order. + * + * @param s the unsigned integer to be encoded. + */ void writeUint16(int s); + + /** + *The uint32 type is a 32-bit unsigned integral value encoded in network byte order. + * + * @param i the unsigned integer to be encoded. + */ void writeUint32(long i); + + /** + * The uint64 type is a 64-bit unsigned integral value encoded in network byte order. + * + * @param b the unsigned integer to be encoded. + */ void writeUint64(long l); + /** + * The datetime type encodes a date and time using the 64 bit POSIX time_t format. + * + * @param l the datetime (as long) to be encoded. + */ void writeDatetime(long l); + + /** + * The uuid type encodes a universally unique id as defined by RFC-4122. + * The format and operations for this type can be found in section 4.1.2 of RFC-4122. + * + * @param uuid the uuid to be encoded. + */ void writeUuid(UUID uuid); + /** + *The sequence-no type encodes, in network byte order, a serial number as defined in RFC-1982. + * + * @param s the sequence number to be encoded. + */ void writeSequenceNo(int s); + void writeSequenceSet(RangeSet ranges); // XXX void writeByteRanges(RangeSet ranges); // XXX + /** + * The str8 type encodes up to 255 octets worth of UTF-8 unicode. + * The number of octets of unicode is first encoded as an 8-bit unsigned integral value. + * This is followed by the actual UTF-8 unicode. + * Note that the encoded size refers to the number of octets of unicode, not necessarily the number of characters since + * the UTF-8 unicode may include multi-byte character sequences. + * + * @param s the string to be encoded. + */ void writeStr8(String s); + + /** + * The str16 type encodes up to 65535 octets worth of UTF-8 unicode. + * The number of octets is first encoded as a 16-bit unsigned integral value in network byte order. + * This is followed by the actual UTF-8 unicode. + * Note that the encoded size refers to the number of octets of unicode, not necessarily the number of unicode + * characters since the UTF-8 unicode may include multi-byte character sequences. + * + * @param s the string to be encoded. + */ void writeStr16(String s); + /** + * The vbin8 type encodes up to 255 octets of opaque binary data. + * The number of octets is first encoded as an 8-bit unsigned integral value. + * This is followed by the actual data. + * + * @param bytes the byte array to be encoded. + */ void writeVbin8(byte[] bytes); + + /** + * The vbin16 type encodes up to 65535 octets of opaque binary data. + * The number of octets is first encoded as a 16-bit unsigned integral value in network byte order. + * This is followed by the actual data. + * + * @param bytes the byte array to be encoded. + */ void writeVbin16(byte[] bytes); + + /** + * The vbin32 type encodes up to 4294967295 octets of opaque binary data. + * The number of octets is first encoded as a 32-bit unsigned integral value in network byte order. + * This is followed by the actual data. + * + * @param bytes the byte array to be encoded. + */ void writeVbin32(byte[] bytes); - void writeStruct32(Struct s); + /** + * The struct32 type describes any coded struct with a 32-bit (4 octet) size. + * The type is restricted to be only coded structs with a 32-bit size, consequently the first six octets of any encoded + * value for this type MUST always contain the size, class-code, and struct-code in that order. + * The size is encoded as a 32-bit unsigned integral value in network byte order that is equal to the size of the + * encoded field-data, packing-flags, class-code, and struct-code. The class-code is a single octet that may be set to any + * valid class code. + * The struct-code is a single octet that may be set to any valid struct code within the given class-code. + * The first six octets are then followed by the packing flags and encoded field data. + * The presence and quantity of packingflags, as well as the specific fields are determined by the struct definition + * identified with the encoded class-code and struct-code. + * + * @param struct the struct to be encoded. + */ + void writeStruct32(Struct struct); + + /** + * A map is a set of distinct keys where each key has an associated (type,value) pair. + * The triple of the key, type, and value, form an entry within a map. Each entry within a given map MUST have a + * distinct key. + * A map is encoded as a size in octets, a count of the number of entries, followed by the encoded entries themselves. + * An encoded map may contain up to (4294967295 - 4) octets worth of encoded entries. + * The size is encoded as a 32-bit unsigned integral value in network byte order equal to the number of octets worth of + * encoded entries plus 4. (The extra 4 octets is added for the entry count.) + * The size is then followed by the number of entries encoded as a 32-bit unsigned integral value in network byte order. + * Finally the entries are encoded sequentially. + * An entry is encoded as the key, followed by the type, and then the value. The key is always a string encoded as a str8. + * The type is a single octet that may contain any valid AMQP type code. + * The value is encoded according to the rules defined by the type code for that entry. + * + * @param map the map to be encoded. + */ void writeMap(Map<String,Object> map); + + /** + * A list is an ordered sequence of (type, value) pairs. The (type, value) pair forms an item within the list. + * The list may contain items of many distinct types. A list is encoded as a size in octets, followed by a count of the + * number of items, followed by the items themselves encoded in their defined order. + * An encoded list may contain up to (4294967295 - 4) octets worth of encoded items. + * The size is encoded as a 32-bit unsigned integral value in network byte order equal to the number of octets worth + * of encoded items plus 4. (The extra4 octets is added for the item count.) + * The size is then followed by the number of items encoded as a 32-bit unsigned integral value in network byte order. + * Finally the items are encoded sequentially in their defined order. + * An item is encoded as the type followed by the value. The type is a single octet that may contain any valid AMQP type + * code. + * The value is encoded according to the rules defined by the type code for that item. + * + * @param list the list to be encoded. + */ void writeList(List<Object> list); + + /** + * An array is an ordered sequence of values of the same type. + * The array is encoded in as a size in octets, followed by a type code, then a count of the number values in the array, + * and finally the values encoded in their defined order. + * An encoded array may contain up to (4294967295 - 5) octets worth of encoded values. + * The size is encoded as a 32-bit unsigned integral value in network byte order equal to the number of octets worth of + * encoded values plus 5. (The extra 5 octets consist of 4 octets for the count of the number of values, and one octet to + * hold the type code for the items inthe array.) + * The size is then followed by a single octet that may contain any valid AMQP type code. + * The type code is then followed by the number of values encoded as a 32-bit unsigned integral value in network byte + * order. + * Finally the values are encoded sequentially in their defined order according to the rules defined by the type code for + * the array. + * + * @param array the array to be encoded. + */ void writeArray(List<Object> array); - void writeStruct(int type, Struct s); - -} + /** + * The struct32 type describes any coded struct with a 32-bit (4 octet) size. + * The type is restricted to be only coded structs with a 32-bit size, consequently the first six octets of any encoded + * value for this type MUST always contain the size, class-code, and struct-code in that order. + * The size is encoded as a 32-bit unsigned integral value in network byte order that is equal to the size of the + * encoded field-data, packing-flags, class-code, and struct-code. The class-code is a single octet that may be set to any + * valid class code. + * The struct-code is a single octet that may be set to any valid struct code within the given class-code. + * The first six octets are then followed by the packing flags and encoded field data. + * The presence and quantity of packingflags, as well as the specific fields are determined by the struct definition + * identified with the encoded class-code and struct-code. + * + * @param type the type of the struct. + * @param struct the struct to be encoded. + */ + void writeStruct(int type, Struct struct); + + /** + * The float type encodes a single precision 32-bit floating point number. + * The format and operations are defined by the IEEE 754 standard for 32-bit single precision floating point numbers. + * + * @param aFloat the float to be encoded. + */ + void writeFloat(float aFloat); + + /** + * The double type encodes a double precision 64-bit floating point number. + * The format and operations are defined by the IEEE 754 standard for 64-bit double precision floating point numbers. + * + * @param aDouble the double to be encoded. + */ + void writeDouble(double aDouble); + + /** + * The int8 type is a signed integral value encoded using an 8-bit two's complement representation. + * + * @param aByte the integer to be encoded. + */ + void writeInt8(byte aByte); + + /** + * The int16 type is a signed integral value encoded using a 16-bit two's complement representation in network byte order. + * + * @param aShort the integer to be encoded. + */ + void writeInt16(short aShort); + + /** + * The int32 type is a signed integral value encoded using a 32-bit two's complement representation in network byte order. + * + * @param anInt the integer to be encoded. + */ + void writeInt32(int anInt); + + /** + * The int64 type is a signed integral value encoded using a 64-bit two's complement representation in network byte order. + * + * @param aLong the integer to be encoded. + */ + void writeInt64(long aLong); + + /** + * The bin128 type consists of 16 consecutive octets of opaque binary data. + * + * @param bytes the bytes array to be encoded. + */ + void writeBin128(byte [] bytes); + + /** + * Encodes the AMQP magic number. + */ + void writeMagicNumber(); +}
\ No newline at end of file diff --git a/java/common/src/main/java/org/apache/qpid/transport/codec/ManagementDecoder.java b/java/common/src/main/java/org/apache/qpid/transport/codec/ManagementDecoder.java deleted file mode 100644 index 1e9fdc5e3e..0000000000 --- a/java/common/src/main/java/org/apache/qpid/transport/codec/ManagementDecoder.java +++ /dev/null @@ -1,109 +0,0 @@ -package org.apache.qpid.transport.codec; - -import java.nio.ByteBuffer; -import java.util.Map; -import java.util.UUID; - - -/* - * Extends BBDecoder to add some additional methods. - * - * FIXME (Gazza) : I don't like very much this class...this code should be part of BBDecoder - */ -public class ManagementDecoder -{ - private BBDecoder _decoder; - private ByteBuffer _buffer; - - public void init(ByteBuffer buffer) - { - this._buffer = buffer; - this._decoder = new BBDecoder(); - _decoder.init(_buffer); - } - - public byte[] readReaminingBytes () - { - byte[] result = new byte[_buffer.limit() - _buffer.position()]; - _decoder.get(result); - return result; - } - - public byte[] readBin128() { - byte[] result = new byte[16]; - _decoder.get(result); - return result; - } - - public byte[] readBytes (int howMany) - { - byte [] result = new byte[howMany]; - _decoder.get(result); - return result; - } - - public long readDatetime () - { - return _decoder.readDatetime(); - } - - public Map<String, Object> readMap () - { - return _decoder.readMap(); - } - - public int readSequenceNo () - { - return _decoder.readSequenceNo(); - } - - public String readStr16 () - { - return _decoder.readStr16(); - } - - public String readStr8 () - { - return _decoder.readStr8(); - } - - public int readUint16 () - { - return _decoder.readUint16(); - } - - public long readUint32 () - { - return _decoder.readUint32(); - } - - public long readUint64 () - { - return _decoder.readUint64(); - } - - public short readUint8 () - { - return _decoder.readUint8(); - } - - public UUID readUuid () - { - return _decoder.readUuid(); - } - - public byte[] readVbin16 () - { - return _decoder.readVbin16(); - } - - public byte[] readVbin32 () - { - return _decoder.readVbin32(); - } - - public byte[] readVbin8 () - { - return _decoder.readVbin8(); - } -}
\ No newline at end of file diff --git a/java/common/src/main/java/org/apache/qpid/transport/codec/ManagementEncoder.java b/java/common/src/main/java/org/apache/qpid/transport/codec/ManagementEncoder.java deleted file mode 100644 index 3dc4fe9ae3..0000000000 --- a/java/common/src/main/java/org/apache/qpid/transport/codec/ManagementEncoder.java +++ /dev/null @@ -1,86 +0,0 @@ -package org.apache.qpid.transport.codec; - - -import java.nio.ByteBuffer; - -import org.apache.qpid.transport.codec.AbstractEncoder; - -/* - * @author rahulapi@gmailcom - * - * Management Encoder extends the basic java encoer (AbastractEncoder) - * its a java encoder we use to encode the incoming messages - * (encode the fields of the message) - * - * TODO (Gazza) : I don't like very much this class...this code should be part of BBDecoder - */ -public class ManagementEncoder extends AbstractEncoder{ - - - public ByteBuffer _out=null; - - public ManagementEncoder(ByteBuffer out) - { - - _out = out; - } - - protected void doPut(byte b) - { - _out.put(b); - } - - protected void doPut(ByteBuffer src) - { - _out.put(src); - } - - public void writeBin128(byte[] s) - { - if(s==null) - { - s=new byte[16]; - - }else if(s.length!=16){ - throw new IllegalArgumentException(""+s); - } - put(s); - } - - @Override - protected int beginSize16() { - // TODO Auto-generated method stub - return 0; - } - - @Override - protected int beginSize32() { - // TODO Auto-generated method stub - return 0; - } - - @Override - protected int beginSize8() { - // TODO Auto-generated method stub - return 0; - } - - @Override - protected void endSize16(int pos) { - // TODO Auto-generated method stub - - } - - @Override - protected void endSize32(int pos) { - // TODO Auto-generated method stub - - } - - @Override - protected void endSize8(int pos) { - // TODO Auto-generated method stub - - } - -}
\ No newline at end of file diff --git a/java/management/client/README.txt b/java/management/client/README.txt index ab9eb137be..ffbe98e228 100644 --- a/java/management/client/README.txt +++ b/java/management/client/README.txt @@ -1,116 +1,117 @@ +1)DESCRIPTION
+Q-Man is a Management bridge that exposes one (or several) Qpid broker domain model as MBeans that are accessible through the Java Management Extensions (JMX).
+The following README content could be read also in http://cwiki.apache.org/confluence/display/qpid/Qman+Tool
-*** FEATURES INCLUDED ***
-
-- Content indication response message ('i') handler;
-- Content indication response message ('c') handler;
-- Schema response ('s') handler;
-- Optional properties management;
-- Properties validation against using constraints defined in the schema (max, min, maxlen);
-- Schema-hash / class-hash management. QMan is able to work with classes having different schema inside the same package.
-- Method invocation (see open issue below for this point) with arguments validation using constraints define in the schema;
-- Graceful shutdown (At shutdown all management clients are shutdown and corresponding resources are released)
-- Connection Pool : for each connected broker you can define (using configuration) a dedicated connecton pool. Properties of connection pool are : max capacity, initial capacity, max wait timeout. If you want for example to open all connections at startup set the initial capacity = max capacity.
-- Each class is responsible to request and build its own schema. So, for example, if a runtime, the remote broker adds a new class and sends instrumentation or configuration data, a corresponding (empty) class definition will be created on QMan; immediately after that, the just created class will request its schema.
-
-*** OPEN POINTS ***
-
-1) Logging should be better : I mean, all messages should be prefixed with an id like <QMAN-xxxxxx>. At the moment not all messages are in this format.
-2) Code used for sending messages should be better (see QpidClass.schemaRequest() and QpidClass.methodRequest());
-3) Overloaded methods : At the moment each method is defined using its name as identifier and that thing doesn't work for overloaded methods...
-4) Default handlers (opcode handlers) must be hard-coded. Only add-on handler must be configurable. At the moment you can add & remove handler using configuration but in this way it's possible to remove the default handlers from the configuration and therefore QMan won't work at all!
-5) Method invocation : there is an echo() method on broker object instance that is throwing an exception while getting the response. It's strange because other method invocations are working (solicitAck(), close(), purge()). I'm working on that...
-5) Return values : are not handled at the moment : command messages must be sent synchronously in order to get the response message and pack the return value(s) in a composite structure used a return object; At the moment the corresponding handler for 'm' message is simply log (debug level) the content of the message, including status text and status code.
-6) It's not clear how to represent events on QMan (Is it useful?)
-7) Offline testcase must be made for all QMan features. There's still a lot of code duplication too :(
-8) Online testcase are missing.
-9) Performance test cases (using something like JPerf) are missing.
-10) ManagementDecoder & ManagementEncoder : I don't like very much those classes. For my opinionthe additional behaviour should be added on the
-corresponding BBDecoder & BBEncoder.
-
-*** Configuration file (org.apache.qpid.management.config.xml) ****
-
-1) RESPONSE MESSAGE HANDLERS
-
-An handler is responsible to handle a message response with a specific opcode. You can configure handlers under the /configuration/message-handlers.
-First, you can configure an handler for response messages coming from management queue and / or method-reply queue.
-The first category can be defined under the /configuration/message-handlers/method-reply-queue while the second one under /configuration/message-handlers/management-queue.
-An handler is configured defining two parameters
-
-<opcode>x</opcode> --> the opcode
-<class-name>xxx.xxx.xx.xxx</class-name> --> the implementation class
-
-2) TYPE MAPPINGS
-A type mapping declares a mapping between a code (defined in management specification) and a concrete implementor of org.apache.qpid.management.domain.model.type.Type.
-At the moment concrete implementors are:
-
-org.apache.qpid.management.domain.model.type.AbsTime.java
-org.apache.qpid.management.domain.model.type.Binary.java
-org.apache.qpid.management.domain.model.type.Boolean.java
-org.apache.qpid.management.domain.model.type.DeltaTime.java
-org.apache.qpid.management.domain.model.type.Map.java
-org.apache.qpid.management.domain.model.type.ObjectReference.java
-org.apache.qpid.management.domain.model.type.Str16.java
-org.apache.qpid.management.domain.model.type.Str8.java
-org.apache.qpid.management.domain.model.type.Type.java
-org.apache.qpid.management.domain.model.type.Uint16.java
-org.apache.qpid.management.domain.model.type.Uint32.java
-org.apache.qpid.management.domain.model.type.Uint64.java
-org.apache.qpid.management.domain.model.type.Uint8.java
-org.apache.qpid.management.domain.model.type.Uuid.java
-
-Anyway a type is defined under the /configuration/type-mappings/mapping using specifying properties:
-
-<mapping>
-<code>x</code> --> as defined in the management specification
-<class-name>xx.xxx.xxx.xx.x</class-name> --> a concrete implementor of org.apache.qpid.management.domain.model.type.Type (see above)
-</mapping>
-
-3) ACCESS MODE MAPPINGS
-A mapping between a code and a Access mode as defined on management specification.
-It is configured under /configuration/access-mode-mappings/mapping using these properties :
-
-<mapping>
-<code>x</code> --> as defined in the management specification
-<value>x</class-name> --> RC,RW,RO
-<mapping>
-
-4) BROKERS
-QMan is able to connect with one or more brokers. In order to do that each broker is configured under a dedicated /configuraton/brokers/broker using the following properties :
-
-<broker>
-<host>192.168.148.131</host> --> host name
-<port>5672</port> --> port
-<virtual-host>test</virtual-host> --> virtual host
-<user>pippo</user> --> username
-<password>pluto</password> --> password
-<max-pool-capacity>4</max-pool-capacity> --> connection pool max capacity
-<initial-pool-capacity>4</initial-pool-capacity> --> connetion pool initial capacity
-<max-wait-timeout>-1</max-wait-timeout> --> wait time timeout (-1 stands for forever)
-<broker>
-
-*** DEPENDENCIES ***
-qpid-common-incubating-M4.jar (already part of qpid)
-qpid-client-incubating-M4.jar (already part of qpid)
-slf4j-api-1.4.0.jar (already part of qpid)
-slf4j-log4j12-1.4.0.jar (already part of qpid)
-mina-filter-ssl-1.0.1.jar (already part of qpid)
-mina-core-1.0.1.jar (already part of qpid)
-log4j-1.2.12.jar (already part of qpid)
-commons-pool-1.4.jar (not part of qpid but attached to this post)
-
-
-*** PREREQUISITES ****
-
-You should have in your classpath a log4j.xml configuration file with a category defined as this :
+2)HOW TO RUN Q-Man
+
+2.1)PREREQUISITES
+QMan is a standalone application that is packaged as qpid-management-client-incubating-M3.jar. To run QMan you need to add the following jars in your CLASSPATH:
+
+log4j-1.2.12.jar
+slf4j-api-1.4.0.jar
+slf4j-log4j12-1.4.0.jar
+commons-pool-1.4.jar
+commons-codec-1.3.jar
+commons-lang-2.2.jar
+commons-collections-3.2.jar
+commons-configuration-1.2.jar
+qpid-client-incubating-Mx.jar (were x is the current qpid version)
+qpid-common-incubating-Mx.jar (were x is the current qpid version)
+
+alternatively you can run the following script (that add all the qpid jars to the CLASSPATH):
+
+> CLASSPATH=`find <lib-root> -name '*.jar' | tr '\n' ":"`
+
+Where <lib-root> is the directory containing the qpid jars (when qpid is built from source <lib-root> is equal to qpid/java/build/lib)
+
+You should have in your classpath a log4j.xml configuration file too with a category defined as this :
<category name="org.apache.qpid.management">
<priority value="INFO"/>
</category>
-it should be better if output is redirected to a file using a FileAppender.
-
-Now after set the classpath with the mentioned dependencies run :
+2.2) CONFIGURATION
+QMan can be connected at run time against any broker. However if you wish to automatically connect to one or several brokers you can do so by providing a configuration file as follows:
+
+<configuration>
+ <brokers>
+ <broker>
+ <host>localhost</host>
+ <port>5672</port>
+ <virtual-host>test</virtual-host>
+ <user>guest</user>
+ <password>guest</password>
+ <max-pool-capacity>4</max-pool-capacity>
+ <initial-pool-capacity>0</initial-pool-capacity>
+ <max-wait-timeout>-1</max-wait-timeout>
+ </broker>
+ <broker>
+ <host>myhost</host>
+ <port>5672</port>
+ <virtual-host>test</virtual-host>
+ <user>guest</user>
+ <password>guest</password>
+ <max-pool-capacity>4</max-pool-capacity>
+ <initial-pool-capacity>0</initial-pool-capacity>
+ <max-wait-timeout>-1</max-wait-timeout>
+ </broker>
+ </brokers>
+</configuration>
+The configuration above specifies that QMan should connect to two brokers, one on localhos and one on myhost, both listening on port 5672.
+
+The configuration file to use is specified through the JVM parameter "qman-config" that must point onto a valid configuration file.
+
+2.3)RUNNING Q-Man
+
+To run QMan in a console run the following command:
> java -Dcom.sun.management.jmxremote org.apache.qpid.management.domain.services.QMan
-If you open the jconsole ($JAVA_HOME/bin/jconsole) you will be able to see (under a Q-MAN domain) all the objects of the connected broker(s) as MBeans.
+Messages similar to those should be displayed:
+
+... [org.apache.qpid.management.domain.services.QMan] <QMAN-000001> : Starting Q-Man...
+...
+Type "q" to quit.
+
+if you wish to use a configuration file <home>/myconfiguration.xml so QMan establishes a connection with one or several brokers, run the following command:
+
+java -Dqman-config="<home>/myconfiguration.xml" org.apache.qpid.management.domain.services.QMan
+
+
+2.4) STOPPING Q-Man
+Type "q" In the console from which QMan has been started.
+
+3) Browsing Manageable Beans using JConsole
+The jconsole tool (JMX-compliant graphical tool for monitoring a Java virtual machine) can be used for monitoring and QMan Mbeans. for more information see http://java.sun.com/javase/6/docs/technotes/guides/management/jconsole.html
+
+The jconsole executable can be found in JDK_HOME/bin, where JDK_HOME is the directory in which the JDK software is installed. If this directory is in your system path, you can start JConsole by simply typing jconsole in a console. Otherwise, you have to type the full path to the executable file.
+
+As jconsole needs to perform operations invocation you will need to add the QMan jar in jconsole classpath. In a console type:
+
+jconsole -J-Djava.class.path=$CLASSPATH:$JAVA_HOME/lib/jconsole.jar:$JAVA_HOME/lib/tools.jar
+Where CLASSPATH contains the QMan jars and JAVA_HOME point on your JDK home.
+
+NOte that in order to see QMan JVM on JConsole you need to add the following command line option to QMan launcher : -Dcom.sun.management.jmxremote
+
+4) Deploying Q-Man on JBoss
+QMan comes with a servlet that can be deployed in any application server. In the following we show how to deploy the qman servlet within JBoss application server.
+
+4.1) PREREQUISITES
+You mus install JBoss:
+
+- Download the latest stable version from: http://www.jboss.org/jbossas/downloads/
+- Unzip the download archive in <jboss-home>
+
+4.2) Deploying
+First you need to copy the provided qman.war in <jboss-home>/server/default/deploy/ (note that you can use another server configuration like for example minimal)
+
+Then run JBoss:
+
+Add the following option-Djboss.platform.mbeanserver to JAVA_OPTS (for example: export JAVA_OPTS=-Djboss.platform.mbeanserver)
+Execute <jboss-home>/binrun.sh (or run.bat on a windows platform)
+Notes:
+
+If you wish to configure QMan via a configuration file so QMan establishes a connection with one or several broker at starting time then add the options -Dqman-config=myconfigFile.xml to JAVA_OPTS.
+When Qpid is built form source, the war archive qman.war is located in qpid/java/build/management/client/servlet
+
+Enjoy!
\ No newline at end of file diff --git a/java/management/client/src/main/java/org/apache/qpid/management/configuration/Configurator.java b/java/management/client/src/main/java/org/apache/qpid/management/configuration/Configurator.java index f9a662ffe7..45962d9cd5 100644 --- a/java/management/client/src/main/java/org/apache/qpid/management/configuration/Configurator.java +++ b/java/management/client/src/main/java/org/apache/qpid/management/configuration/Configurator.java @@ -41,6 +41,10 @@ import org.apache.qpid.management.domain.handler.impl.SchemaResponseMessageHandl import org.apache.qpid.management.domain.model.AccessMode; import org.apache.qpid.management.domain.model.type.AbsTime; import org.apache.qpid.management.domain.model.type.DeltaTime; +import org.apache.qpid.management.domain.model.type.Int16; +import org.apache.qpid.management.domain.model.type.Int32; +import org.apache.qpid.management.domain.model.type.Int64; +import org.apache.qpid.management.domain.model.type.Int8; import org.apache.qpid.management.domain.model.type.ObjectReference; import org.apache.qpid.management.domain.model.type.Str16; import org.apache.qpid.management.domain.model.type.Str8; @@ -228,8 +232,14 @@ public class Configurator extends DefaultHandler configuration.addTypeMapping(new TypeMapping(9,new DeltaTime())); configuration.addTypeMapping(new TypeMapping(10,new ObjectReference())); configuration.addTypeMapping(new TypeMapping(11,new org.apache.qpid.management.domain.model.type.Boolean())); + configuration.addTypeMapping(new TypeMapping(12,new org.apache.qpid.management.domain.model.type.Float(),Names.NUMBER_VALIDATOR)); + configuration.addTypeMapping(new TypeMapping(13,new org.apache.qpid.management.domain.model.type.Double(),Names.NUMBER_VALIDATOR)); configuration.addTypeMapping(new TypeMapping(14,new org.apache.qpid.management.domain.model.type.Uuid())); configuration.addTypeMapping(new TypeMapping(15,new org.apache.qpid.management.domain.model.type.Map())); + configuration.addTypeMapping(new TypeMapping(16,new Int8(),Names.NUMBER_VALIDATOR)); + configuration.addTypeMapping(new TypeMapping(17,new Int16(),Names.NUMBER_VALIDATOR)); + configuration.addTypeMapping(new TypeMapping(18,new Int32(),Names.NUMBER_VALIDATOR)); + configuration.addTypeMapping(new TypeMapping(19,new Int64(),Names.NUMBER_VALIDATOR)); } /** diff --git a/java/management/client/src/main/java/org/apache/qpid/management/configuration/QpidDatasource.java b/java/management/client/src/main/java/org/apache/qpid/management/configuration/QpidDatasource.java index 21bdea59b5..569a65a782 100644 --- a/java/management/client/src/main/java/org/apache/qpid/management/configuration/QpidDatasource.java +++ b/java/management/client/src/main/java/org/apache/qpid/management/configuration/QpidDatasource.java @@ -99,7 +99,7 @@ public final class QpidDatasource public void exception(Throwable t) { - super.exception(t); + //super.exception(t); _valid = false; } } diff --git a/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/base/ContentIndicationMessageHandler.java b/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/base/ContentIndicationMessageHandler.java index a5b30b382a..be000e9a05 100644 --- a/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/base/ContentIndicationMessageHandler.java +++ b/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/base/ContentIndicationMessageHandler.java @@ -21,7 +21,7 @@ package org.apache.qpid.management.domain.handler.base; import org.apache.qpid.management.domain.model.type.Binary; -import org.apache.qpid.transport.codec.ManagementDecoder; +import org.apache.qpid.transport.codec.Decoder; /** * Base class for content indication message handlers. @@ -36,7 +36,7 @@ public abstract class ContentIndicationMessageHandler extends BaseMessageHandler * @param decoder the decoder used to parse the message. * @param sequenceNumber the sequence number of the message. */ - public final void process (ManagementDecoder decoder, int sequenceNumber) + public final void process (Decoder decoder, int sequenceNumber) { String packageName = decoder.readStr8(); String className = decoder.readStr8(); diff --git a/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/base/IMessageHandler.java b/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/base/IMessageHandler.java index b945a29117..c120334d30 100644 --- a/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/base/IMessageHandler.java +++ b/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/base/IMessageHandler.java @@ -21,7 +21,7 @@ package org.apache.qpid.management.domain.handler.base; import org.apache.qpid.management.domain.model.DomainModel; -import org.apache.qpid.transport.codec.ManagementDecoder; +import org.apache.qpid.transport.codec.Decoder; /** * Interface definition for a processor able to deal with a specific message. @@ -41,7 +41,7 @@ public interface IMessageHandler * @param decoder the stream decoder. * @param sequenceNumber the sequence number of the message. */ - void process (ManagementDecoder decoder, int sequenceNumber); + void process (Decoder decoder, int sequenceNumber); /** * Injects the domain model into this handler. diff --git a/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/EventContentMessageHandler.java b/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/EventContentMessageHandler.java index 0a9e8138da..0a590d2836 100644 --- a/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/EventContentMessageHandler.java +++ b/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/EventContentMessageHandler.java @@ -22,7 +22,7 @@ package org.apache.qpid.management.domain.handler.impl; import org.apache.qpid.management.domain.handler.base.BaseMessageHandler;
import org.apache.qpid.management.domain.model.type.Binary;
-import org.apache.qpid.transport.codec.ManagementDecoder;
+import org.apache.qpid.transport.codec.Decoder;
/**
* Base class for content indication message handlers.
@@ -37,7 +37,7 @@ public class EventContentMessageHandler extends BaseMessageHandler * @param decoder the decoder used to parse the message.
* @param sequenceNumber the sequence number of the message.
*/
- public final void process (ManagementDecoder decoder, int sequenceNumber)
+ public final void process (Decoder decoder, int sequenceNumber)
{
String packageName = decoder.readStr8();
String eventName = decoder.readStr8();
diff --git a/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/HeartBeatIndicationMessageHandler.java b/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/HeartBeatIndicationMessageHandler.java index f3bb102926..eda35ea5a5 100644 --- a/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/HeartBeatIndicationMessageHandler.java +++ b/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/HeartBeatIndicationMessageHandler.java @@ -1,7 +1,7 @@ package org.apache.qpid.management.domain.handler.impl;
import org.apache.qpid.management.domain.handler.base.BaseMessageHandler;
-import org.apache.qpid.transport.codec.ManagementDecoder;
+import org.apache.qpid.transport.codec.Decoder;
/**
* This is the handler responsible for processing the heartbeat indication response messages.
@@ -11,7 +11,7 @@ import org.apache.qpid.transport.codec.ManagementDecoder; */
public class HeartBeatIndicationMessageHandler extends BaseMessageHandler
{
- public void process(ManagementDecoder decoder, int sequenceNumber)
+ public void process(Decoder decoder, int sequenceNumber)
{
_domainModel.updateLastRefreshDate();
}
diff --git a/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/MethodResponseMessageHandler.java b/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/MethodResponseMessageHandler.java index 3ca6faa2fd..9c99eb09aa 100644 --- a/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/MethodResponseMessageHandler.java +++ b/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/MethodResponseMessageHandler.java @@ -28,7 +28,7 @@ import org.apache.qpid.management.Messages; import org.apache.qpid.management.domain.handler.base.BaseMessageHandler; import org.apache.qpid.management.domain.model.DomainModel; import org.apache.qpid.management.domain.model.InvocationEvent; -import org.apache.qpid.transport.codec.ManagementDecoder; +import org.apache.qpid.transport.codec.Decoder; import org.apache.qpid.transport.util.Logger; /** @@ -70,7 +70,7 @@ public class MethodResponseMessageHandler extends BaseMessageHandler * @param decoder the decoder used for parsing incoming data. * @param sequenceNumber the sequence number of the incoming message. */ - public void process (ManagementDecoder decoder, int sequenceNumber) + public void process (Decoder decoder, int sequenceNumber) { InvocationResult result = new InvocationResult(decoder.readUint32(), decoder.readStr16(),decoder.readReaminingBytes()); BlockingQueue<InvocationResult> exchangeChannel = _exchangeChannels.remove(sequenceNumber); diff --git a/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/SchemaResponseMessageHandler.java b/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/SchemaResponseMessageHandler.java index 04357b8eb4..ee5efe2af6 100644 --- a/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/SchemaResponseMessageHandler.java +++ b/java/management/client/src/main/java/org/apache/qpid/management/domain/handler/impl/SchemaResponseMessageHandler.java @@ -29,7 +29,7 @@ import org.apache.qpid.management.Names; import org.apache.qpid.management.Protocol; import org.apache.qpid.management.domain.handler.base.BaseMessageHandler; import org.apache.qpid.management.domain.model.type.Binary; -import org.apache.qpid.transport.codec.ManagementDecoder; +import org.apache.qpid.transport.codec.Decoder; /** * Schema Response message handler. @@ -52,7 +52,7 @@ public class SchemaResponseMessageHandler extends BaseMessageHandler * * @param decoder the decoder used for dealing with incoming message. */ - void process(ManagementDecoder decoder); + void process(Decoder decoder); } /** @@ -60,7 +60,7 @@ public class SchemaResponseMessageHandler extends BaseMessageHandler */ final IProcessor _classSchemaProcessor = new IProcessor() { - public void process(ManagementDecoder decoder) + public void process(Decoder decoder) { try { @@ -92,7 +92,7 @@ public class SchemaResponseMessageHandler extends BaseMessageHandler */ final IProcessor _eventSchemaProcessor = new IProcessor() { - public void process(ManagementDecoder decoder) + public void process(Decoder decoder) { try { @@ -120,7 +120,7 @@ public class SchemaResponseMessageHandler extends BaseMessageHandler * @param decoder the decoder used for parsing the incoming stream. * @param sequenceNumber the sequence number of the incoming message. */ - public void process (ManagementDecoder decoder, int sequenceNumber) + public void process (Decoder decoder, int sequenceNumber) { try { @@ -155,7 +155,7 @@ public class SchemaResponseMessageHandler extends BaseMessageHandler * @param howManyProperties the number of properties to read. * @return a list of maps. Each map contains a property definition. */ - List<Map<String, Object>> getAttributes(ManagementDecoder decoder,int howMany) + List<Map<String, Object>> getAttributes(Decoder decoder,int howMany) { List<Map<String, Object>> result = new ArrayList<Map<String, Object>>(howMany); for (int i = 0; i < howMany; i++ ) @@ -172,7 +172,7 @@ public class SchemaResponseMessageHandler extends BaseMessageHandler * @param howManyMethods the number of methods to read. * @return a list method definitions. */ - List<MethodOrEventDataTransferObject> getMethods(ManagementDecoder decoder, int howManyMethods) + List<MethodOrEventDataTransferObject> getMethods(Decoder decoder, int howManyMethods) { List<MethodOrEventDataTransferObject> result = new ArrayList<MethodOrEventDataTransferObject>(howManyMethods); for (int i = 0; i < howManyMethods; i++) @@ -197,7 +197,7 @@ public class SchemaResponseMessageHandler extends BaseMessageHandler * @param howManyEvents the number of events to read. * @return a list event definitions. */ - List<MethodOrEventDataTransferObject> getEvents(ManagementDecoder decoder, int howManyEvents) + List<MethodOrEventDataTransferObject> getEvents(Decoder decoder, int howManyEvents) { List<MethodOrEventDataTransferObject> result = new ArrayList<MethodOrEventDataTransferObject>(howManyEvents); for (int i = 0; i < howManyEvents; i++) @@ -214,4 +214,4 @@ public class SchemaResponseMessageHandler extends BaseMessageHandler } return result; } - } + }
\ No newline at end of file diff --git a/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidArgument.java b/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidArgument.java index db3ddb97e7..1e90479c0b 100644 --- a/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidArgument.java +++ b/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidArgument.java @@ -21,8 +21,7 @@ package org.apache.qpid.management.domain.model; import org.apache.qpid.management.Messages; -import org.apache.qpid.management.messages.AmqpCoDec; -import org.apache.qpid.transport.codec.ManagementDecoder; +import org.apache.qpid.transport.codec.Encoder; import org.apache.qpid.transport.util.Logger; class QpidArgument extends QpidProperty @@ -70,13 +69,13 @@ class QpidArgument extends QpidProperty .toString(); } - public void encode(Object value,AmqpCoDec encoder) + public void encode(Object value,Encoder encoder) { _type.encode(value, encoder); LOGGER.debug(Messages.QMAN_200013_ARGUMENT_VALUE_ENCODED,value,_name,_type); } - public Object decode(ManagementDecoder decoder) + public Object decode(org.apache.qpid.transport.codec.Decoder decoder) { return _type.decode(decoder); } diff --git a/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidAttribute.java b/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidAttribute.java index 69b5cb0565..6712a14075 100644 --- a/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidAttribute.java +++ b/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidAttribute.java @@ -22,7 +22,7 @@ package org.apache.qpid.management.domain.model; import org.apache.qpid.management.Messages; import org.apache.qpid.management.domain.model.type.Type; -import org.apache.qpid.transport.codec.ManagementDecoder; +import org.apache.qpid.transport.codec.Decoder; import org.apache.qpid.transport.util.Logger; /** @@ -86,7 +86,7 @@ class QpidAttribute extends QpidFeature * @param decoder the decoder used to extract the value. * @return the value of this feature according to its type definition */ - Object decodeValue(ManagementDecoder decoder) + Object decodeValue(Decoder decoder) { try { return _type.decode(decoder); diff --git a/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidClass.java b/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidClass.java index 277d9e47a8..c7dfcb033c 100644 --- a/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidClass.java +++ b/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidClass.java @@ -52,7 +52,7 @@ import org.apache.qpid.management.domain.handler.impl.InvocationResult; import org.apache.qpid.management.domain.handler.impl.MethodOrEventDataTransferObject; import org.apache.qpid.management.domain.model.type.Binary; import org.apache.qpid.management.domain.services.SequenceNumberGenerator; -import org.apache.qpid.transport.codec.ManagementDecoder; +import org.apache.qpid.transport.codec.BBDecoder; import org.apache.qpid.transport.util.Logger; /** @@ -693,7 +693,7 @@ class QpidClass extends QpidEntity */ void updateInstanceWithConfigurationData(QpidManagedObject instance,byte [] rawData) { - ManagementDecoder decoder = new ManagementDecoder(); + BBDecoder decoder = new BBDecoder(); decoder.init(ByteBuffer.wrap(rawData)); byte [] presenceBitMasks = decoder.readBytes(_howManyPresenceBitMasks); @@ -716,7 +716,7 @@ class QpidClass extends QpidEntity */ void updateInstanceWithInstrumentationData(QpidManagedObject instance,byte [] rawData) { - ManagementDecoder decoder = new ManagementDecoder(); + BBDecoder decoder = new BBDecoder(); decoder.init(ByteBuffer.wrap(rawData)); for (QpidStatistic statistic : _schemaOrderedStatistics) diff --git a/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidEvent.java b/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidEvent.java index e6205bba76..273ae650c1 100644 --- a/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidEvent.java +++ b/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidEvent.java @@ -40,7 +40,7 @@ import javax.management.RuntimeOperationsException; import org.apache.qpid.management.Messages; import org.apache.qpid.management.domain.model.type.Binary; -import org.apache.qpid.transport.codec.ManagementDecoder; +import org.apache.qpid.transport.codec.BBDecoder; /** * Qpid event definition. @@ -408,7 +408,7 @@ class QpidEvent extends QpidEntity */ void updateEventInstanceWithData(QpidManagedEvent instance) { - ManagementDecoder decoder = new ManagementDecoder(); + BBDecoder decoder = new BBDecoder(); decoder.init(ByteBuffer.wrap(instance._rawEventData)); for (QpidProperty property : _schemaOrderedArguments) diff --git a/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidMethod.java b/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidMethod.java index d1011420ef..7824ecc9a4 100644 --- a/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidMethod.java +++ b/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidMethod.java @@ -26,8 +26,8 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; -import org.apache.qpid.management.messages.AmqpCoDec; -import org.apache.qpid.transport.codec.ManagementDecoder; +import org.apache.qpid.transport.codec.BBDecoder; +import org.apache.qpid.transport.codec.Encoder; /** @@ -92,7 +92,7 @@ public class QpidMethod extends QpidFeature * @param parameters the parameters values. * @param encoder the encoder used for encoding. */ - public void encodeParameters (Object[] parameters, AmqpCoDec encoder) + public void encodeParameters (Object[] parameters, Encoder encoder) { int index = 0; for (QpidArgument argument : arguments) @@ -113,7 +113,7 @@ public class QpidMethod extends QpidFeature */ public Map<String, Object> decodeParameters (byte [] values) { - ManagementDecoder decoder = new ManagementDecoder(); + BBDecoder decoder = new BBDecoder(); decoder.init(ByteBuffer.wrap(values)); Map<String, Object> result = new HashMap<String, Object>(); diff --git a/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidProperty.java b/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidProperty.java index 6335a553ae..089b00c71c 100644 --- a/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidProperty.java +++ b/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidProperty.java @@ -25,7 +25,6 @@ import java.lang.reflect.Constructor; import org.apache.qpid.management.Messages; import org.apache.qpid.management.configuration.Configuration; import org.apache.qpid.management.domain.model.type.Type; -import org.apache.qpid.transport.codec.ManagementDecoder; import org.apache.qpid.transport.util.Logger; /** @@ -46,7 +45,7 @@ class QpidProperty extends QpidAttribute */ interface Decoder { - Object decodeValue(ManagementDecoder decoder,byte [] presenceBitMasks); + Object decodeValue(org.apache.qpid.transport.codec.Decoder decoder,byte [] presenceBitMasks); } /** @@ -54,7 +53,7 @@ class QpidProperty extends QpidAttribute */ final Decoder _optionalPropertyDecoder = new Decoder() { - public Object decodeValue (ManagementDecoder decoder, byte[] presenceBitMasks) + public Object decodeValue (org.apache.qpid.transport.codec.Decoder decoder, byte[] presenceBitMasks) { return ((presenceBitMasks[_optionalIndex/8] & MASKS[_maskIndex]) != 0) ? QpidProperty.this.decodeValue(decoder) @@ -67,7 +66,7 @@ class QpidProperty extends QpidAttribute */ final Decoder _mandatoryPropertyDecoder = new Decoder() { - public Object decodeValue (ManagementDecoder decoder, byte[] presenceBitMasks) + public Object decodeValue (org.apache.qpid.transport.codec.Decoder decoder, byte[] presenceBitMasks) { return QpidProperty.this.decodeValue(decoder); } @@ -186,7 +185,7 @@ class QpidProperty extends QpidAttribute * @param decoder the decoder used to extract the value. * @return the value of this feature according to its type definition */ - Object decodeValue(ManagementDecoder decoder,byte [] presenceBitMasks) + Object decodeValue(org.apache.qpid.transport.codec.Decoder decoder,byte [] presenceBitMasks) { return _decoder.decodeValue(decoder, presenceBitMasks); } diff --git a/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/AbsTime.java b/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/AbsTime.java index dd49636a5c..28f5f70c04 100644 --- a/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/AbsTime.java +++ b/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/AbsTime.java @@ -20,8 +20,8 @@ */ package org.apache.qpid.management.domain.model.type; -import org.apache.qpid.management.messages.AmqpCoDec; -import org.apache.qpid.transport.codec.ManagementDecoder; +import org.apache.qpid.transport.codec.Decoder; +import org.apache.qpid.transport.codec.Encoder; public class AbsTime extends Type { @@ -31,14 +31,14 @@ public class AbsTime extends Type } @Override - public Object decode (ManagementDecoder decoder) + public Object decode (Decoder decoder) { - return decoder.readUint64(); + return decoder.readInt64(); } @Override - public void encode (Object value, AmqpCoDec encoder) + public void encode (Object value, Encoder encoder) { - encoder.pack64((Long)value); + encoder.writeInt64((Long)value); } }
\ No newline at end of file diff --git a/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Binary.java b/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Binary.java index 02b38d8499..8009150eb2 100644 --- a/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Binary.java +++ b/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Binary.java @@ -25,6 +25,7 @@ import java.util.Arrays; import java.util.UUID; import org.apache.qpid.management.messages.AmqpCoDec; +import org.apache.qpid.transport.codec.Encoder; /** * It is a simple wrapper for a byte array (for example a 128bin). @@ -117,9 +118,9 @@ public final class Binary implements Serializable * * @param encoder the encoder used to encode instance content. */ - public void encode(AmqpCoDec encoder) + public void encode(Encoder encoder) { - encoder.pack(_bytes); + encoder.writeBin128(_bytes); } @Override diff --git a/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Boolean.java b/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Boolean.java index d9407fd200..c339b870ac 100644 --- a/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Boolean.java +++ b/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Boolean.java @@ -20,8 +20,8 @@ */ package org.apache.qpid.management.domain.model.type; -import org.apache.qpid.management.messages.AmqpCoDec; -import org.apache.qpid.transport.codec.ManagementDecoder; +import org.apache.qpid.transport.codec.Decoder; +import org.apache.qpid.transport.codec.Encoder; public class Boolean extends Type { @@ -31,14 +31,14 @@ public class Boolean extends Type } @Override - public Object decode (ManagementDecoder decoder) + public Object decode (Decoder decoder) { return (decoder.readUint8() == 1); } @Override - public void encode (Object value, AmqpCoDec encoder) + public void encode (Object value, Encoder encoder) { - encoder.pack8( ((java.lang.Boolean)value) ? 1 : 0); + encoder.writeUint8( ((java.lang.Boolean)value) ? (short)1 : 0 ); } }
\ No newline at end of file diff --git a/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/DeltaTime.java b/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/DeltaTime.java index a05bd3fe58..a788e2f8e1 100644 --- a/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/DeltaTime.java +++ b/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/DeltaTime.java @@ -20,8 +20,8 @@ */ package org.apache.qpid.management.domain.model.type; -import org.apache.qpid.management.messages.AmqpCoDec; -import org.apache.qpid.transport.codec.ManagementDecoder; +import org.apache.qpid.transport.codec.Decoder; +import org.apache.qpid.transport.codec.Encoder; public class DeltaTime extends Type { @@ -31,14 +31,14 @@ public class DeltaTime extends Type } @Override - public Object decode (ManagementDecoder decoder) + public Object decode (Decoder decoder) { return decoder.readUint64(); } @Override - public void encode (Object value, AmqpCoDec encoder) + public void encode (Object value, Encoder encoder) { - encoder.pack64((Long)value); + encoder.writeUint64((Long)value); } }
\ No newline at end of file diff --git a/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Map.java b/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Map.java index 645df0d9ac..cc540ff4da 100644 --- a/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Map.java +++ b/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Map.java @@ -20,8 +20,8 @@ */ package org.apache.qpid.management.domain.model.type; -import org.apache.qpid.management.messages.AmqpCoDec; -import org.apache.qpid.transport.codec.ManagementDecoder; +import org.apache.qpid.transport.codec.Decoder; +import org.apache.qpid.transport.codec.Encoder; public class Map extends Type { @@ -31,15 +31,14 @@ public class Map extends Type } @Override - public Object decode (ManagementDecoder decoder) + public Object decode (Decoder decoder) { return decoder.readMap(); } @Override - public void encode (Object value, AmqpCoDec encoder) + public void encode (Object value, Encoder encoder) { - throw new RuntimeException("encode not yet supported for AMQP Map type."); - //encoder.writeMap((java.util.Map<String, Object>)value); + encoder.writeMap((java.util.Map<String, Object>)value); } }
\ No newline at end of file diff --git a/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/ObjectReference.java b/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/ObjectReference.java index 3285c3c37e..13e1b68d26 100644 --- a/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/ObjectReference.java +++ b/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/ObjectReference.java @@ -20,8 +20,8 @@ */ package org.apache.qpid.management.domain.model.type; -import org.apache.qpid.management.messages.AmqpCoDec; -import org.apache.qpid.transport.codec.ManagementDecoder; +import org.apache.qpid.transport.codec.Decoder; +import org.apache.qpid.transport.codec.Encoder; public class ObjectReference extends Type { @@ -31,13 +31,13 @@ public class ObjectReference extends Type } @Override - public Object decode (ManagementDecoder decoder) + public Object decode (Decoder decoder) { return decoder.readBin128(); } @Override - public void encode (Object value, AmqpCoDec encoder) + public void encode (Object value, Encoder encoder) { ((Binary)value).encode(encoder); } diff --git a/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Str16.java b/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Str16.java index 0bffaba9fe..42829ce176 100644 --- a/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Str16.java +++ b/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Str16.java @@ -20,8 +20,8 @@ */ package org.apache.qpid.management.domain.model.type; -import org.apache.qpid.management.messages.AmqpCoDec; -import org.apache.qpid.transport.codec.ManagementDecoder; +import org.apache.qpid.transport.codec.Decoder; +import org.apache.qpid.transport.codec.Encoder; public class Str16 extends Type { @@ -31,14 +31,14 @@ public class Str16 extends Type } @Override - public Object decode (ManagementDecoder decoder) + public Object decode (Decoder decoder) { return decoder.readStr16(); } @Override - public void encode (Object value, AmqpCoDec encoder) + public void encode (Object value, Encoder encoder) { - encoder.packStr16((String)value); + encoder.writeStr16((String)value); } }
\ No newline at end of file diff --git a/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Str8.java b/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Str8.java index 730d5b4c78..f9b747ce6d 100644 --- a/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Str8.java +++ b/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Str8.java @@ -20,8 +20,8 @@ */ package org.apache.qpid.management.domain.model.type; -import org.apache.qpid.management.messages.AmqpCoDec; -import org.apache.qpid.transport.codec.ManagementDecoder; +import org.apache.qpid.transport.codec.Decoder; +import org.apache.qpid.transport.codec.Encoder; public class Str8 extends Type { @@ -31,14 +31,14 @@ public class Str8 extends Type } @Override - public Object decode (ManagementDecoder decoder) + public Object decode (Decoder decoder) { return decoder.readStr8(); } @Override - public void encode (Object value, AmqpCoDec encoder) + public void encode (Object value, Encoder encoder) { - encoder.packStr8((String)value); + encoder.writeStr8((String)value); } }
\ No newline at end of file diff --git a/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Type.java b/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Type.java index 2242b986e0..c455faaf2c 100644 --- a/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Type.java +++ b/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Type.java @@ -20,8 +20,8 @@ */ package org.apache.qpid.management.domain.model.type; -import org.apache.qpid.management.messages.AmqpCoDec; -import org.apache.qpid.transport.codec.ManagementDecoder; +import org.apache.qpid.transport.codec.Decoder; +import org.apache.qpid.transport.codec.Encoder; /** * Layer supertype for all management "types". @@ -60,7 +60,7 @@ public abstract class Type * @return the "typed" value. * */ - public abstract Object decode(ManagementDecoder decoder); + public abstract Object decode(Decoder decoder); /** * Returns a string representation of this type. @@ -91,5 +91,11 @@ public abstract class Type return getClass().hashCode(); } - public abstract void encode (Object value, AmqpCoDec encoder); + /** + * Encodes the given values according to this type definition. + * + * @param value the value to be encoded. + * @param encoder the encoder. + */ + public abstract void encode (Object value,Encoder encoder); }
\ No newline at end of file diff --git a/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Uint16.java b/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Uint16.java index 045924157d..2d3edd41ea 100644 --- a/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Uint16.java +++ b/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Uint16.java @@ -20,8 +20,8 @@ */ package org.apache.qpid.management.domain.model.type; -import org.apache.qpid.management.messages.AmqpCoDec; -import org.apache.qpid.transport.codec.ManagementDecoder; +import org.apache.qpid.transport.codec.Decoder; +import org.apache.qpid.transport.codec.Encoder; public class Uint16 extends Type { @@ -31,14 +31,14 @@ public class Uint16 extends Type } @Override - public Object decode (ManagementDecoder decoder) + public Object decode (Decoder decoder) { return new Integer(decoder.readUint16()); } @Override - public void encode (Object value, AmqpCoDec encoder) + public void encode (Object value, Encoder encoder) { - encoder.pack16((Integer)value); + encoder.writeUint16((Integer)value); } }
\ No newline at end of file diff --git a/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Uint32.java b/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Uint32.java index dc49695934..c5fb981bb0 100644 --- a/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Uint32.java +++ b/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Uint32.java @@ -20,8 +20,8 @@ */ package org.apache.qpid.management.domain.model.type; -import org.apache.qpid.management.messages.AmqpCoDec; -import org.apache.qpid.transport.codec.ManagementDecoder; +import org.apache.qpid.transport.codec.Decoder; +import org.apache.qpid.transport.codec.Encoder; public class Uint32 extends Type { @@ -31,14 +31,14 @@ public class Uint32 extends Type } @Override - public Object decode (ManagementDecoder decoder) + public Object decode (Decoder decoder) { return new Long(decoder.readUint32()); } @Override - public void encode (Object value, AmqpCoDec encoder) + public void encode (Object value, Encoder encoder) { - encoder.pack32(((Number)value).intValue()); + encoder.writeUint32((Long)value); } } diff --git a/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Uint64.java b/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Uint64.java index bd35500400..9182f883bf 100644 --- a/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Uint64.java +++ b/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Uint64.java @@ -20,8 +20,8 @@ */ package org.apache.qpid.management.domain.model.type; -import org.apache.qpid.management.messages.AmqpCoDec; -import org.apache.qpid.transport.codec.ManagementDecoder; +import org.apache.qpid.transport.codec.Decoder; +import org.apache.qpid.transport.codec.Encoder; public class Uint64 extends Type { @@ -31,14 +31,14 @@ public class Uint64 extends Type } @Override - public Object decode (ManagementDecoder decoder) + public Object decode (Decoder decoder) { return new Long(decoder.readUint64()); } @Override - public void encode (Object value, AmqpCoDec encoder) + public void encode (Object value, Encoder encoder) { - encoder.pack64((Long)value); + encoder.writeUint64((Long)value); } }
\ No newline at end of file diff --git a/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Uint8.java b/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Uint8.java index c71648ae85..ab7e78856c 100644 --- a/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Uint8.java +++ b/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Uint8.java @@ -20,8 +20,8 @@ */ package org.apache.qpid.management.domain.model.type; -import org.apache.qpid.management.messages.AmqpCoDec; -import org.apache.qpid.transport.codec.ManagementDecoder; +import org.apache.qpid.transport.codec.Decoder; +import org.apache.qpid.transport.codec.Encoder; public class Uint8 extends Type { @@ -31,14 +31,14 @@ public class Uint8 extends Type } @Override - public Object decode (ManagementDecoder decoder) + public Object decode (Decoder decoder) { return new Short(decoder.readUint8()); } @Override - public void encode (Object value, AmqpCoDec encoder) + public void encode (Object value, Encoder encoder) { - encoder.pack8((Short)value); + encoder.writeUint8((Short)value); } }
\ No newline at end of file diff --git a/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Uuid.java b/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Uuid.java index 3b22449ea4..1b3be954d6 100644 --- a/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Uuid.java +++ b/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Uuid.java @@ -22,8 +22,8 @@ package org.apache.qpid.management.domain.model.type; import java.util.UUID; -import org.apache.qpid.management.messages.AmqpCoDec; -import org.apache.qpid.transport.codec.ManagementDecoder; +import org.apache.qpid.transport.codec.Decoder; +import org.apache.qpid.transport.codec.Encoder; public class Uuid extends Type { @@ -33,15 +33,14 @@ public class Uuid extends Type } @Override - public Object decode (ManagementDecoder decoder) + public Object decode (Decoder decoder) { return decoder.readUuid(); } @Override - public void encode (Object value, AmqpCoDec encoder) + public void encode (Object value, Encoder encoder) { - throw new RuntimeException("Not yet implemented encode for UUID type."); -// encoder.writeUuid((UUID)value); + encoder.writeUuid((UUID)value); } }
\ No newline at end of file diff --git a/java/management/client/src/main/java/org/apache/qpid/management/domain/services/BrokerMessageListener.java b/java/management/client/src/main/java/org/apache/qpid/management/domain/services/BrokerMessageListener.java index 135acbd36d..aa588043aa 100644 --- a/java/management/client/src/main/java/org/apache/qpid/management/domain/services/BrokerMessageListener.java +++ b/java/management/client/src/main/java/org/apache/qpid/management/domain/services/BrokerMessageListener.java @@ -33,7 +33,7 @@ import org.apache.qpid.management.Protocol; import org.apache.qpid.management.domain.handler.base.IMessageHandler; import org.apache.qpid.management.domain.model.DomainModel; import org.apache.qpid.nclient.util.MessageListener; -import org.apache.qpid.transport.codec.ManagementDecoder; +import org.apache.qpid.transport.codec.BBDecoder; import org.apache.qpid.transport.util.Logger; /** @@ -162,7 +162,7 @@ class BrokerMessageListener implements MessageListener IMessageHandler handler = _handlers.get(opcode); if (handler != null) { - ManagementDecoder decoder = new ManagementDecoder(); + BBDecoder decoder = new BBDecoder(); decoder.init(buffer); LOGGER.debug(Messages.QMAN_200003_MESSAGE_FORWARDING,opcode,handler); diff --git a/java/management/client/src/main/java/org/apache/qpid/management/domain/services/MessageTokenizer.java b/java/management/client/src/main/java/org/apache/qpid/management/domain/services/MessageTokenizer.java index 1b5de9663e..cabc568d6f 100644 --- a/java/management/client/src/main/java/org/apache/qpid/management/domain/services/MessageTokenizer.java +++ b/java/management/client/src/main/java/org/apache/qpid/management/domain/services/MessageTokenizer.java @@ -9,7 +9,7 @@ import org.apache.qpid.api.Message; import org.apache.qpid.management.Messages;
import org.apache.qpid.management.Protocol;
import org.apache.qpid.nclient.util.ByteBufferMessage;
-import org.apache.qpid.transport.codec.ManagementDecoder;
+import org.apache.qpid.transport.codec.BBDecoder;
import org.apache.qpid.transport.util.Logger;
/**
@@ -101,7 +101,7 @@ class MessageTokenizer implements Enumeration<Message> int startIndex = 0;
int indexOfMagicNumber = 0;
- ManagementDecoder decoder = new ManagementDecoder();
+ BBDecoder decoder = new BBDecoder();
decoder.init(compoundMessage.readData());
byte [] source = decoder.readReaminingBytes();
diff --git a/java/management/client/src/main/java/org/apache/qpid/management/messages/ManagementMessage.java b/java/management/client/src/main/java/org/apache/qpid/management/messages/ManagementMessage.java index d797cb0579..2fa20fb456 100644 --- a/java/management/client/src/main/java/org/apache/qpid/management/messages/ManagementMessage.java +++ b/java/management/client/src/main/java/org/apache/qpid/management/messages/ManagementMessage.java @@ -29,6 +29,7 @@ import org.apache.qpid.management.domain.services.SequenceNumberGenerator; import org.apache.qpid.transport.DeliveryProperties; import org.apache.qpid.transport.Header; import org.apache.qpid.transport.MessageProperties; +import org.apache.qpid.transport.codec.BBEncoder; /** * Message implementation used for specific management purposes. @@ -63,17 +64,18 @@ public abstract class ManagementMessage implements Message IDataBuilderStrategy ACCUMULATING = new IDataBuilderStrategy() { public ByteBuffer getData() { - _codec.pack8((byte)opcode()); - _codec.pack32(sequenceNumber()); + _codec.writeInt8((byte)opcode()); + _codec.writeSequenceNo(sequenceNumber()); specificMessageEncoding(); - _data =_codec.getEncodedBuffer(); + + _data =_codec.segment(); _reader = READING; return _data; } }; - protected AmqpCoDec _codec; + protected BBEncoder _codec; protected ByteBuffer _data; private int _messageTransferId; private IDataBuilderStrategy _reader = ACCUMULATING; @@ -83,7 +85,8 @@ public abstract class ManagementMessage implements Message */ ManagementMessage() { - _codec = new AmqpCoDec(); + _codec = new BBEncoder(100); + _codec.writeMagicNumber(); } /** diff --git a/java/management/client/src/main/java/org/apache/qpid/management/messages/MethodInvocationRequestMessage.java b/java/management/client/src/main/java/org/apache/qpid/management/messages/MethodInvocationRequestMessage.java index fad42b125c..99916085d6 100644 --- a/java/management/client/src/main/java/org/apache/qpid/management/messages/MethodInvocationRequestMessage.java +++ b/java/management/client/src/main/java/org/apache/qpid/management/messages/MethodInvocationRequestMessage.java @@ -150,12 +150,12 @@ public abstract class MethodInvocationRequestMessage extends ManagementMessage void specificMessageEncoding () { objectId().encode(_codec); - _codec.packStr8(packageName()); - _codec.packStr8(className()); + _codec.writeStr8(packageName()); + _codec.writeStr8(className()); schemaHash().encode(_codec); QpidMethod method = method(); - _codec.packStr8(method.getName()); + _codec.writeStr8(method.getName()); method.encodeParameters(parameters(), _codec); } } diff --git a/java/management/client/src/main/java/org/apache/qpid/management/messages/SchemaRequestMessage.java b/java/management/client/src/main/java/org/apache/qpid/management/messages/SchemaRequestMessage.java index aa596c8413..9df1733649 100644 --- a/java/management/client/src/main/java/org/apache/qpid/management/messages/SchemaRequestMessage.java +++ b/java/management/client/src/main/java/org/apache/qpid/management/messages/SchemaRequestMessage.java @@ -61,8 +61,8 @@ public abstract class SchemaRequestMessage extends ManagementMessage @Override final void specificMessageEncoding () { - _codec.packStr8(packageName()); - _codec.packStr8(className()); + _codec.writeStr8(packageName()); + _codec.writeStr8(className()); schemaHash().encode(_codec); } } diff --git a/java/management/client/src/test/java/org/apache/qpid/management/configuration/ConfigurationTest.java b/java/management/client/src/test/java/org/apache/qpid/management/configuration/ConfigurationTest.java index ca6ae846a8..efd5990bd7 100644 --- a/java/management/client/src/test/java/org/apache/qpid/management/configuration/ConfigurationTest.java +++ b/java/management/client/src/test/java/org/apache/qpid/management/configuration/ConfigurationTest.java @@ -74,11 +74,11 @@ public class ConfigurationTest extends TestCase { try { - Configuration.getInstance().getType(TestConstants.VALID_CODE+1); + Configuration.getInstance().getType(Integer.MIN_VALUE); fail("If an unknwon code is supplied an exception must be thrown."); } catch (UnknownTypeCodeException expected) { - assertEquals(TestConstants.VALID_CODE+1,expected.getCode()); + assertEquals(Integer.MIN_VALUE,expected.getCode()); } } @@ -107,11 +107,11 @@ public class ConfigurationTest extends TestCase { try { - Configuration.getInstance().getAccessMode(TestConstants.VALID_CODE+1); + Configuration.getInstance().getAccessMode(Integer.MIN_VALUE); fail("If an unknwon code is supplied an exception must be thrown."); } catch (UnknownAccessCodeException expected) { - assertEquals(TestConstants.VALID_CODE+1,expected.getCode()); + assertEquals(Integer.MIN_VALUE,expected.getCode()); } } @@ -199,7 +199,6 @@ public class ConfigurationTest extends TestCase Map<Character, IMessageHandler> handlerMappings = Configuration.getInstance().getManagementQueueHandlers(); - assertEquals(2,handlerMappings.size()); assertEquals(instrMessageHandlerClassName,handlerMappings.get(instrMapping.getOpcode()).getClass().getName()); assertEquals(configMessageHandlerClassName,handlerMappings.get(configMapping.getOpcode()).getClass().getName()); } diff --git a/java/management/client/src/test/java/org/apache/qpid/management/domain/model/BaseDomainModelTestCase.java b/java/management/client/src/test/java/org/apache/qpid/management/domain/model/BaseDomainModelTestCase.java index 3ed9ed8a61..c528392a93 100644 --- a/java/management/client/src/test/java/org/apache/qpid/management/domain/model/BaseDomainModelTestCase.java +++ b/java/management/client/src/test/java/org/apache/qpid/management/domain/model/BaseDomainModelTestCase.java @@ -29,7 +29,7 @@ import junit.framework.TestCase; * * @author Andrea Gazzarini */ -public class BaseDomainModelTestCase extends TestCase +public abstract class BaseDomainModelTestCase extends TestCase { /** * Set up fixture for this test case. diff --git a/java/management/client/src/test/java/org/apache/qpid/management/domain/model/OptionalPropertiesTest.java b/java/management/client/src/test/java/org/apache/qpid/management/domain/model/OptionalPropertiesTest.java index a4e1e24ff3..553c1c21de 100644 --- a/java/management/client/src/test/java/org/apache/qpid/management/domain/model/OptionalPropertiesTest.java +++ b/java/management/client/src/test/java/org/apache/qpid/management/domain/model/OptionalPropertiesTest.java @@ -27,7 +27,7 @@ import java.util.List; import junit.framework.TestCase; import org.apache.qpid.management.domain.model.type.Uint64; -import org.apache.qpid.transport.codec.ManagementDecoder; +import org.apache.qpid.transport.codec.BBDecoder; public class OptionalPropertiesTest extends TestCase { @@ -60,7 +60,7 @@ public class OptionalPropertiesTest extends TestCase QpidProperty property = new QpidProperty(); // We don't need a decoder so in order to be sure that it won't be invoked set it to null. - ManagementDecoder nullDecoder = null; + BBDecoder nullDecoder = null; for (int i = 0; i < 8; i++) { @@ -92,7 +92,7 @@ public class OptionalPropertiesTest extends TestCase ByteBuffer buffer = ByteBuffer.allocate(8); buffer.putLong(_44); buffer.rewind(); - ManagementDecoder decoder = new ManagementDecoder(); + BBDecoder decoder = new BBDecoder(); decoder.init(buffer); assertEquals(_44,property.decodeValue(decoder, presenceBytes)); @@ -164,7 +164,7 @@ public class OptionalPropertiesTest extends TestCase } } buffer.rewind(); - ManagementDecoder decoder = new ManagementDecoder(); + BBDecoder decoder = new BBDecoder(); decoder.init(buffer); int index = 0; diff --git a/java/management/client/src/test/java/org/apache/qpid/management/domain/services/BrokerMessageListenerTest.java b/java/management/client/src/test/java/org/apache/qpid/management/domain/services/BrokerMessageListenerTest.java index c489f7d767..805c039a6f 100644 --- a/java/management/client/src/test/java/org/apache/qpid/management/domain/services/BrokerMessageListenerTest.java +++ b/java/management/client/src/test/java/org/apache/qpid/management/domain/services/BrokerMessageListenerTest.java @@ -32,7 +32,7 @@ import org.apache.qpid.management.TestConstants; import org.apache.qpid.management.domain.handler.base.IMessageHandler; import org.apache.qpid.management.domain.model.DomainModel; import org.apache.qpid.nclient.util.ByteBufferMessage; -import org.apache.qpid.transport.codec.ManagementDecoder; +import org.apache.qpid.transport.codec.Decoder; /** * Test case for Broker Message Listener. @@ -44,7 +44,7 @@ public class BrokerMessageListenerTest extends TestCase // An empty message handler user for test. private IMessageHandler _emptyMessageHandler = new IMessageHandler() { - public void process (ManagementDecoder decoder, int sequenceNumber) + public void process (Decoder decoder, int sequenceNumber) { } public void setDomainModel (DomainModel domainModel) @@ -55,7 +55,7 @@ public class BrokerMessageListenerTest extends TestCase // Another empty message handler user for test. private IMessageHandler _anotherEmptyMessageHandler = new IMessageHandler() { - public void process (ManagementDecoder decoder, int sequenceNumber) + public void process (Decoder decoder, int sequenceNumber) { } public void setDomainModel (DomainModel domainModel) @@ -111,7 +111,7 @@ public class BrokerMessageListenerTest extends TestCase IMessageHandler wrongMessageHandler = new IMessageHandler() { - public void process (ManagementDecoder decoder, int sequenceNumber) + public void process (Decoder decoder, int sequenceNumber) { } @@ -148,7 +148,7 @@ public class BrokerMessageListenerTest extends TestCase IMessageHandler neverCallMe = new IMessageHandler() { - public void process (ManagementDecoder decoder, int sequenceNumber) + public void process (Decoder decoder, int sequenceNumber) { fail("This test shouldn't never arrive at this point..."); } @@ -189,7 +189,7 @@ public class BrokerMessageListenerTest extends TestCase this._opcode = opcode; } - public void process (ManagementDecoder decoder, int sequenceNumber) + public void process (Decoder decoder, int sequenceNumber) { handlersMap.remove(_opcode); } diff --git a/java/management/client/src/test/java/org/apache/qpid/management/domain/services/MessageTokenizerTest.java b/java/management/client/src/test/java/org/apache/qpid/management/domain/services/MessageTokenizerTest.java index 5da3db2933..66ed7cdc18 100644 --- a/java/management/client/src/test/java/org/apache/qpid/management/domain/services/MessageTokenizerTest.java +++ b/java/management/client/src/test/java/org/apache/qpid/management/domain/services/MessageTokenizerTest.java @@ -2,16 +2,13 @@ package org.apache.qpid.management.domain.services; import java.io.IOException;
import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.*;
-import java.util.Random;
import junit.framework.TestCase;
import org.apache.qpid.api.Message;
import org.apache.qpid.nclient.util.ByteBufferMessage;
-import org.apache.qpid.transport.codec.ManagementDecoder;
+import org.apache.qpid.transport.codec.BBDecoder;
/**
* Tests case for messaeg tokenizer.
@@ -114,7 +111,7 @@ public class MessageTokenizerTest extends TestCase { private void assertEquals(Message message, byte [] expected) throws IOException
{
ByteBuffer messageContent = message.readData();
- ManagementDecoder decoder = new ManagementDecoder();
+ BBDecoder decoder = new BBDecoder();
decoder.init(messageContent);
byte [] content = decoder.readReaminingBytes();
assertTrue(Arrays.equals(content, expected));
|