summaryrefslogtreecommitdiff
path: root/qpid/java/common/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'qpid/java/common/src/main')
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpid/AMQProtocolException.java38
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpid/protocol/AMQConstant.java9
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpidity/ErrorCode.java1
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpidity/ProtocolException.java36
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpidity/ToyClient.java4
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpidity/transport/ConnectionDelegate.java8
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpidity/transport/TransportConstants.java24
7 files changed, 116 insertions, 4 deletions
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/AMQProtocolException.java b/qpid/java/common/src/main/java/org/apache/qpid/AMQProtocolException.java
new file mode 100644
index 0000000000..bbc569839a
--- /dev/null
+++ b/qpid/java/common/src/main/java/org/apache/qpid/AMQProtocolException.java
@@ -0,0 +1,38 @@
+package org.apache.qpid;
+
+import org.apache.qpid.protocol.AMQConstant;
+
+/* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+public class AMQProtocolException extends AMQException
+{
+ /**
+ * Constructor for a Protocol Exception
+ * <p> This is the only provided constructor and the parameters have to be
+ * set to null when they are unknown.
+ *
+ * @param msg A description of the reason of this exception .
+ * @param errorCode A string specifyin the error code of this exception.
+ * @param cause The linked Execption.
+ */
+ public AMQProtocolException(AMQConstant errorCode, String msg, Throwable cause)
+ {
+ super(errorCode, msg, cause);
+ }
+}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/protocol/AMQConstant.java b/qpid/java/common/src/main/java/org/apache/qpid/protocol/AMQConstant.java
index 375df2a45d..8dee790a9e 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/protocol/AMQConstant.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/protocol/AMQConstant.java
@@ -153,6 +153,15 @@ public final class AMQConstant
public static final AMQConstant FRAME_MIN_SIZE = new AMQConstant(4096, "frame min size", true);
+ /**
+ * The server does not support the protocol version
+ */
+ public static final AMQConstant UNSUPPORTED_BROKER_PROTOCOL_ERROR = new AMQConstant(542, "broker unsupported protocol", true);
+ /**
+ * The client imp does not support the protocol version
+ */
+ public static final AMQConstant UNSUPPORTED_CLIENT_PROTOCOL_ERROR = new AMQConstant(543, "client unsupported protocol", true);
+
/** The AMQP status code. */
private int _code;
diff --git a/qpid/java/common/src/main/java/org/apache/qpidity/ErrorCode.java b/qpid/java/common/src/main/java/org/apache/qpidity/ErrorCode.java
index 4ff6939139..4b18c46d16 100644
--- a/qpid/java/common/src/main/java/org/apache/qpidity/ErrorCode.java
+++ b/qpid/java/common/src/main/java/org/apache/qpidity/ErrorCode.java
@@ -6,6 +6,7 @@ public enum ErrorCode
UNDEFINED(1,"undefined",true),
MESSAGE_REJECTED(2,"message_rejected",true),
CONNECTION_ERROR(3,"connection was closed",true),
+ UNSUPPORTED_PROTOCOL(4, "protocol version is unsupported", true),
//This might change in the spec, the error class is not applicable
NO_ERROR(200,"reply-success",true),
diff --git a/qpid/java/common/src/main/java/org/apache/qpidity/ProtocolException.java b/qpid/java/common/src/main/java/org/apache/qpidity/ProtocolException.java
new file mode 100644
index 0000000000..596143a1b9
--- /dev/null
+++ b/qpid/java/common/src/main/java/org/apache/qpidity/ProtocolException.java
@@ -0,0 +1,36 @@
+/* Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.qpidity;
+
+public class ProtocolException extends QpidException
+{
+ /**
+ * Constructor for a Ptotocol Exception.
+ * <p> This is the only provided constructor and the parameters have to be set to null when
+ * they are unknown.
+ * @param message A description of the reason of this exception.
+ * @param errorCode A string specifyin the error code of this exception.
+ * @param cause The linked Execption.
+ *
+ */
+ public ProtocolException(String message, ErrorCode errorCode, Throwable cause)
+ {
+ super(message, errorCode, cause);
+ }
+}
diff --git a/qpid/java/common/src/main/java/org/apache/qpidity/ToyClient.java b/qpid/java/common/src/main/java/org/apache/qpidity/ToyClient.java
index e455be0873..10b68bbb20 100644
--- a/qpid/java/common/src/main/java/org/apache/qpidity/ToyClient.java
+++ b/qpid/java/common/src/main/java/org/apache/qpidity/ToyClient.java
@@ -75,7 +75,9 @@ class ToyClient extends SessionDelegate
}
public void closed() {}
});
- conn.send(new ConnectionEvent(0, new ProtocolHeader(1, TransportConstants.CONNECTION_VERSION_MAJOR, TransportConstants.CONNECTION_VERSION_MINOR)));
+ conn.send(new ConnectionEvent(0, new ProtocolHeader(1,
+ TransportConstants.getVersionMajor(),
+ TransportConstants.getVersionMinor())));
Channel ch = conn.getChannel(0);
Session ssn = new Session();
diff --git a/qpid/java/common/src/main/java/org/apache/qpidity/transport/ConnectionDelegate.java b/qpid/java/common/src/main/java/org/apache/qpidity/transport/ConnectionDelegate.java
index 21c7b8c16b..4815f1025f 100644
--- a/qpid/java/common/src/main/java/org/apache/qpidity/transport/ConnectionDelegate.java
+++ b/qpid/java/common/src/main/java/org/apache/qpidity/transport/ConnectionDelegate.java
@@ -83,7 +83,8 @@ public abstract class ConnectionDelegate extends MethodDelegate<Channel>
if (hdr.getMajor() != 0 && hdr.getMinor() != 10)
{
// XXX
- ch.getConnection().send(new ConnectionEvent(0, new ProtocolHeader(1, TransportConstants.CONNECTION_VERSION_MAJOR, TransportConstants.CONNECTION_VERSION_MINOR)));
+ ch.getConnection().send(new ConnectionEvent(0, new ProtocolHeader(1, TransportConstants.getVersionMajor(),
+ TransportConstants.getVersionMinor())));
ch.getConnection().close();
}
else
@@ -282,4 +283,9 @@ public abstract class ConnectionDelegate extends MethodDelegate<Channel>
{
_virtualHost = host;
}
+
+ public String getUnsupportedProtocol()
+ {
+ return null;
+ }
}
diff --git a/qpid/java/common/src/main/java/org/apache/qpidity/transport/TransportConstants.java b/qpid/java/common/src/main/java/org/apache/qpidity/transport/TransportConstants.java
index 47f7f17578..54429a1a4f 100644
--- a/qpid/java/common/src/main/java/org/apache/qpidity/transport/TransportConstants.java
+++ b/qpid/java/common/src/main/java/org/apache/qpidity/transport/TransportConstants.java
@@ -2,6 +2,26 @@ package org.apache.qpidity.transport;
public class TransportConstants
{
- public static final byte CONNECTION_VERSION_MAJOR = 99;
- public static final byte CONNECTION_VERSION_MINOR = 0;
+ private static byte _protocol_version_minor = 0;
+ private static byte _protocol_version_major = 99;
+
+ public static void setVersionMajor(byte value)
+ {
+ _protocol_version_major = value;
+ }
+
+ public static void setVersionMinor(byte value)
+ {
+ _protocol_version_minor = value;
+ }
+
+ public static byte getVersionMajor()
+ {
+ return _protocol_version_major;
+ }
+
+ public static byte getVersionMinor()
+ {
+ return _protocol_version_minor;
+ }
}