diff options
| author | Robert Godfrey <rgodfrey@apache.org> | 2007-11-26 01:41:31 +0000 |
|---|---|---|
| committer | Robert Godfrey <rgodfrey@apache.org> | 2007-11-26 01:41:31 +0000 |
| commit | a1391b5724829e4268faf4de60625b2d05e86288 (patch) | |
| tree | d124245b02b8ead3be3e37cef3fbac684c606e4e /java/common | |
| parent | 66f97f32c78e0cf5914a441ae8277ee3aa659ce9 (diff) | |
| download | qpid-python-a1391b5724829e4268faf4de60625b2d05e86288.tar.gz | |
QPID-567 : Add mutliversion support to Qpid/Java, fixed client support when server returns Protocol header.
Added QueueUnbind
Added ability to select protocol version in ConnectionURL or with -Dorg.apache.qpid.amqp_version
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/M2.1@598105 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/common')
| -rw-r--r-- | java/common/src/main/java/org/apache/qpid/codec/AMQDecoder.java | 17 | ||||
| -rw-r--r-- | java/common/templates/model/ProtocolVersionListClass.vm | 23 |
2 files changed, 37 insertions, 3 deletions
diff --git a/java/common/src/main/java/org/apache/qpid/codec/AMQDecoder.java b/java/common/src/main/java/org/apache/qpid/codec/AMQDecoder.java index 02ae3cb089..ff0bc798da 100644 --- a/java/common/src/main/java/org/apache/qpid/codec/AMQDecoder.java +++ b/java/common/src/main/java/org/apache/qpid/codec/AMQDecoder.java @@ -56,6 +56,7 @@ public class AMQDecoder extends CumulativeProtocolDecoder /** Flag to indicate whether this decoder needs to handle protocol initiation. */ private boolean _expectProtocolInitiation; + private boolean firstDecode = true; /** * Creates a new AMQP decoder. @@ -81,14 +82,24 @@ public class AMQDecoder extends CumulativeProtocolDecoder */ protected boolean doDecode(IoSession session, ByteBuffer in, ProtocolDecoderOutput out) throws Exception { - if (_expectProtocolInitiation) + + boolean decoded; + if (_expectProtocolInitiation + || (firstDecode + && (in.remaining() > 0) + && (in.get(in.position()) == (byte)'A'))) { - return doDecodePI(session, in, out); + decoded = doDecodePI(session, in, out); } else { - return doDecodeDataBlock(session, in, out); + decoded = doDecodeDataBlock(session, in, out); + } + if(firstDecode && decoded) + { + firstDecode = false; } + return decoded; } /** diff --git a/java/common/templates/model/ProtocolVersionListClass.vm b/java/common/templates/model/ProtocolVersionListClass.vm index d56d14e1ed..9ac6adfdf5 100644 --- a/java/common/templates/model/ProtocolVersionListClass.vm +++ b/java/common/templates/model/ProtocolVersionListClass.vm @@ -33,6 +33,8 @@ package org.apache.qpid.framing; import java.util.SortedSet; import java.util.Collections; import java.util.TreeSet; +import java.util.Map; +import java.util.HashMap; public class ProtocolVersion implements Comparable @@ -124,6 +126,9 @@ public class ProtocolVersion implements Comparable } private static final SortedSet<ProtocolVersion> _supportedVersions; + private static final Map<String, ProtocolVersion> _nameToVersionMap = + new HashMap<String, ProtocolVersion>(); + private static final ProtocolVersion _defaultVersion; #foreach( $version in $model.getVersionSet() ) @@ -138,8 +143,17 @@ public class ProtocolVersion implements Comparable #foreach( $version in $model.getVersionSet() ) #set( $versionId = "v$version.getMajor()_$version.getMinor()" ) versions.add($versionId); + _nameToVersionMap.put("${version.getMajor()}-${version.getMinor()}", $versionId); #end _supportedVersions = Collections.unmodifiableSortedSet(versions); + + + ProtocolVersion systemDefinedVersion = + _nameToVersionMap.get(System.getProperty("org.apache.qpid.amqp_version")); + + _defaultVersion = (systemDefinedVersion == null) + ? getLatestSupportedVersion() + : systemDefinedVersion; } @@ -149,7 +163,16 @@ public class ProtocolVersion implements Comparable } + + public static ProtocolVersion parse(String name) + { + return _nameToVersionMap.get(name); + } + public static ProtocolVersion defaultProtocolVersion() + { + return _defaultVersion; + } } |
