diff options
author | Alan Conway <aconway@apache.org> | 2007-08-14 16:15:26 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2007-08-14 16:15:26 +0000 |
commit | cb65298edd497295d215220397f8fedff7b14aca (patch) | |
tree | 9f3a167ef11b0f3bd918507767fbf455d362d79d /cpp | |
parent | b3ddadd9b15088afecf1f9774d2004258b164258 (diff) | |
download | qpid-python-cb65298edd497295d215220397f8fedff7b14aca.tar.gz |
Removed unused types: RequestId, ResponseId, MethodContext.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@565821 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp')
30 files changed, 102 insertions, 309 deletions
diff --git a/cpp/gentools/src/org/apache/qpid/gentools/AmqpMethod.java b/cpp/gentools/src/org/apache/qpid/gentools/AmqpMethod.java index 66c19532c6..f00bb5fef8 100644 --- a/cpp/gentools/src/org/apache/qpid/gentools/AmqpMethod.java +++ b/cpp/gentools/src/org/apache/qpid/gentools/AmqpMethod.java @@ -35,7 +35,6 @@ public class AmqpMethod implements Printable, NodeAware, VersionConsistencyCheck public AmqpOrdinalVersionMap indexMap; public AmqpFlagMap clientMethodFlagMap; // Method called on client (<chassis name="server"> in XML) public AmqpFlagMap serverMethodFlagMap; // Method called on server (<chassis name="client"> in XML) - public AmqpFlagMap isResponseFlagMap; public boolean content; public AmqpMethod(String name, LanguageConverter converter) @@ -47,14 +46,8 @@ public class AmqpMethod implements Printable, NodeAware, VersionConsistencyCheck indexMap = new AmqpOrdinalVersionMap(); clientMethodFlagMap = new AmqpFlagMap(); serverMethodFlagMap = new AmqpFlagMap(); - isResponseFlagMap = new AmqpFlagMap(); } - public boolean isResponse(AmqpVersion version) { - if (!CppGenerator.USE_RELIABLE_FRAMING) return false; - return (version == null) ? isResponseFlagMap.isSet() : isResponseFlagMap.isSet(version); - } - /** Check if this method is named as a response by any other method in the class. */ public void checkForResponse(Element methodElement, AmqpVersion version) { Element clazz = (Element)methodElement.getParentNode(); @@ -66,7 +59,6 @@ public class AmqpMethod implements Printable, NodeAware, VersionConsistencyCheck for (int j =0; j<responses.getLength(); ++j) { Element response = (Element)responses.item(j); if (methodName.equals(response.getAttribute("name"))) { - isResponseFlagMap.setFlagForVersion(true, version); } } } @@ -139,7 +131,6 @@ public class AmqpMethod implements Printable, NodeAware, VersionConsistencyCheck { clientMethodFlagMap.removeVersion(version); serverMethodFlagMap.removeVersion(version); - isResponseFlagMap.removeVersion(version); indexMap.removeVersion(version); fieldMap.removeVersion(version); versionSet.remove(version); diff --git a/cpp/gentools/src/org/apache/qpid/gentools/CppGenerator.java b/cpp/gentools/src/org/apache/qpid/gentools/CppGenerator.java index 4fbda4e0fb..80ce266f39 100644 --- a/cpp/gentools/src/org/apache/qpid/gentools/CppGenerator.java +++ b/cpp/gentools/src/org/apache/qpid/gentools/CppGenerator.java @@ -29,8 +29,6 @@ import java.util.TreeMap; public class CppGenerator extends Generator { - protected static final boolean USE_RELIABLE_FRAMING = false; - protected static final String versionNamespaceStartToken = "${version_namespace_start}"; protected static final String versionNamespaceEndToken = "${version_namespace_end}"; @@ -379,9 +377,7 @@ public class CppGenerator extends Generator } private String baseClass(AmqpMethod method, AmqpVersion version) { - if (!USE_RELIABLE_FRAMING) return "AMQMethodBody"; - String base = method.isResponse(version) ? "AMQResponseBody":"AMQRequestBody"; - return base; + return "AMQMethodBody"; } @Override @@ -769,7 +765,7 @@ public class CppGenerator extends Generator for (String thisMethodName : thisClass.methodMap.keySet()) { AmqpMethod method = thisClass.methodMap.get(thisMethodName); - String returnType = (abstractMethodFlag || method.isResponse(null))? "void" : "RequestId"; + String returnType = "void"; boolean clientChassisFlag = method.clientMethodFlagMap.isSet(); boolean serverChassisFlag = method.serverMethodFlagMap.isSet(); if ((serverFlag && serverChassisFlag) || (!serverFlag && clientChassisFlag)) @@ -784,7 +780,7 @@ public class CppGenerator extends Generator sb.append(indent + "virtual "+returnType+" "+ methodName + "("); if (abstractMethodFlag && isSpecialCase(thisClass.name, method.name)) { - sb.append("const MethodContext& context"); + sb.append("const AMQMethodBody& context"); } else { sb.append(generateMethodParameterList(thisFieldMap, indentSize + (5*tabSize), false, true, true)); } @@ -906,7 +902,6 @@ public class CppGenerator extends Generator sb.append(indent + "{" + cr); sb.append(indent + "private:" + cr); sb.append(indent + tab + "ChannelAdapter& channel;" + cr); - sb.append(indent + tab + "RequestId responseTo;" + cr); sb.append(cr); sb.append(indent + "public:" + cr); sb.append(indent + tab + "// Constructors and destructors" + cr); @@ -917,7 +912,6 @@ public class CppGenerator extends Generator sb.append(cr); sb.append(indent + tab + "static "+className+"& get(" + proxyOuterClassName(serverFlag)+"& proxy) { return proxy.get"+className+"();}\n\n"); sb.append(indent + tab + "// set for response correlation" + cr); - sb.append(indent + tab + "void setResponseTo(RequestId r) { responseTo = r; }" + cr); sb.append(cr); sb.append(indent + tab + "// Protocol methods" + cr); sb.append(cr); @@ -1021,16 +1015,10 @@ public class CppGenerator extends Generator AmqpVersionSet versionSet = overloadededParameterMap.get(thisFieldMap); if (!first) sb.append(cr); - String returnType = method.isResponse(null) ? "void" : "RequestId"; + String returnType = "void"; sb.append(indent + returnType + " " + outerclassName + "::" + thisClass.name + "::" + methodName + "("); sb.append(generateMethodParameterList(thisFieldMap, indentSize + (5*tabSize), false, true, true)); - if (method.isResponse(null)) { - /* - if (!thisFieldMap.isEmpty()) sb.append(", "); - sb.append("RequestId responseTo"); - */ - } sb.append(")"); if (versionSet.size() != globalVersionSet.size()) sb.append(" // AMQP Version(s) " + versionSet); @@ -1094,9 +1082,8 @@ public class CppGenerator extends Generator String tab = Utils.createSpaces(tabSize); String namespace = version != null ? version.namespace() + "::" : ""; StringBuffer sb = new StringBuffer(); - sb.append(indent+tab+(method.isResponse(version) ? "" : "return ")+"channel.send(make_shared_ptr(new "); + sb.append(indent+tab+"channel.send(make_shared_ptr(new "); sb.append(namespace + methodBodyClassName + "( channel.getVersion()"); - if (method.isResponse(version)) sb.append(", responseTo"); sb.append(generateMethodParameterList(fieldMap, indentSize + (5*tabSize), true, false, true)); sb.append(")));\n"); return sb.toString(); @@ -1454,18 +1441,11 @@ public class CppGenerator extends Generator String indent = Utils.createSpaces(indentSize); String tab = Utils.createSpaces(tabSize); StringBuffer sb = new StringBuffer(); - if (method.fieldMap.size() > 0 || method.isResponse(version)) + if (method.fieldMap.size() > 0) { sb.append(indent + thisClass.name + Utils.firstUpper(method.name) + "Body(ProtocolVersion version," + cr); - if (method.isResponse(version)) { - sb.append(indent+tab+"RequestId toRequest"); - if (method.fieldMap.size() >0) - sb.append(",\n"); - } sb.append(generateFieldList(method.fieldMap, version, true, false, 8)); sb.append(indent + tab + ") : " + baseClass(method, version) + "(version"); - if (method.isResponse(version)) - sb.append(", 0, toRequest"); sb.append(")"); if (method.fieldMap.size() > 0) sb.append(", \n" + generateFieldList(method.fieldMap, version, false, true, 8)); @@ -1491,15 +1471,14 @@ public class CppGenerator extends Generator if (bItr.next()) // This is a server operation { boolean fieldMapNotEmptyFlag = method.fieldMap.size() > 0; - sb.append(indent + "void invoke(AMQP_ServerOperations& target, const MethodContext&" - + (special ? " context)" : " )") + cr); + sb.append(indent + "void invoke(AMQP_ServerOperations& target)\n"); sb.append(indent + "{" + cr); sb.append(indent + tab + "target.get" + thisClass.name + "Handler()->" + parseForReservedWords(Utils.firstLower(method.name), thisClass.name + Utils.firstUpper(method.name) + "Body.invoke()") + "("); if (special) { - sb.append("context"); + sb.append("*this"); } else if (fieldMapNotEmptyFlag) { diff --git a/cpp/gentools/templ.cpp/AMQP_ClientOperations.h.tmpl b/cpp/gentools/templ.cpp/AMQP_ClientOperations.h.tmpl index 137d66e90c..a61b2b762d 100644 --- a/cpp/gentools/templ.cpp/AMQP_ClientOperations.h.tmpl +++ b/cpp/gentools/templ.cpp/AMQP_ClientOperations.h.tmpl @@ -36,7 +36,7 @@ namespace qpid { namespace framing { -class MethodContext; +class AMQMethodBody; class AMQP_ClientOperations { diff --git a/cpp/gentools/templ.cpp/AMQP_ServerOperations.h.tmpl b/cpp/gentools/templ.cpp/AMQP_ServerOperations.h.tmpl index 06ef88c84e..09611c8d31 100644 --- a/cpp/gentools/templ.cpp/AMQP_ServerOperations.h.tmpl +++ b/cpp/gentools/templ.cpp/AMQP_ServerOperations.h.tmpl @@ -34,7 +34,7 @@ namespace qpid { namespace framing { -class MethodContext; +class AMQMethodBody; class Invocable { diff --git a/cpp/rubygen/amqpgen.rb b/cpp/rubygen/amqpgen.rb index edfbce2576..a144825f08 100755 --- a/cpp/rubygen/amqpgen.rb +++ b/cpp/rubygen/amqpgen.rb @@ -188,6 +188,7 @@ class Generator @outdir=outdir @prefix='' # For indentation or comments. @indentstr=' ' # One indent level. + @outdent=2 raise "Invalid output directory: #{outdir}" unless @outdir=="-" or File.directory?(@outdir) end @@ -229,6 +230,14 @@ class Generator # Generate indented code def indent(n=1,&block) prefix(@indentstr * n,&block); end + # Generate outdented code + def outdent(&block) + save=@prefix + @prefix=@prefix[0...-2] + yield + @prefix=save + end + attr_accessor :out end diff --git a/cpp/rubygen/cppgen.rb b/cpp/rubygen/cppgen.rb index 64987e763f..724634e514 100755 --- a/cpp/rubygen/cppgen.rb +++ b/cpp/rubygen/cppgen.rb @@ -172,6 +172,9 @@ class CppGen < Generator def variantl(types) "boost::variant<#{types.join(", \n")}>"; end def blank_variant(types) variant(["boost::blank"]+types); end def tuple(types) "boost::tuple<#{types.join(', ')}>"; end - + + def public() outdent { genl "public:" } end + def private() outdent { genl "private:" } end + def protected() outdent { genl "protected:" } end end diff --git a/cpp/rubygen/templates/Proxy.rb b/cpp/rubygen/templates/Proxy.rb index 40eaa2baa3..f36d6bcd99 100755 --- a/cpp/rubygen/templates/Proxy.rb +++ b/cpp/rubygen/templates/Proxy.rb @@ -15,96 +15,51 @@ class ProxyGen < CppGen def inner_class_decl(c) cname=c.name.caps - gen <<EOS - // ==================== class #{cname} ==================== - class #{cname} - { - private: - ChannelAdapter& channel; - RequestId responseTo; + cpp_class(cname) { + gen <<EOS +ChannelAdapter& channel; - public: - // Constructors and destructors +public: +#{cname}(ChannelAdapter& ch) : channel(ch) {} +virtual ~#{cname}() {} - #{cname}(ChannelAdapter& ch) : - channel(ch) {} - virtual ~#{cname}() {} +static #{cname}& get(#{@classname}& proxy) { return proxy.get#{cname}(); } - static #{cname}& get(#{@classname}& proxy) { return proxy.get#{cname}();} - // set for response correlation - void setResponseTo(RequestId r) { responseTo = r; } - - // Protocol methods EOS - indent(2) { c.amqp_methods_on(@chassis).each { |m| inner_method_decl(m) } } - gen "\n }; // class #{cname}\n\n" - end - - def inner_method_decl(m) - genl "virtual RequestId #{m.cppname}(#{m.signature.join(",\n ")});" - genl + c.amqp_methods_on(@chassis).each { |m| + genl "virtual void #{m.cppname}(#{m.signature.join(",\n ")});" + genl + }} end def inner_class_defn(c) cname=c.cppname - gen "// ==================== class #{cname} ====================\n" - c.amqp_methods_on(@chassis).each { |m| inner_method_defn(m, cname) } - end - - def inner_method_defn(m,cname) - genl "RequestId #{@classname}::#{cname}::#{m.cppname}(#{m.signature.join(", ")})" - scope { - params=(["channel.getVersion()"]+m.param_names).join(", ") - genl "return channel.send(make_shared_ptr(new #{m.body_name}(#{params})));" - } - end - - def get_decl(c) - cname=c.name.caps - gen " #{cname}& get#{cname}();\n" - end - - def get_defn(c) - cname=c.name.caps - gen <<EOS -#{@classname}::#{c.name.caps}& #{@classname}::get#{c.name.caps}() -{ - return #{proxy_member(c)}; -} -EOS + c.amqp_methods_on(@chassis).each { |m| + genl "void #{@classname}::#{cname}::#{m.cppname}(#{m.signature.join(", ")})" + scope { + params=(["channel.getVersion()"]+m.param_names).join(", ") + genl "channel.send(make_shared_ptr(new #{m.body_name}(#{params})));" + }} end def generate # .h file h_file(@filename) { - gen <<EOS -#include "qpid/framing/Proxy.h" - -namespace qpid { -namespace framing { - -class #{@classname} : public Proxy -{ -public: - #{@classname}(ChannelAdapter& ch); - - // Inner class definitions -EOS - @amqp.amqp_classes.each{ |c| inner_class_decl(c) } - gen " // Inner class instance get methods\n" - @amqp.amqp_classes.each{ |c| get_decl(c) } - gen <<EOS - private: - // Inner class instances -EOS - indent { @amqp.amqp_classes.each{ |c| gen c.cppname+" "+proxy_member(c)+";\n" } } - gen <<EOS -}; /* class #{@classname} */ - -} /* namespace framing */ -} /* namespace qpid */ -EOS - } + include "qpid/framing/Proxy.h" + namespace("qpid::framing") { + cpp_class(@classname, "public Proxy") { + public + genl "#{@classname}(ChannelAdapter& ch);" + genl + @amqp.amqp_classes.each { |c| + inner_class_decl(c) + genl + genl "#{c.cppname}& get#{c.cppname}() { return #{proxy_member(c)}; }" + genl + } + private + @amqp.amqp_classes.each{ |c| gen c.cppname+" "+proxy_member(c)+";\n" } + }}} # .cpp file cpp_file(@filename) { @@ -112,30 +67,19 @@ EOS include "#{@classname}.h" include "qpid/framing/ChannelAdapter.h" include "qpid/framing/amqp_types_full.h" - @amqp.amqp_methods_on(@chassis).each { - |m| include "qpid/framing/#{m.body_name}.h" } - gen <<EOS -namespace qpid { -namespace framing { - -#{@classname}::#{@classname}(ChannelAdapter& ch) : -EOS - gen " Proxy(ch)" - @amqp.amqp_classes.each { |c| gen ",\n "+proxy_member(c)+"(channel)" } - gen <<EOS - {} - - // Inner class instance get methods -EOS - @amqp.amqp_classes.each { |c| get_defn(c) } - gen " // Inner class implementation\n\n" - @amqp.amqp_classes.each { |c| inner_class_defn(c) } - genl "}} // namespae qpid::framing" - } + Amqp.amqp_methods_on(@chassis).each { |m| include "qpid/framing/"+m.body_name } + genl + namespace("qpid::framing") { + genl "#{@classname}::#{@classname}(ChannelAdapter& ch) :" + gen " Proxy(ch)" + @amqp.amqp_classes.each { |c| gen ",\n "+proxy_member(c)+"(channel)" } + genl "{}\n" + @amqp.amqp_classes.each { |c| inner_class_defn(c) } + }} end end -ProxyGen.new("client", ARGV[0], Amqp).generate; -ProxyGen.new("server", ARGV[0], Amqp).generate; +ProxyGen.new("client", Outdir, Amqp).generate; +ProxyGen.new("server", Outdir, Amqp).generate; diff --git a/cpp/src/Makefile.am b/cpp/src/Makefile.am index 690f939e71..23a9e2a2fa 100644 --- a/cpp/src/Makefile.am +++ b/cpp/src/Makefile.am @@ -369,8 +369,6 @@ nobase_include_HEADERS = \ qpid/framing/HeaderProperties.h \ qpid/framing/InitiationHandler.h \ qpid/framing/InputHandler.h \ - qpid/framing/MethodContent.h \ - qpid/framing/MethodContext.h \ qpid/framing/OutputHandler.h \ qpid/framing/ProtocolInitiation.h \ qpid/framing/ProtocolVersion.h \ diff --git a/cpp/src/qpid/broker/BrokerAdapter.cpp b/cpp/src/qpid/broker/BrokerAdapter.cpp index 26c2b30ac6..77030855ff 100644 --- a/cpp/src/qpid/broker/BrokerAdapter.cpp +++ b/cpp/src/qpid/broker/BrokerAdapter.cpp @@ -400,18 +400,5 @@ void BrokerAdapter::ChannelHandlerImpl::ok() //no specific action required, generic response handling should be sufficient } -void BrokerAdapter::setResponseTo(RequestId r) -{ - basicHandler.client.setResponseTo(r); - channelHandler.client.setResponseTo(r); - exchangeHandler.client.setResponseTo(r); - bindingHandler.client.setResponseTo(r); - messageHandler.client.setResponseTo(r); - queueHandler.client.setResponseTo(r); - txHandler.client.setResponseTo(r); - dtxHandler.setResponseTo(r); -} - - }} // namespace qpid::broker diff --git a/cpp/src/qpid/broker/BrokerAdapter.h b/cpp/src/qpid/broker/BrokerAdapter.h index 4ae8346580..3fe2eb9eba 100644 --- a/cpp/src/qpid/broker/BrokerAdapter.h +++ b/cpp/src/qpid/broker/BrokerAdapter.h @@ -85,7 +85,6 @@ class BrokerAdapter : public CoreRefs, public framing::AMQP_ServerOperations } framing::AMQP_ClientProxy& getProxy() { return proxy; } - void setResponseTo(framing::RequestId r); private: diff --git a/cpp/src/qpid/broker/BrokerMessage.h b/cpp/src/qpid/broker/BrokerMessage.h index 3f22f07aec..af8e4e62e9 100644 --- a/cpp/src/qpid/broker/BrokerMessage.h +++ b/cpp/src/qpid/broker/BrokerMessage.h @@ -35,7 +35,6 @@ namespace qpid { namespace framing { -class MethodContext; class ChannelAdapter; class AMQHeaderBody; } diff --git a/cpp/src/qpid/broker/BrokerMessageBase.h b/cpp/src/qpid/broker/BrokerMessageBase.h index aeb34880eb..94035905ce 100644 --- a/cpp/src/qpid/broker/BrokerMessageBase.h +++ b/cpp/src/qpid/broker/BrokerMessageBase.h @@ -33,7 +33,6 @@ namespace qpid { namespace framing { -class MethodContext; class ChannelAdapter; class BasicHeaderProperties; class FieldTable; diff --git a/cpp/src/qpid/broker/BrokerMessageMessage.cpp b/cpp/src/qpid/broker/BrokerMessageMessage.cpp index 9ad27093bb..0da5f3d8f5 100644 --- a/cpp/src/qpid/broker/BrokerMessageMessage.cpp +++ b/cpp/src/qpid/broker/BrokerMessageMessage.cpp @@ -48,27 +48,24 @@ struct MessageDeliveryToken : public DeliveryToken }; MessageMessage::MessageMessage( - ConnectionToken* publisher, RequestId requestId_, TransferPtr transfer_ + ConnectionToken* publisher, TransferPtr transfer_ ) : Message(publisher, transfer_->getDestination(), transfer_->getRoutingKey(), transfer_->getRejectUnroutable(), transfer_->getImmediate(), transfer_), - requestId(requestId_), transfer(transfer_) { assert(transfer->getBody().isInline()); } MessageMessage::MessageMessage( - ConnectionToken* publisher, RequestId requestId_, TransferPtr transfer_, - ReferencePtr reference_ + ConnectionToken* publisher, TransferPtr transfer_, ReferencePtr reference_ ) : Message(publisher, transfer_->getDestination(), transfer_->getRoutingKey(), transfer_->getRejectUnroutable(), transfer_->getImmediate(), transfer_), - requestId(requestId_), transfer(transfer_), reference(reference_) { @@ -178,7 +175,7 @@ void MessageMessage::transferMessage( ReferencePtr newRef(new Reference(refname)); Reference::AppendPtr newAppend(new MessageAppendBody(channel.getVersion(), refname, content)); newRef->append(newAppend); - MessageMessage newMsg(const_cast<ConnectionToken*>(getPublisher()), 0, newTransfer, newRef); + MessageMessage newMsg(const_cast<ConnectionToken*>(getPublisher()), newTransfer, newRef); newMsg.transferMessage(channel, consumerTag, framesize); return; } diff --git a/cpp/src/qpid/broker/BrokerMessageMessage.h b/cpp/src/qpid/broker/BrokerMessageMessage.h index 4efd22c9fe..6b1bd9ab5d 100644 --- a/cpp/src/qpid/broker/BrokerMessageMessage.h +++ b/cpp/src/qpid/broker/BrokerMessageMessage.h @@ -43,13 +43,12 @@ class MessageMessage: public Message{ typedef boost::shared_ptr<framing::MessageTransferBody> TransferPtr; typedef boost::shared_ptr<Reference> ReferencePtr; - MessageMessage(ConnectionToken* publisher, framing::RequestId, TransferPtr transfer); - MessageMessage(ConnectionToken* publisher, framing::RequestId, TransferPtr transfer, ReferencePtr reference); + MessageMessage(ConnectionToken* publisher, TransferPtr transfer); + MessageMessage(ConnectionToken* publisher, TransferPtr transfer, ReferencePtr reference); MessageMessage(); // Default destructor okay - framing::RequestId getRequestId() const {return requestId; } TransferPtr getTransfer() const { return transfer; } ReferencePtr getReference() const ; @@ -86,7 +85,6 @@ class MessageMessage: public Message{ const std::string& destination, const framing::Content& body) const; - framing::RequestId requestId; const TransferPtr transfer; const boost::shared_ptr<Reference> reference; }; diff --git a/cpp/src/qpid/broker/ConnectionAdapter.cpp b/cpp/src/qpid/broker/ConnectionAdapter.cpp index 4fa4b2c238..a67a5557c6 100644 --- a/cpp/src/qpid/broker/ConnectionAdapter.cpp +++ b/cpp/src/qpid/broker/ConnectionAdapter.cpp @@ -21,14 +21,12 @@ #include "ConnectionAdapter.h" #include "Connection.h" -#include "qpid/framing/MethodContext.h" using namespace qpid; using namespace qpid::broker; using qpid::framing::ReplyCode; using qpid::framing::ClassId; using qpid::framing::MethodId; -using qpid::framing::MethodContext; using qpid::framing::FieldTable; void ConnectionAdapter::init(const framing::ProtocolInitiation& header) { @@ -44,13 +42,11 @@ void ConnectionAdapter::close(ReplyCode code, const string& text, ClassId classI handler->client.close(code, text, classId, methodId); } -void ConnectionAdapter::handleMethodInContext( - boost::shared_ptr<qpid::framing::AMQMethodBody> method, - const MethodContext& context -) +void ConnectionAdapter::handleMethod( + boost::shared_ptr<qpid::framing::AMQMethodBody> method) { try{ - method->invoke(*this, context); + method->invoke(*this); }catch(ConnectionException& e){ handler->client.close(e.code, e.toString(), method->amqpClassId(), method->amqpMethodId()); }catch(std::exception& e){ diff --git a/cpp/src/qpid/broker/ConnectionAdapter.h b/cpp/src/qpid/broker/ConnectionAdapter.h index 6890b014a4..1ce850a659 100644 --- a/cpp/src/qpid/broker/ConnectionAdapter.h +++ b/cpp/src/qpid/broker/ConnectionAdapter.h @@ -47,8 +47,7 @@ public: void handle(framing::AMQFrame& frame); //ChannelAdapter virtual methods: - void handleMethodInContext(boost::shared_ptr<qpid::framing::AMQMethodBody> method, - const qpid::framing::MethodContext& context); + void handleMethod(boost::shared_ptr<qpid::framing::AMQMethodBody> method); bool isOpen() const { return true; } //channel 0 is always open //never needed: void handleHeader(boost::shared_ptr<qpid::framing::AMQHeaderBody>) {} diff --git a/cpp/src/qpid/broker/DtxHandlerImpl.cpp b/cpp/src/qpid/broker/DtxHandlerImpl.cpp index 72d3888e37..8b3629dff9 100644 --- a/cpp/src/qpid/broker/DtxHandlerImpl.cpp +++ b/cpp/src/qpid/broker/DtxHandlerImpl.cpp @@ -25,7 +25,6 @@ using namespace qpid::broker; using qpid::framing::AMQP_ClientProxy; using qpid::framing::Buffer; using qpid::framing::FieldTable; -using qpid::framing::MethodContext; using std::string; DtxHandlerImpl::DtxHandlerImpl(CoreRefs& parent) : @@ -194,9 +193,4 @@ void DtxHandlerImpl::setTimeout(u_int16_t /*ticket*/, broker.getDtxManager().setTimeout(xid, timeout); } -void DtxHandlerImpl::setResponseTo(framing::RequestId r) -{ - dClient.setResponseTo(r); - cClient.setResponseTo(r); -} diff --git a/cpp/src/qpid/broker/DtxHandlerImpl.h b/cpp/src/qpid/broker/DtxHandlerImpl.h index 6139b95bd6..067ba47fb5 100644 --- a/cpp/src/qpid/broker/DtxHandlerImpl.h +++ b/cpp/src/qpid/broker/DtxHandlerImpl.h @@ -36,8 +36,6 @@ class DtxHandlerImpl public: DtxHandlerImpl(CoreRefs& parent); - void setResponseTo(framing::RequestId r); - // DtxCoordinationHandler: void commit(u_int16_t ticket, const std::string& xid, bool onePhase); diff --git a/cpp/src/qpid/broker/MessageHandlerImpl.cpp b/cpp/src/qpid/broker/MessageHandlerImpl.cpp index 70f7c3b8ec..b5bea05eac 100644 --- a/cpp/src/qpid/broker/MessageHandlerImpl.cpp +++ b/cpp/src/qpid/broker/MessageHandlerImpl.cpp @@ -54,7 +54,7 @@ MessageHandlerImpl::open(const string& /*reference*/) } void -MessageHandlerImpl::append(const framing::MethodContext& /*context*/) +MessageHandlerImpl::append(const framing::AMQMethodBody& ) { throw ConnectionException(540, "References no longer supported"); } @@ -157,14 +157,13 @@ MessageHandlerImpl::reject(uint16_t /*code*/, const string& /*text*/ ) } void -MessageHandlerImpl::transfer(const framing::MethodContext& context) +MessageHandlerImpl::transfer(const framing::AMQMethodBody& context) { MessageTransferBody::shared_ptr transfer( - boost::shared_polymorphic_downcast<MessageTransferBody>( - context.methodBody)); + make_shared_ptr(new MessageTransferBody(static_cast<const MessageTransferBody&>(context)))); if (transfer->getBody().isInline()) { - MessageMessage::shared_ptr message(new MessageMessage(&connection, 0, transfer)); + MessageMessage::shared_ptr message(new MessageMessage(&connection, transfer)); channel.handleInlineTransfer(message); } else { throw ConnectionException(540, "References no longer supported"); diff --git a/cpp/src/qpid/broker/MessageHandlerImpl.h b/cpp/src/qpid/broker/MessageHandlerImpl.h index b7e91795ec..20cae46da4 100644 --- a/cpp/src/qpid/broker/MessageHandlerImpl.h +++ b/cpp/src/qpid/broker/MessageHandlerImpl.h @@ -40,7 +40,7 @@ class MessageHandlerImpl : public: MessageHandlerImpl(CoreRefs& parent); - void append(const framing::MethodContext& context); + void append(const framing::AMQMethodBody& context); void cancel(const std::string& destination ); @@ -82,7 +82,7 @@ class MessageHandlerImpl : void resume(const std::string& reference, const std::string& identifier ); - void transfer(const framing::MethodContext& context); + void transfer(const framing::AMQMethodBody& context); void flow(const std::string& destination, u_int8_t unit, u_int32_t value); diff --git a/cpp/src/qpid/broker/SemanticHandler.cpp b/cpp/src/qpid/broker/SemanticHandler.cpp index fd0a5cfbe1..6ef2162a4a 100644 --- a/cpp/src/qpid/broker/SemanticHandler.cpp +++ b/cpp/src/qpid/broker/SemanticHandler.cpp @@ -60,13 +60,12 @@ void SemanticHandler::handle(framing::AMQFrame& frame) } //ChannelAdapter virtual methods: -void SemanticHandler::handleMethodInContext(boost::shared_ptr<qpid::framing::AMQMethodBody> method, - const qpid::framing::MethodContext& context) +void SemanticHandler::handleMethod(boost::shared_ptr<qpid::framing::AMQMethodBody> method) { try { if (!method->invoke(this)) { //else do the usual: - handleL4(method, context); + handleL4(method); //(if the frameset is complete) we can move the execution-mark //forward @@ -113,8 +112,7 @@ void SemanticHandler::flush() } } -void SemanticHandler::handleL4(boost::shared_ptr<qpid::framing::AMQMethodBody> method, - const qpid::framing::MethodContext& context) +void SemanticHandler::handleL4(boost::shared_ptr<qpid::framing::AMQMethodBody> method) { try{ if(getId() != 0 && !method->isA<ChannelOpenBody>() && !isOpen()) { @@ -124,7 +122,7 @@ void SemanticHandler::handleL4(boost::shared_ptr<qpid::framing::AMQMethodBody> m throw ConnectionException(504, out.str()); } } else { - method->invoke(*adapter, context); + method->invoke(*adapter); } }catch(const ChannelException& e){ adapter->getProxy().getChannel().close( @@ -171,7 +169,7 @@ void SemanticHandler::redeliver(Message::shared_ptr& msg, DeliveryToken::shared_ msg->deliver(*this, tag, token, connection.getFrameMax()); } -RequestId SemanticHandler::send(shared_ptr<AMQBody> body) +void SemanticHandler::send(shared_ptr<AMQBody> body) { Mutex::ScopedLock l(outLock); uint8_t type(body->type()); @@ -182,5 +180,5 @@ RequestId SemanticHandler::send(shared_ptr<AMQBody> body) //std::cout << "[" << this << "] allocated: " << outgoing.hwm.getValue() << " to " << *body << std::endl; } } - return ChannelAdapter::send(body); + ChannelAdapter::send(body); } diff --git a/cpp/src/qpid/broker/SemanticHandler.h b/cpp/src/qpid/broker/SemanticHandler.h index 7d5d95243e..016c94738d 100644 --- a/cpp/src/qpid/broker/SemanticHandler.h +++ b/cpp/src/qpid/broker/SemanticHandler.h @@ -48,18 +48,16 @@ class SemanticHandler : private framing::ChannelAdapter, framing::Window outgoing; sys::Mutex outLock; - void handleL4(boost::shared_ptr<qpid::framing::AMQMethodBody> method, - const qpid::framing::MethodContext& context); + void handleL4(boost::shared_ptr<qpid::framing::AMQMethodBody> method); //ChannelAdapter virtual methods: - void handleMethodInContext(boost::shared_ptr<qpid::framing::AMQMethodBody> method, - const qpid::framing::MethodContext& context); + void handleMethod(boost::shared_ptr<qpid::framing::AMQMethodBody> method); bool isOpen() const; void handleHeader(boost::shared_ptr<qpid::framing::AMQHeaderBody>); void handleContent(boost::shared_ptr<qpid::framing::AMQContentBody>); void handleHeartbeat(boost::shared_ptr<qpid::framing::AMQHeartbeatBody>); - framing::RequestId send(shared_ptr<framing::AMQBody> body); + void send(shared_ptr<framing::AMQBody> body); //delivery adapter methods: diff --git a/cpp/src/qpid/cluster/SessionManager.cpp b/cpp/src/qpid/cluster/SessionManager.cpp index 715ed7817c..a4efa939fc 100644 --- a/cpp/src/qpid/cluster/SessionManager.cpp +++ b/cpp/src/qpid/cluster/SessionManager.cpp @@ -57,7 +57,7 @@ using namespace broker; void handle(AMQFrame& frame) { AMQMethodBody* body=dynamic_cast<AMQMethodBody*>(frame.body.get()); assert(body); - body->invoke(adapter, MethodContext()); // TODO aconway 2007-07-24: Remove MethodContext + body->invoke(adapter); } // Dummy methods. @@ -65,9 +65,9 @@ using namespace broker; virtual void handleContent(boost::shared_ptr<AMQContentBody>){} virtual void handleHeartbeat(boost::shared_ptr<AMQHeartbeatBody>){} virtual bool isOpen() const{ return true; } - virtual void handleMethodInContext(shared_ptr<AMQMethodBody>, const MethodContext&){} + virtual void handleMethod(shared_ptr<AMQMethodBody>){} // No-op send. - virtual RequestId send(shared_ptr<AMQBody>) { return 0; } + virtual void send(shared_ptr<AMQBody>) {} //delivery adapter methods, also no-ops: virtual DeliveryId deliver(Message::shared_ptr&, DeliveryToken::shared_ptr) { return 0; } diff --git a/cpp/src/qpid/framing/AMQMethodBody.cpp b/cpp/src/qpid/framing/AMQMethodBody.cpp index eb34d48c5f..0a2720e69a 100644 --- a/cpp/src/qpid/framing/AMQMethodBody.cpp +++ b/cpp/src/qpid/framing/AMQMethodBody.cpp @@ -31,7 +31,7 @@ void AMQMethodBody::encodeId(Buffer& buffer) const{ buffer.putShort(amqpMethodId()); } -void AMQMethodBody::invoke(AMQP_ServerOperations&, const MethodContext&){ +void AMQMethodBody::invoke(AMQP_ServerOperations&){ assert(0); THROW_QPID_ERROR(PROTOCOL_ERROR, "Method not supported by AMQP Server."); } diff --git a/cpp/src/qpid/framing/AMQMethodBody.h b/cpp/src/qpid/framing/AMQMethodBody.h index cbfd438b48..73c5eb78a6 100644 --- a/cpp/src/qpid/framing/AMQMethodBody.h +++ b/cpp/src/qpid/framing/AMQMethodBody.h @@ -26,7 +26,6 @@ #include "AMQBody.h" #include "Buffer.h" #include "qpid/framing/AMQP_ServerOperations.h" -#include "MethodContext.h" namespace qpid { namespace framing { @@ -52,7 +51,7 @@ class AMQMethodBody : public AMQBody virtual MethodId amqpMethodId() const = 0; virtual ClassId amqpClassId() const = 0; - virtual void invoke(AMQP_ServerOperations&, const MethodContext&); + virtual void invoke(AMQP_ServerOperations&); virtual bool invoke(Invocable* target); template <class T> bool isA() { diff --git a/cpp/src/qpid/framing/ChannelAdapter.cpp b/cpp/src/qpid/framing/ChannelAdapter.cpp index b3b442004a..d61126bc7f 100644 --- a/cpp/src/qpid/framing/ChannelAdapter.cpp +++ b/cpp/src/qpid/framing/ChannelAdapter.cpp @@ -18,6 +18,7 @@ #include <boost/format.hpp> #include "ChannelAdapter.h" +#include "OutputHandler.h" #include "AMQFrame.h" #include "FrameHandler.h" #include "qpid/Exception.h" @@ -44,18 +45,11 @@ void ChannelAdapter::init(ChannelId i, OutputHandler& out, ProtocolVersion v) handlers.out= make_shared_ptr(new OutputHandlerFrameHandler(out)); } -RequestId ChannelAdapter::send(shared_ptr<AMQBody> body) +void ChannelAdapter::send(shared_ptr<AMQBody> body) { - RequestId requestId = 0; assertChannelOpen(); AMQFrame frame(getVersion(), getId(), body); handlers.out->handle(frame); - return requestId; -} - -void ChannelAdapter::handleMethod(AMQMethodBody::shared_ptr method) { - assertMethodOk(*method); - handleMethodInContext(method, MethodContext(this, method)); } void ChannelAdapter::assertMethodOk(AMQMethodBody& method) const { diff --git a/cpp/src/qpid/framing/ChannelAdapter.h b/cpp/src/qpid/framing/ChannelAdapter.h index 84a626c864..9e418013eb 100644 --- a/cpp/src/qpid/framing/ChannelAdapter.h +++ b/cpp/src/qpid/framing/ChannelAdapter.h @@ -34,7 +34,6 @@ namespace qpid { namespace framing { -class MethodContext; class OutputHandler; /** @@ -67,12 +66,7 @@ class ChannelAdapter : protected BodyHandler { ChannelId getId() const { return id; } ProtocolVersion getVersion() const { return version; } - /** - * Send a frame. - *@param body Body of the frame. - *@return If body is a request, the ID assigned else 0. - */ - virtual RequestId send(shared_ptr<AMQBody> body); + virtual void send(shared_ptr<AMQBody> body); virtual bool isOpen() const = 0; @@ -81,16 +75,12 @@ class ChannelAdapter : protected BodyHandler { void assertChannelOpen() const; void assertChannelNotOpen() const; - virtual void handleMethodInContext( - shared_ptr<AMQMethodBody> method, - const MethodContext& context) = 0; + virtual void handleMethod(shared_ptr<AMQMethodBody>) = 0; private: class ChannelAdapterHandler; friend class ChannelAdapterHandler; - void handleMethod(shared_ptr<AMQMethodBody>); - ChannelId id; ProtocolVersion version; FrameHandler::Chains handlers; diff --git a/cpp/src/qpid/framing/MethodContext.h b/cpp/src/qpid/framing/MethodContext.h deleted file mode 100644 index 102dc279d4..0000000000 --- a/cpp/src/qpid/framing/MethodContext.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef _framing_MethodContext_h -#define _framing_MethodContext_h - -/* - * - * Copyright (c) 2006 The Apache Software Foundation - * - * Licensed 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. - * - */ - -#include <boost/shared_ptr.hpp> - -#include "OutputHandler.h" -#include "ProtocolVersion.h" - -namespace qpid { -namespace framing { - -class BodyHandler; -class AMQMethodBody; -class ChannelAdapter; - -/** - * Invocation context for an AMQP method. - * - * It provides the method being processed and the channel on which - * it arrived. - * - * All Handler functions take a MethodContext as the last parameter. - */ -struct MethodContext -{ - typedef boost::shared_ptr<AMQMethodBody> BodyPtr; - - MethodContext(ChannelAdapter* ch=0, BodyPtr method=BodyPtr()) - : channel(ch), methodBody(method) {} - - /** - * Channel on which the method being processed arrived. - * 0 if the method was constructed by the caller - * rather than received from a channel. - */ - ChannelAdapter* channel; - - /** - * Body of the method being processed. - * It's useful for passing around instead of unpacking all its parameters. - * It's also provides the request ID when constructing a response. - */ - BodyPtr methodBody; -}; - - -}} // namespace qpid::framing - - - -#endif /*!_framing_MethodContext_h*/ diff --git a/cpp/src/tests/MockChannel.h b/cpp/src/tests/MockChannel.h index 908a222614..fb2de98d2a 100644 --- a/cpp/src/tests/MockChannel.h +++ b/cpp/src/tests/MockChannel.h @@ -19,7 +19,6 @@ * */ -#include "qpid/framing/MethodContext.h" #include "qpid/framing/ChannelAdapter.h" #include "qpid/framing/OutputHandler.h" #include "qpid/framing/AMQFrame.h" @@ -58,12 +57,7 @@ struct MockChannel : public qpid::framing::ChannelAdapter boost::shared_ptr<qpid::framing::AMQContentBody> b) { send(b); } void handleHeartbeat( boost::shared_ptr<qpid::framing::AMQHeartbeatBody> b) { send(b); } - void handleMethodInContext( - boost::shared_ptr<qpid::framing::AMQMethodBody> method, - const qpid::framing::MethodContext& context) - { - context.channel->send(method); - }; + void handleMethod(boost::shared_ptr<qpid::framing::AMQMethodBody> method) { send(method); }; }; diff --git a/cpp/src/tests/ReferenceTest.cpp b/cpp/src/tests/ReferenceTest.cpp index e8b759264b..b3dd44bf7d 100644 --- a/cpp/src/tests/ReferenceTest.cpp +++ b/cpp/src/tests/ReferenceTest.cpp @@ -70,11 +70,11 @@ class ReferenceTest : public CppUnit::TestCase MessageTransferBody::shared_ptr t1(new MessageTransferBody(v)); // TODO aconway 2007-04-03: hack around lack of generated setters. Clean this up. const_cast<framing::Content&>(t1->getBody()) = framing::Content(REFERENCE,"bar"); - MessageMessage::shared_ptr m1(new MessageMessage(0, 1, t1, r1)); + MessageMessage::shared_ptr m1(new MessageMessage(0, t1, r1)); MessageTransferBody::shared_ptr t2(new MessageTransferBody(v)); const_cast<framing::Content&>(t2->getBody()) = framing::Content(REFERENCE,"bar"); - MessageMessage::shared_ptr m2(new MessageMessage(0, 2, t2, r1)); + MessageMessage::shared_ptr m2(new MessageMessage(0, t2, r1)); MessageAppendBody::shared_ptr a1(new MessageAppendBody(v)); MessageAppendBody::shared_ptr a2(new MessageAppendBody(v)); |