From 62c921bce20ab6d193602e31ccf75074efdf495d Mon Sep 17 00:00:00 2001 From: Kim van der Riet Date: Tue, 9 Jan 2007 19:47:02 +0000 Subject: New broker Messafe class handelrs added, removed old Basic* handlers; New framing Request and Response classes added git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/qpid.0-9@494541 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/qpid/framing/AMQRequest.java | 86 ---------------------- .../org/apache/qpid/framing/AMQRequestBody.java | 86 ++++++++++++++++++++++ .../java/org/apache/qpid/framing/AMQResponse.java | 86 ---------------------- .../org/apache/qpid/framing/AMQResponseBody.java | 70 ++++++++++++++++++ 4 files changed, 156 insertions(+), 172 deletions(-) delete mode 100644 java/common/src/main/java/org/apache/qpid/framing/AMQRequest.java create mode 100644 java/common/src/main/java/org/apache/qpid/framing/AMQRequestBody.java delete mode 100644 java/common/src/main/java/org/apache/qpid/framing/AMQResponse.java create mode 100644 java/common/src/main/java/org/apache/qpid/framing/AMQResponseBody.java (limited to 'java/common/src') diff --git a/java/common/src/main/java/org/apache/qpid/framing/AMQRequest.java b/java/common/src/main/java/org/apache/qpid/framing/AMQRequest.java deleted file mode 100644 index 821b5d177d..0000000000 --- a/java/common/src/main/java/org/apache/qpid/framing/AMQRequest.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * - * 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.qpid.framing; - -import org.apache.mina.common.ByteBuffer; - -public class AMQRequest extends AMQBody -{ - public static final byte TYPE = (byte)AmqpConstants.frameRequestAsInt(); - - // Fields declared in specification - public long requestId; - public long responseMark; - public AMQMethodBody methodPayload; - - - // Constructor - public AMQRequest() {} - - // Field methods - - public long getRequestId() { return requestId; } - public long getResponseMark() { return responseMark; } - public AMQMethodBody getMethodPayload() { return methodPayload; } - - - protected byte getFrameType() - { - return TYPE; - } - - protected int getSize() - { - return 8 + 8 + 4 + methodPayload.getBodySize(); - } - - protected void writePayload(ByteBuffer buffer) - { - EncodingUtils.writeLong(buffer, requestId); - EncodingUtils.writeLong(buffer, responseMark); - EncodingUtils.writeUnsignedShort(buffer, 0); // reserved, set to 0 - methodPayload.writePayload(buffer); - } - - protected void populateFromBuffer(ByteBuffer buffer, long size) - throws AMQFrameDecodingException, AMQProtocolVersionException - { - requestId = EncodingUtils.readLong(buffer); - responseMark = EncodingUtils.readLong(buffer); - int reserved = EncodingUtils.readShort(buffer); // reserved, throw away - methodPayload.populateFromBuffer(buffer, size - 8 - 8 - 4); - } - - public static AMQFrame createAMQFrame(int channelId, long requestId, - long responseMark, AMQMethodBody methodPayload) - { - AMQResponse responseFrame = new AMQResponse(); - responseFrame.requestId = requestId; - responseFrame.responseMark = responseMark; - responseFrame.methodPayload = methodPayload; - - - AMQFrame frame = new AMQFrame(); - frame.channel = channelId; - frame.bodyFrame = responseFrame; - return frame; - } -} diff --git a/java/common/src/main/java/org/apache/qpid/framing/AMQRequestBody.java b/java/common/src/main/java/org/apache/qpid/framing/AMQRequestBody.java new file mode 100644 index 0000000000..a60db0fa3f --- /dev/null +++ b/java/common/src/main/java/org/apache/qpid/framing/AMQRequestBody.java @@ -0,0 +1,86 @@ +/* + * + * 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.qpid.framing; + +import org.apache.mina.common.ByteBuffer; + +public class AMQRequestBody extends AMQBody +{ + public static final byte TYPE = (byte)AmqpConstants.frameRequestAsInt(); + + // Fields declared in specification + public long requestId; + public long responseMark; + public AMQMethodBody methodPayload; + + + // Constructor + public AMQRequestBody() {} + + // Field methods + + public long getRequestId() { return requestId; } + public long getResponseMark() { return responseMark; } + public AMQMethodBody getMethodPayload() { return methodPayload; } + + + protected byte getFrameType() + { + return TYPE; + } + + protected int getSize() + { + return 8 + 8 + 4 + methodPayload.getBodySize(); + } + + protected void writePayload(ByteBuffer buffer) + { + EncodingUtils.writeLong(buffer, requestId); + EncodingUtils.writeLong(buffer, responseMark); + EncodingUtils.writeUnsignedShort(buffer, 0); // reserved, set to 0 + methodPayload.writePayload(buffer); + } + + protected void populateFromBuffer(ByteBuffer buffer, long size) + throws AMQFrameDecodingException, AMQProtocolVersionException + { + requestId = EncodingUtils.readLong(buffer); + responseMark = EncodingUtils.readLong(buffer); + int reserved = EncodingUtils.readShort(buffer); // reserved, throw away + methodPayload.populateFromBuffer(buffer, size - 8 - 8 - 4); + } + + public static AMQFrame createAMQFrame(int channelId, long requestId, + long responseMark, AMQMethodBody methodPayload) + { + AMQResponseBody responseFrame = new AMQResponseBody(); + responseFrame.requestId = requestId; + responseFrame.responseMark = responseMark; + responseFrame.methodPayload = methodPayload; + + + AMQFrame frame = new AMQFrame(); + frame.channel = channelId; + frame.bodyFrame = responseFrame; + return frame; + } +} diff --git a/java/common/src/main/java/org/apache/qpid/framing/AMQResponse.java b/java/common/src/main/java/org/apache/qpid/framing/AMQResponse.java deleted file mode 100644 index bf4bec8cda..0000000000 --- a/java/common/src/main/java/org/apache/qpid/framing/AMQResponse.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * - * 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.qpid.framing; - -import org.apache.mina.common.ByteBuffer; - -public class AMQResponse extends AMQBody -{ - public static final byte TYPE = (byte)AmqpConstants.frameResponseAsInt(); - - // Fields declared in specification - public long requestId; - public long responseMark; - public int batchOffset; - public AMQMethodBody methodPayload; - - // Constructor - public AMQResponse() {} - - // Field methods - - public long getRequestId() { return requestId; } - public long getResponseMark() { return responseMark; } - public int getBatchOffset() { return batchOffset; } - public AMQMethodBody getMethodPayload() { return methodPayload; } - - protected byte getFrameType() - { - return TYPE; - } - - protected int getSize() - { - return 8 + 8 + 4 + methodPayload.getBodySize(); - } - - protected void writePayload(ByteBuffer buffer) - { - EncodingUtils.writeLong(buffer, requestId); - EncodingUtils.writeLong(buffer, responseMark); - EncodingUtils.writeUnsignedShort(buffer, batchOffset); - methodPayload.writePayload(buffer); - } - - protected void populateFromBuffer(ByteBuffer buffer, long size) - throws AMQFrameDecodingException, AMQProtocolVersionException - { - requestId = EncodingUtils.readLong(buffer); - responseMark = EncodingUtils.readLong(buffer); - batchOffset = EncodingUtils.readShort(buffer); - methodPayload.populateFromBuffer(buffer, size - 8 - 8 - 4); - } - - public static AMQFrame createAMQFrame(int channelId, long requestId, - long responseMark, int batchOffset, AMQMethodBody methodPayload) - { - AMQResponse responseFrame = new AMQResponse(); - responseFrame.requestId = requestId; - responseFrame.responseMark = responseMark; - responseFrame.batchOffset = batchOffset; - responseFrame.methodPayload = methodPayload; - - AMQFrame frame = new AMQFrame(); - frame.channel = channelId; - frame.bodyFrame = responseFrame; - return frame; - } -} diff --git a/java/common/src/main/java/org/apache/qpid/framing/AMQResponseBody.java b/java/common/src/main/java/org/apache/qpid/framing/AMQResponseBody.java new file mode 100644 index 0000000000..c86bcbe2ad --- /dev/null +++ b/java/common/src/main/java/org/apache/qpid/framing/AMQResponseBody.java @@ -0,0 +1,70 @@ +/* + * + * 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.qpid.framing; + +import org.apache.mina.common.ByteBuffer; + +public class AMQResponseBody extends AMQRequestBody +{ + public static final byte TYPE = (byte)AmqpConstants.frameResponseAsInt(); + + // Fields declared in specification + public int batchOffset; + + // Constructor + public AMQResponseBody() {} + + // Field methods + + public int getBatchOffset() { return batchOffset; } + + protected void writePayload(ByteBuffer buffer) + { + EncodingUtils.writeLong(buffer, requestId); + EncodingUtils.writeLong(buffer, responseMark); + EncodingUtils.writeUnsignedShort(buffer, batchOffset); + methodPayload.writePayload(buffer); + } + + protected void populateFromBuffer(ByteBuffer buffer, long size) + throws AMQFrameDecodingException, AMQProtocolVersionException + { + requestId = EncodingUtils.readLong(buffer); + responseMark = EncodingUtils.readLong(buffer); + batchOffset = EncodingUtils.readShort(buffer); + methodPayload.populateFromBuffer(buffer, size - 8 - 8 - 4); + } + + public static AMQFrame createAMQFrame(int channelId, long requestId, + long responseMark, int batchOffset, AMQMethodBody methodPayload) + { + AMQResponseBody responseFrame = new AMQResponseBody(); + responseFrame.requestId = requestId; + responseFrame.responseMark = responseMark; + responseFrame.batchOffset = batchOffset; + responseFrame.methodPayload = methodPayload; + + AMQFrame frame = new AMQFrame(); + frame.channel = channelId; + frame.bodyFrame = responseFrame; + return frame; + } +} -- cgit v1.2.1