From 24966bd7fbaff11d8a0f1ad282180154c96a7d2f Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Mon, 17 Sep 2007 20:22:55 +0000 Subject: Renamed SessionAdapter as SessionHandler. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@576578 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/Makefile.am | 4 +- cpp/src/qpid/broker/BrokerAdapter.cpp | 2 +- cpp/src/qpid/broker/Connection.cpp | 6 +- cpp/src/qpid/broker/Connection.h | 8 +- cpp/src/qpid/broker/SemanticHandler.cpp | 4 +- cpp/src/qpid/broker/Session.cpp | 4 +- cpp/src/qpid/broker/Session.h | 10 +-- cpp/src/qpid/broker/SessionAdapter.cpp | 146 -------------------------------- cpp/src/qpid/broker/SessionAdapter.h | 94 -------------------- cpp/src/qpid/broker/SessionHandler.cpp | 146 ++++++++++++++++++++++++++++++++ cpp/src/qpid/broker/SessionHandler.h | 94 ++++++++++++++++++++ cpp/src/qpid/cluster/SessionManager.cpp | 2 +- 12 files changed, 260 insertions(+), 260 deletions(-) delete mode 100644 cpp/src/qpid/broker/SessionAdapter.cpp delete mode 100644 cpp/src/qpid/broker/SessionAdapter.h create mode 100644 cpp/src/qpid/broker/SessionHandler.cpp create mode 100644 cpp/src/qpid/broker/SessionHandler.h (limited to 'cpp/src') diff --git a/cpp/src/Makefile.am b/cpp/src/Makefile.am index d3aad9939e..49535babff 100644 --- a/cpp/src/Makefile.am +++ b/cpp/src/Makefile.am @@ -195,8 +195,8 @@ libqpidbroker_la_SOURCES = \ qpid/broker/RecoveredDequeue.cpp \ qpid/broker/Session.h \ qpid/broker/Session.cpp \ - qpid/broker/SessionAdapter.h \ - qpid/broker/SessionAdapter.cpp \ + qpid/broker/SessionHandler.h \ + qpid/broker/SessionHandler.cpp \ qpid/broker/SemanticHandler.cpp \ qpid/broker/Timer.cpp \ qpid/broker/TopicExchange.cpp \ diff --git a/cpp/src/qpid/broker/BrokerAdapter.cpp b/cpp/src/qpid/broker/BrokerAdapter.cpp index b3a8e135a3..35a87784d2 100644 --- a/cpp/src/qpid/broker/BrokerAdapter.cpp +++ b/cpp/src/qpid/broker/BrokerAdapter.cpp @@ -17,7 +17,7 @@ */ #include "BrokerAdapter.h" #include "Session.h" -#include "SessionAdapter.h" +#include "SessionHandler.h" #include "Connection.h" #include "DeliveryToken.h" #include "MessageDelivery.h" diff --git a/cpp/src/qpid/broker/Connection.cpp b/cpp/src/qpid/broker/Connection.cpp index 825ce4978c..ec6fd6ece7 100644 --- a/cpp/src/qpid/broker/Connection.cpp +++ b/cpp/src/qpid/broker/Connection.cpp @@ -52,7 +52,7 @@ void Connection::received(framing::AMQFrame& frame){ if (frame.getChannel() == 0) { adapter.handle(frame); } else { - SessionAdapter sa = getChannel(frame.getChannel()); + SessionHandler sa = getChannel(frame.getChannel()); sa.in(frame); } } @@ -94,8 +94,8 @@ void Connection::closeChannel(uint16_t id) { if (i != channels.end()) channels.erase(i); } -SessionAdapter Connection::getChannel(ChannelId id) { - boost::optional& ch = channels[id]; +SessionHandler Connection::getChannel(ChannelId id) { + boost::optional& ch = channels[id]; if (!ch) { ch = boost::in_place(boost::ref(*this), id); } diff --git a/cpp/src/qpid/broker/Connection.h b/cpp/src/qpid/broker/Connection.h index ff7fb4e327..3dd6bfbb29 100644 --- a/cpp/src/qpid/broker/Connection.h +++ b/cpp/src/qpid/broker/Connection.h @@ -38,7 +38,7 @@ #include "qpid/Exception.h" #include "Session.h" #include "ConnectionAdapter.h" -#include "SessionAdapter.h" +#include "SessionHandler.h" #include @@ -51,8 +51,8 @@ class Connection : public sys::ConnectionInputHandler, public: Connection(sys::ConnectionOutputHandler* out, Broker& broker); - /** Get the SessionAdapter for channel. Create if it does not already exist */ - SessionAdapter getChannel(framing::ChannelId channel); + /** Get the SessionHandler for channel. Create if it does not already exist */ + SessionHandler getChannel(framing::ChannelId channel); /** Close the connection */ void close(framing::ReplyCode code, const string& text, framing::ClassId classId, framing::MethodId methodId); @@ -85,7 +85,7 @@ class Connection : public sys::ConnectionInputHandler, private: // Use boost::optional to allow default-constructed uninitialized entries in the map. - typedef std::map >ChannelMap; + typedef std::map >ChannelMap; typedef std::vector::iterator queue_iterator; framing::ProtocolVersion version; diff --git a/cpp/src/qpid/broker/SemanticHandler.cpp b/cpp/src/qpid/broker/SemanticHandler.cpp index dab41dd92f..60c6a5cc10 100644 --- a/cpp/src/qpid/broker/SemanticHandler.cpp +++ b/cpp/src/qpid/broker/SemanticHandler.cpp @@ -21,7 +21,7 @@ #include "SemanticHandler.h" #include "Session.h" -#include "SessionAdapter.h" +#include "SessionHandler.h" #include "BrokerAdapter.h" #include "MessageDelivery.h" #include "Connection.h" @@ -187,7 +187,7 @@ void SemanticHandler::redeliver(Message::shared_ptr& msg, DeliveryToken::shared_ void SemanticHandler::send(const AMQBody& body) { Mutex::ScopedLock l(outLock); - // FIXME aconway 2007-08-31: SessionAdapter should not send + // FIXME aconway 2007-08-31: SessionHandler should not send // channel/session commands via the semantic handler, it should shortcut // directly to its own output handler. That will make the CLASS_ID // part of the test unnecessary. diff --git a/cpp/src/qpid/broker/Session.cpp b/cpp/src/qpid/broker/Session.cpp index 8e8632e922..6bc96b0049 100644 --- a/cpp/src/qpid/broker/Session.cpp +++ b/cpp/src/qpid/broker/Session.cpp @@ -29,7 +29,7 @@ #include "DtxTimeout.h" #include "Message.h" #include "SemanticHandler.h" -#include "SessionAdapter.h" +#include "SessionHandler.h" #include "TxAck.h" #include "TxPublish.h" #include "qpid/QpidError.h" @@ -56,7 +56,7 @@ using namespace qpid::broker; using namespace qpid::framing; using namespace qpid::sys; -Session::Session(SessionAdapter& a, uint32_t t) +Session::Session(SessionHandler& a, uint32_t t) : adapter(&a), broker(adapter->getConnection().broker), timeout(t), diff --git a/cpp/src/qpid/broker/Session.h b/cpp/src/qpid/broker/Session.h index 6b9d3e9557..afcd5853fa 100644 --- a/cpp/src/qpid/broker/Session.h +++ b/cpp/src/qpid/broker/Session.h @@ -50,7 +50,7 @@ class AMQP_ClientProxy; namespace broker { -class SessionAdapter; +class SessionHandler; class Broker; /** @@ -99,7 +99,7 @@ class Session : public framing::FrameHandler::Chains, typedef boost::ptr_map ConsumerImplMap; - SessionAdapter* adapter; + SessionHandler* adapter; Broker& broker; uint32_t timeout; boost::ptr_vector handlers; @@ -137,12 +137,12 @@ class Session : public framing::FrameHandler::Chains, public: - Session(SessionAdapter&, uint32_t timeout); + Session(SessionHandler&, uint32_t timeout); ~Session(); /** Returns 0 if this session is not currently attached */ - SessionAdapter* getAdapter() { return adapter; } - const SessionAdapter* getAdapter() const { return adapter; } + SessionHandler* getAdapter() { return adapter; } + const SessionHandler* getAdapter() const { return adapter; } Broker& getBroker() const { return broker; } diff --git a/cpp/src/qpid/broker/SessionAdapter.cpp b/cpp/src/qpid/broker/SessionAdapter.cpp deleted file mode 100644 index f9d352aa6a..0000000000 --- a/cpp/src/qpid/broker/SessionAdapter.cpp +++ /dev/null @@ -1,146 +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. - * - */ - -#include "SessionAdapter.h" -#include "Session.h" -#include "Connection.h" -#include "qpid/framing/reply_exceptions.h" -#include "qpid/framing/constants.h" -#include "qpid/log/Statement.h" - -namespace qpid { -namespace broker { -using namespace framing; - -// FIXME aconway 2007-08-31: the SessionAdapter should create its -// private proxy directly on the connections out handler. -// Session/channel methods should not go thru the other layers. -// Need to get rid of ChannelAdapter and allow proxies to be created -// directly on output handlers. -// -framing::AMQP_ClientProxy& SessionAdapter::getProxy() { - return session->getProxy(); -} - -SessionAdapter::SessionAdapter(Connection& c, ChannelId ch) - : connection(c), channel(ch), ignoring(false) -{ - in = this; - out = &c.getOutput(); -} - -SessionAdapter::~SessionAdapter() {} - -namespace { -ClassId classId(AMQMethodBody* m) { return m ? m->amqpMethodId() : 0; } -MethodId methodId(AMQMethodBody* m) { return m ? m->amqpClassId() : 0; } -} // namespace - -void SessionAdapter::handle(AMQFrame& f) { - // Note on channel states: a channel is open if session != 0. A - // channel that is closed (session == 0) can be in the "ignoring" - // 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(); - try { - if (m && m->invoke(static_cast(this))) - return; - else if (session) - session->in(f); - else if (!ignoring) - throw ChannelErrorException( - QPID_MSG("Channel " << channel << " is not open")); - } catch(const ChannelException& e){ - getProxy().getChannel().close( - e.code, e.toString(), classId(m), methodId(m)); - session.reset(); - ignoring=true; // Ignore trailing frames sent by client. - }catch(const ConnectionException& e){ - connection.close(e.code, e.what(), classId(m), methodId(m)); - }catch(const std::exception& e){ - connection.close( - framing::INTERNAL_ERROR, e.what(), classId(m), methodId(m)); - } -} - -void SessionAdapter::assertOpen(const char* method) { - if (!session) - throw ChannelErrorException( - QPID_MSG(""<flow(active); - getProxy().getChannel().flowOk(active); -} - -void SessionAdapter::flowOk(bool /*active*/){} - -void SessionAdapter::close(uint16_t replyCode, - const string& replyText, - uint16_t classId, uint16_t methodId) -{ - // FIXME aconway 2007-08-31: Extend constants.h to map codes & ids - // to text names. - QPID_LOG(warning, "Received session.close("< session; - bool ignoring; -}; - -}} // namespace qpid::broker - -#endif /*!QPID_BROKER_SESSIONADAPTER_H*/ diff --git a/cpp/src/qpid/broker/SessionHandler.cpp b/cpp/src/qpid/broker/SessionHandler.cpp new file mode 100644 index 0000000000..c6ba73e43a --- /dev/null +++ b/cpp/src/qpid/broker/SessionHandler.cpp @@ -0,0 +1,146 @@ +/* + * 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. + * + */ + +#include "SessionHandler.h" +#include "Session.h" +#include "Connection.h" +#include "qpid/framing/reply_exceptions.h" +#include "qpid/framing/constants.h" +#include "qpid/log/Statement.h" + +namespace qpid { +namespace broker { +using namespace framing; + +// FIXME aconway 2007-08-31: the SessionHandler should create its +// private proxy directly on the connections out handler. +// Session/channel methods should not go thru the other layers. +// Need to get rid of ChannelAdapter and allow proxies to be created +// directly on output handlers. +// +framing::AMQP_ClientProxy& SessionHandler::getProxy() { + return session->getProxy(); +} + +SessionHandler::SessionHandler(Connection& c, ChannelId ch) + : connection(c), channel(ch), ignoring(false) +{ + in = this; + out = &c.getOutput(); +} + +SessionHandler::~SessionHandler() {} + +namespace { +ClassId classId(AMQMethodBody* m) { return m ? m->amqpMethodId() : 0; } +MethodId methodId(AMQMethodBody* m) { return m ? m->amqpClassId() : 0; } +} // namespace + +void SessionHandler::handle(AMQFrame& f) { + // Note on channel states: a channel is open if session != 0. A + // channel that is closed (session == 0) can be in the "ignoring" + // 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(); + try { + if (m && m->invoke(static_cast(this))) + return; + else if (session) + session->in(f); + else if (!ignoring) + throw ChannelErrorException( + QPID_MSG("Channel " << channel << " is not open")); + } catch(const ChannelException& e){ + getProxy().getChannel().close( + e.code, e.toString(), classId(m), methodId(m)); + session.reset(); + ignoring=true; // Ignore trailing frames sent by client. + }catch(const ConnectionException& e){ + connection.close(e.code, e.what(), classId(m), methodId(m)); + }catch(const std::exception& e){ + connection.close( + framing::INTERNAL_ERROR, e.what(), classId(m), methodId(m)); + } +} + +void SessionHandler::assertOpen(const char* method) { + if (!session) + throw ChannelErrorException( + QPID_MSG(""<flow(active); + getProxy().getChannel().flowOk(active); +} + +void SessionHandler::flowOk(bool /*active*/){} + +void SessionHandler::close(uint16_t replyCode, + const string& replyText, + uint16_t classId, uint16_t methodId) +{ + // FIXME aconway 2007-08-31: Extend constants.h to map codes & ids + // to text names. + QPID_LOG(warning, "Received session.close("< session; + bool ignoring; +}; + +}} // namespace qpid::broker + +#endif /*!QPID_BROKER_SESSIONADAPTER_H*/ diff --git a/cpp/src/qpid/cluster/SessionManager.cpp b/cpp/src/qpid/cluster/SessionManager.cpp index dc14b24905..537b17a23c 100644 --- a/cpp/src/qpid/cluster/SessionManager.cpp +++ b/cpp/src/qpid/cluster/SessionManager.cpp @@ -40,7 +40,7 @@ using namespace broker; struct SessionManager::BrokerHandler : public FrameHandler, private ChannelAdapter { Connection connection; - SessionAdapter sessionAdapter; + SessionHandler sessionAdapter; broker::Session session; BrokerAdapter adapter; -- cgit v1.2.1