From fac4ce5feb34885051ff8ec08527875ca5583af7 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Wed, 18 Jan 2012 22:08:29 +0000 Subject: QPID-3603: Consistent find/get functions for Queue and Exchange registries. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1233084 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/broker/ExchangeRegistry.cpp | 13 ++++++++++--- cpp/src/qpid/broker/ExchangeRegistry.h | 12 +++++++++++- cpp/src/qpid/broker/QueueRegistry.cpp | 8 +++++++- cpp/src/qpid/broker/QueueRegistry.h | 5 +++++ 4 files changed, 33 insertions(+), 5 deletions(-) (limited to 'cpp') diff --git a/cpp/src/qpid/broker/ExchangeRegistry.cpp b/cpp/src/qpid/broker/ExchangeRegistry.cpp index 1c8d26c4f7..fca77f7ddd 100644 --- a/cpp/src/qpid/broker/ExchangeRegistry.cpp +++ b/cpp/src/qpid/broker/ExchangeRegistry.cpp @@ -87,12 +87,19 @@ void ExchangeRegistry::destroy(const string& name){ } } -Exchange::shared_ptr ExchangeRegistry::get(const string& name){ +Exchange::shared_ptr ExchangeRegistry::find(const string& name){ RWlock::ScopedRlock locker(lock); ExchangeMap::iterator i = exchanges.find(name); if (i == exchanges.end()) - throw framing::NotFoundException(QPID_MSG("Exchange not found: " << name)); - return i->second; + return Exchange::shared_ptr(); + else + return i->second; +} + +Exchange::shared_ptr ExchangeRegistry::get(const string& name) { + Exchange::shared_ptr ex = find(name); + if (!ex) throw framing::NotFoundException(QPID_MSG("Exchange not found: "< find(const std::string& name); + + /** + * Get the named exchange. Throw exception if not found. + */ + QPID_BROKER_EXTERN boost::shared_ptr get(const std::string& name); + + /** * Register the manageable parent for declared exchanges */ diff --git a/cpp/src/qpid/broker/QueueRegistry.cpp b/cpp/src/qpid/broker/QueueRegistry.cpp index 135a3543d9..236d5ae34c 100644 --- a/cpp/src/qpid/broker/QueueRegistry.cpp +++ b/cpp/src/qpid/broker/QueueRegistry.cpp @@ -23,6 +23,7 @@ #include "qpid/broker/QueueEvents.h" #include "qpid/broker/Exchange.h" #include "qpid/log/Statement.h" +#include "qpid/framing/reply_exceptions.h" #include #include @@ -84,7 +85,6 @@ void QueueRegistry::destroy (const string& name){ Queue::shared_ptr QueueRegistry::find(const string& name){ RWlock::ScopedRlock locker(lock); QueueMap::iterator i = queues.find(name); - if (i == queues.end()) { return Queue::shared_ptr(); } else { @@ -92,6 +92,12 @@ Queue::shared_ptr QueueRegistry::find(const string& name){ } } +Queue::shared_ptr QueueRegistry::get(const string& name) { + Queue::shared_ptr q = find(name); + if (!q) throw framing::NotFoundException(QPID_MSG("Queue not found: "< find(const std::string& name); + /** + * Get the named queue. Throw exception if not found. + */ + QPID_BROKER_EXTERN boost::shared_ptr get(const std::string& name); + /** * Generate unique queue name. */ -- cgit v1.2.1