From 5129ac060aed57d8e31a62c3cd64ff0ad8995949 Mon Sep 17 00:00:00 2001 From: Kim van der Riet Date: Fri, 22 Dec 2006 17:00:28 +0000 Subject: AMQP version using new generator - Part 1. In these changes, all places where version-specific info is required, it has been hard-wired to major=8, minor=0. The next phase of changes will connect the version info to that obtained from ProtocolInitiation for the current session. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@489691 13f79535-47bb-0310-9956-ffa450edef68 --- java/common/pom.xml | 15 +-- java/common/protocol-version.xml | 109 +++------------------ .../java/org/apache/qpid/AMQChannelException.java | 13 ++- .../main/java/org/apache/qpid/framing/AMQBody.java | 3 +- .../apache/qpid/framing/AMQDataBlockDecoder.java | 2 +- .../java/org/apache/qpid/framing/AMQFrame.java | 2 +- .../org/apache/qpid/framing/AMQMethodBody.java | 18 +++- .../apache/qpid/framing/AMQMethodBodyFactory.java | 7 +- .../qpid/framing/BasicContentHeaderProperties.java | 2 +- .../org/apache/qpid/framing/ContentHeaderBody.java | 6 +- .../qpid/framing/ContentHeaderProperties.java | 2 +- .../framing/ContentHeaderPropertiesFactory.java | 17 ++-- java/common/src/main/xsl/cluster.asl | 12 +-- 13 files changed, 77 insertions(+), 131 deletions(-) (limited to 'java/common') diff --git a/java/common/pom.xml b/java/common/pom.xml index 653b2a8a9d..053fb5fafb 100644 --- a/java/common/pom.xml +++ b/java/common/pom.xml @@ -35,14 +35,12 @@ .. - ${basedir}/src/main/xsl/cluster.asl - ${basedir}/src/main/xsl/framing.xsl - ${basedir}/src/main/xsl/registry.xsl - ${basedir}/src/main/xsl/registry.template + ${topDirectoryLocation}/../gentools ${project.build.directory}/generated-sources/xsl org/apache/qpid/framing ${generated.path}/${generated.package} ${topDirectoryLocation}/../specs + ${basedir}/src/main/xsl/cluster.asl @@ -57,13 +55,10 @@ - - - - + - - + + ${generated.path} diff --git a/java/common/protocol-version.xml b/java/common/protocol-version.xml index 96ce348523..6a92dfbe2b 100644 --- a/java/common/protocol-version.xml +++ b/java/common/protocol-version.xml @@ -20,102 +20,21 @@ --> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Found AMQP specification file "${specs.dir}/amqp-@{ver}.xml"; major=${@{ver}.amqp(major)} minor=${@{ver}.amqp(minor)} - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - - - - - + + XML files to be processed: ${xml.spec.list} + + + diff --git a/java/common/src/main/java/org/apache/qpid/AMQChannelException.java b/java/common/src/main/java/org/apache/qpid/AMQChannelException.java index 4d604f8c0b..2ead0a03e6 100644 --- a/java/common/src/main/java/org/apache/qpid/AMQChannelException.java +++ b/java/common/src/main/java/org/apache/qpid/AMQChannelException.java @@ -27,23 +27,30 @@ public class AMQChannelException extends AMQException { private final int _classId; private final int _methodId; + /* AMQP version for which exception ocurred */ + private final byte major; + private final byte minor; - public AMQChannelException(int errorCode, String msg, int classId, int methodId, Throwable t) + public AMQChannelException(int errorCode, String msg, int classId, int methodId, byte major, byte minor, Throwable t) { super(errorCode, msg, t); _classId = classId; _methodId = methodId; + this.major = major; + this.minor = minor; } - public AMQChannelException(int errorCode, String msg, int classId, int methodId) + public AMQChannelException(int errorCode, String msg, int classId, int methodId, byte major, byte minor) { super(errorCode, msg); _classId = classId; _methodId = methodId; + this.major = major; + this.minor = minor; } public AMQFrame getCloseFrame(int channel) { - return ChannelCloseBody.createAMQFrame(channel, getErrorCode(), getMessage(), _classId, _methodId); + return ChannelCloseBody.createAMQFrame(channel, major, minor, _classId, _methodId, getErrorCode(), getMessage()); } } diff --git a/java/common/src/main/java/org/apache/qpid/framing/AMQBody.java b/java/common/src/main/java/org/apache/qpid/framing/AMQBody.java index d829144b11..36287d2923 100644 --- a/java/common/src/main/java/org/apache/qpid/framing/AMQBody.java +++ b/java/common/src/main/java/org/apache/qpid/framing/AMQBody.java @@ -34,5 +34,6 @@ public abstract class AMQBody protected abstract void writePayload(ByteBuffer buffer); - protected abstract void populateFromBuffer(ByteBuffer buffer, long size) throws AMQFrameDecodingException; + protected abstract void populateFromBuffer(ByteBuffer buffer, long size) + throws AMQFrameDecodingException, AMQProtocolVersionException; } diff --git a/java/common/src/main/java/org/apache/qpid/framing/AMQDataBlockDecoder.java b/java/common/src/main/java/org/apache/qpid/framing/AMQDataBlockDecoder.java index 438bfa8d82..2a999fe130 100644 --- a/java/common/src/main/java/org/apache/qpid/framing/AMQDataBlockDecoder.java +++ b/java/common/src/main/java/org/apache/qpid/framing/AMQDataBlockDecoder.java @@ -81,7 +81,7 @@ public class AMQDataBlockDecoder } protected Object createAndPopulateFrame(ByteBuffer in) - throws AMQFrameDecodingException + throws AMQFrameDecodingException, AMQProtocolVersionException { final byte type = in.get(); if (!isSupportedFrameType(type)) diff --git a/java/common/src/main/java/org/apache/qpid/framing/AMQFrame.java b/java/common/src/main/java/org/apache/qpid/framing/AMQFrame.java index e75f37d623..6af691fbe8 100644 --- a/java/common/src/main/java/org/apache/qpid/framing/AMQFrame.java +++ b/java/common/src/main/java/org/apache/qpid/framing/AMQFrame.java @@ -62,7 +62,7 @@ public class AMQFrame extends AMQDataBlock implements EncodableAMQDataBlock * @throws AMQFrameDecodingException */ public void populateFromBuffer(ByteBuffer buffer, int channel, long bodySize, BodyFactory bodyFactory) - throws AMQFrameDecodingException + throws AMQFrameDecodingException, AMQProtocolVersionException { this.channel = channel; bodyFrame = bodyFactory.createBody(buffer); diff --git a/java/common/src/main/java/org/apache/qpid/framing/AMQMethodBody.java b/java/common/src/main/java/org/apache/qpid/framing/AMQMethodBody.java index 6659b4ff8f..5ccc900b2c 100644 --- a/java/common/src/main/java/org/apache/qpid/framing/AMQMethodBody.java +++ b/java/common/src/main/java/org/apache/qpid/framing/AMQMethodBody.java @@ -26,6 +26,20 @@ import org.apache.qpid.AMQChannelException; public abstract class AMQMethodBody extends AMQBody { public static final byte TYPE = 1; + + /** + * AMQP version + */ + protected byte major; + protected byte minor; + public byte getMajor() { return major; } + public byte getMinor() { return minor; } + + public AMQMethodBody(byte major, byte minor) + { + this.major = major; + this.minor = minor; + } /** unsigned short */ protected abstract int getBodySize(); @@ -80,11 +94,11 @@ public abstract class AMQMethodBody extends AMQBody */ public AMQChannelException getChannelException(int code, String message) { - return new AMQChannelException(code, message, getClazz(), getMethod()); + return new AMQChannelException(code, message, getClazz(), getMethod(), major, minor); } public AMQChannelException getChannelException(int code, String message, Throwable cause) { - return new AMQChannelException(code, message, getClazz(), getMethod(), cause); + return new AMQChannelException(code, message, getClazz(), getMethod(), major, minor, cause); } } diff --git a/java/common/src/main/java/org/apache/qpid/framing/AMQMethodBodyFactory.java b/java/common/src/main/java/org/apache/qpid/framing/AMQMethodBodyFactory.java index 107af67dc7..da0909d32f 100644 --- a/java/common/src/main/java/org/apache/qpid/framing/AMQMethodBodyFactory.java +++ b/java/common/src/main/java/org/apache/qpid/framing/AMQMethodBodyFactory.java @@ -41,6 +41,11 @@ public class AMQMethodBodyFactory implements BodyFactory public AMQBody createBody(ByteBuffer in) throws AMQFrameDecodingException { - return MethodBodyDecoderRegistry.get(in.getUnsignedShort(), in.getUnsignedShort()); + // AMQP version change: MethodBodyDecoderRegistry is obsolete, since all the XML + // segments generated together are now handled by MainRegistry. The Cluster class, + // if generated together with amqp.xml is a part of MainRegistry. + // TODO: Connect with version acquired from ProtocolInitiation class. + return MainRegistry.get((short)in.getUnsignedShort(), (short)in.getUnsignedShort(), + (byte)8, (byte)0); } } diff --git a/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java b/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java index 61837f65cc..fc80d93f82 100644 --- a/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java +++ b/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java @@ -245,7 +245,7 @@ public class BasicContentHeaderProperties implements ContentHeaderProperties } public void populatePropertiesFromBuffer(ByteBuffer buffer, int propertyFlags, int size) - throws AMQFrameDecodingException + throws AMQFrameDecodingException, AMQProtocolVersionException { _propertyFlags = propertyFlags; diff --git a/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderBody.java b/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderBody.java index a59869b1d8..4ee36ee831 100644 --- a/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderBody.java +++ b/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderBody.java @@ -58,7 +58,8 @@ public class ContentHeaderBody extends AMQBody return TYPE; } - protected void populateFromBuffer(ByteBuffer buffer, long size) throws AMQFrameDecodingException + protected void populateFromBuffer(ByteBuffer buffer, long size) + throws AMQFrameDecodingException, AMQProtocolVersionException { classId = buffer.getUnsignedShort(); weight = buffer.getUnsignedShort(); @@ -75,7 +76,8 @@ public class ContentHeaderBody extends AMQBody * @return * @throws AMQFrameDecodingException */ - public static ContentHeaderBody createFromBuffer(ByteBuffer buffer, long size) throws AMQFrameDecodingException + public static ContentHeaderBody createFromBuffer(ByteBuffer buffer, long size) + throws AMQFrameDecodingException, AMQProtocolVersionException { ContentHeaderBody body = new ContentHeaderBody(); body.populateFromBuffer(buffer, size); diff --git a/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderProperties.java b/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderProperties.java index 561d7852fd..88bdefca88 100644 --- a/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderProperties.java +++ b/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderProperties.java @@ -41,7 +41,7 @@ public interface ContentHeaderProperties * @throws AMQFrameDecodingException when the buffer does not contain valid data */ void populatePropertiesFromBuffer(ByteBuffer buffer, int propertyFlags, int size) - throws AMQFrameDecodingException; + throws AMQFrameDecodingException, AMQProtocolVersionException; /** * @return the size of the encoded property list in bytes. diff --git a/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderPropertiesFactory.java b/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderPropertiesFactory.java index cec413cb9d..cfcc5db857 100644 --- a/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderPropertiesFactory.java +++ b/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderPropertiesFactory.java @@ -37,16 +37,19 @@ public class ContentHeaderPropertiesFactory public ContentHeaderProperties createContentHeaderProperties(int classId, int propertyFlags, ByteBuffer buffer, int size) - throws AMQFrameDecodingException + throws AMQFrameDecodingException, AMQProtocolVersionException { ContentHeaderProperties properties; - switch (classId) + // AMQP version change: "Hardwired" version to major=8, minor=0 + // TODO: Change so that the actual version is obtained from + // the ProtocolInitiation object for this session. + if (classId == BasicConsumeBody.getClazz((byte)8, (byte)0)) { - case BasicConsumeBody.CLASS_ID: - properties = new BasicContentHeaderProperties(); - break; - default: - throw new AMQFrameDecodingException("Unsupport content header class id: " + classId); + properties = new BasicContentHeaderProperties(); + } + else + { + throw new AMQFrameDecodingException("Unsupport content header class id: " + classId); } properties.populatePropertiesFromBuffer(buffer, propertyFlags, size); return properties; diff --git a/java/common/src/main/xsl/cluster.asl b/java/common/src/main/xsl/cluster.asl index 40ca937904..09e8ca0787 100644 --- a/java/common/src/main/xsl/cluster.asl +++ b/java/common/src/main/xsl/cluster.asl @@ -29,26 +29,26 @@ provide a clustered service to clients. - + - + - + - + - + - + -- cgit v1.2.1