summaryrefslogtreecommitdiff
path: root/java/common/src
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2007-02-23 11:36:44 +0000
committerGordon Sim <gsim@apache.org>2007-02-23 11:36:44 +0000
commit5fb71f78117c9bc9d50be8cf1ccc1534bdadefc6 (patch)
tree6c1084d8ba06a48c96076e1a6ad9cab1a3a6396e /java/common/src
parent067f367d27bef7500410ea27c000d0ca275c748a (diff)
downloadqpid-python-5fb71f78117c9bc9d50be8cf1ccc1534bdadefc6.tar.gz
Implementation of queue.unbind & message.get
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/qpid.0-9@510912 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/common/src')
-rw-r--r--java/common/src/main/java/org/apache/qpid/protocol/RequestToken.java69
1 files changed, 69 insertions, 0 deletions
diff --git a/java/common/src/main/java/org/apache/qpid/protocol/RequestToken.java b/java/common/src/main/java/org/apache/qpid/protocol/RequestToken.java
new file mode 100644
index 0000000000..ee274f9f66
--- /dev/null
+++ b/java/common/src/main/java/org/apache/qpid/protocol/RequestToken.java
@@ -0,0 +1,69 @@
+/*
+ *
+ * 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.protocol;
+
+import org.apache.qpid.framing.AMQMethodBody;
+
+/**
+ * Allows the context for a request to be passed around, simplying the
+ * task of responding to it.
+ */
+public class RequestToken<M extends AMQMethodBody>
+{
+ private final AMQProtocolWriter _session;
+ private final AMQMethodEvent<M> _request;
+ private final byte _major;
+ private final byte _minor;
+
+ public RequestToken(AMQProtocolWriter session, AMQMethodEvent<M> request, byte major, byte minor)
+ {
+ _session = session;
+ _request = request;
+ _major = major;
+ _minor = minor;
+ }
+
+ /**
+ * Sends a response to the request this token represents.
+ */
+ public void respond(AMQMethodBody response)
+ {
+ _session.writeResponse(_request.getChannelId(), _request.getRequestId(), response);
+ }
+
+ /**
+ * Provides access to the original request
+ */
+ public M getRequest()
+ {
+ return _request.getMethod();
+ }
+
+ public byte getMajor()
+ {
+ return _major;
+ }
+
+ public byte getMinor()
+ {
+ return _minor;
+ }
+}