summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/broker
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2007-10-16 19:07:54 +0000
committerAlan Conway <aconway@apache.org>2007-10-16 19:07:54 +0000
commit428de9b6fe6f81f2bfc3f47d5db013b4b00da6a2 (patch)
treee3fe772cbe0e08ea84f4b2f54b969dc7471bb8e1 /cpp/src/qpid/broker
parent3bd61c1fa1a748789707b502ada85200f6180f5b (diff)
downloadqpid-python-428de9b6fe6f81f2bfc3f47d5db013b4b00da6a2.tar.gz
* Summary: generalized Invoker visitor to all *Operations and
*Handler classes, client and broker. Single template free function invoke(Invocable, const AMQBody&); works for all invocable handlers. * rubygen/templates/OperationsInvoker.rb: Generates invoker visitors for all Operations classes, client and server. * src/qpid/framing/Invoker.h: Invoker base class and template invoke() function. * rubygen/templates/structs.rb: add generic invoke method template to invoke an arbitrary object with the correct memeber function. * src/qpid/framing/AMQMethodBody.cpp, .h: Removed invoke(), replaced by qpid::framing::invoke() * src/qpid/broker/SemanticHandler.cpp, ConnectionHandler.cpp: Replace AMQMethodBody::invoke with invoke() free function. * src/qpid/framing/StructHelper.h: Avoid un-necessary alloc and copy in encode/decode. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@585223 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/broker')
-rw-r--r--cpp/src/qpid/broker/ConnectionHandler.cpp3
-rw-r--r--cpp/src/qpid/broker/SemanticHandler.cpp14
-rw-r--r--cpp/src/qpid/broker/SessionHandler.cpp7
-rw-r--r--cpp/src/qpid/broker/SessionHandler.h2
4 files changed, 13 insertions, 13 deletions
diff --git a/cpp/src/qpid/broker/ConnectionHandler.cpp b/cpp/src/qpid/broker/ConnectionHandler.cpp
index a769d05470..f697986194 100644
--- a/cpp/src/qpid/broker/ConnectionHandler.cpp
+++ b/cpp/src/qpid/broker/ConnectionHandler.cpp
@@ -23,6 +23,7 @@
#include "ConnectionHandler.h"
#include "Connection.h"
#include "qpid/framing/ConnectionStartBody.h"
+#include "qpid/framing/ServerInvoker.h"
using namespace qpid;
using namespace qpid::broker;
@@ -44,7 +45,7 @@ void ConnectionHandler::handle(framing::AMQFrame& frame)
{
AMQMethodBody* method=frame.getBody()->getMethod();
try{
- if (!method->invoke(handler.get()))
+ if (!invoke(*handler.get(), *method))
throw ConnectionException(503, "Class can't be accessed over channel 0");
}catch(ConnectionException& e){
handler->client.close(e.code, e.toString(), method->amqpClassId(), method->amqpMethodId());
diff --git a/cpp/src/qpid/broker/SemanticHandler.cpp b/cpp/src/qpid/broker/SemanticHandler.cpp
index dc5407be99..8535dc6a60 100644
--- a/cpp/src/qpid/broker/SemanticHandler.cpp
+++ b/cpp/src/qpid/broker/SemanticHandler.cpp
@@ -28,7 +28,7 @@
#include "Connection.h"
#include "qpid/framing/ExecutionCompleteBody.h"
#include "qpid/framing/ExecutionResultBody.h"
-#include "qpid/framing/InvocationVisitor.h"
+#include "qpid/framing/ServerInvoker.h"
#include <boost/format.hpp>
#include <boost/bind.hpp>
@@ -121,14 +121,13 @@ void SemanticHandler::handleCommand(framing::AMQMethodBody* method)
{
SequenceNumber id = incoming.next();
BrokerAdapter adapter(state);
- InvocationVisitor v(&adapter);
- method->accept(v);
+ Invoker::Result invoker = invoke(adapter, *method);
incoming.complete(id);
- if (!v.wasHandled()) {
+ if (!invoker.wasHandled()) {
throw ConnectionException(540, "Not implemented");
- } else if (v.hasResult()) {
- session.getProxy().getExecution().result(id.getValue(), v.getResult());
+ } else if (invoker.hasResult()) {
+ session.getProxy().getExecution().result(id.getValue(), invoker.getResult());
}
if (method->isSync()) {
incoming.sync(id);
@@ -139,9 +138,8 @@ void SemanticHandler::handleCommand(framing::AMQMethodBody* method)
void SemanticHandler::handleL3(framing::AMQMethodBody* method)
{
- if (!method->invoke(this)) {
+ if (!invoke(*this, *method))
throw ConnectionException(540, "Not implemented");
- }
}
void SemanticHandler::handleContent(AMQFrame& frame)
diff --git a/cpp/src/qpid/broker/SessionHandler.cpp b/cpp/src/qpid/broker/SessionHandler.cpp
index d7308572f9..ed092d6a05 100644
--- a/cpp/src/qpid/broker/SessionHandler.cpp
+++ b/cpp/src/qpid/broker/SessionHandler.cpp
@@ -23,6 +23,7 @@
#include "Connection.h"
#include "qpid/framing/reply_exceptions.h"
#include "qpid/framing/constants.h"
+#include "qpid/framing/ServerInvoker.h"
#include "qpid/log/Statement.h"
namespace qpid {
@@ -48,10 +49,10 @@ void SessionHandler::handleIn(AMQFrame& f) {
// state. This is a temporary state after we have sent a channel
// exception, where extra frames might arrive that should be
// ignored.
- //
- AMQMethodBody* m=f.getMethod();
+ //
+ AMQMethodBody* m = f.getBody()->getMethod();
try {
- if (m && m->invoke(this))
+ if (m && invoke(*this, *m))
return;
else if (session.get())
session->in(f);
diff --git a/cpp/src/qpid/broker/SessionHandler.h b/cpp/src/qpid/broker/SessionHandler.h
index aec3731dc0..51a65e3092 100644
--- a/cpp/src/qpid/broker/SessionHandler.h
+++ b/cpp/src/qpid/broker/SessionHandler.h
@@ -41,7 +41,7 @@ class SessionState;
* association between the channel and a session.
*/
class SessionHandler : public framing::FrameHandler::InOutHandler,
- private framing::AMQP_ServerOperations::SessionHandler,
+ public framing::AMQP_ServerOperations::SessionHandler,
private boost::noncopyable
{
public: