summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2012-01-18 22:08:29 +0000
committerAlan Conway <aconway@apache.org>2012-01-18 22:08:29 +0000
commit95212f86c498cb5612b3cc0970b13e9038f10700 (patch)
tree40fb0f0e3e953f273ebc26949e839538ac5b5f6d
parent237af7e92427c9dd3ea6ccd8912ce6a436cc7627 (diff)
downloadqpid-python-95212f86c498cb5612b3cc0970b13e9038f10700.tar.gz
QPID-3603: Consistent find/get functions for Queue and Exchange registries.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1233084 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/cpp/src/qpid/broker/ExchangeRegistry.cpp13
-rw-r--r--qpid/cpp/src/qpid/broker/ExchangeRegistry.h12
-rw-r--r--qpid/cpp/src/qpid/broker/QueueRegistry.cpp8
-rw-r--r--qpid/cpp/src/qpid/broker/QueueRegistry.h5
4 files changed, 33 insertions, 5 deletions
diff --git a/qpid/cpp/src/qpid/broker/ExchangeRegistry.cpp b/qpid/cpp/src/qpid/broker/ExchangeRegistry.cpp
index 1c8d26c4f7..fca77f7ddd 100644
--- a/qpid/cpp/src/qpid/broker/ExchangeRegistry.cpp
+++ b/qpid/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: "<<name));
+ return ex;
}
bool ExchangeRegistry::registerExchange(const Exchange::shared_ptr& ex) {
diff --git a/qpid/cpp/src/qpid/broker/ExchangeRegistry.h b/qpid/cpp/src/qpid/broker/ExchangeRegistry.h
index 2b75a8f3cf..90ef81b49e 100644
--- a/qpid/cpp/src/qpid/broker/ExchangeRegistry.h
+++ b/qpid/cpp/src/qpid/broker/ExchangeRegistry.h
@@ -54,10 +54,20 @@ class ExchangeRegistry{
bool durable,
const qpid::framing::FieldTable& args = framing::FieldTable());
QPID_BROKER_EXTERN void destroy(const std::string& name);
- QPID_BROKER_EXTERN Exchange::shared_ptr get(const std::string& name);
Exchange::shared_ptr getDefault();
/**
+ * Find the named exchange. Return 0 if not found.
+ */
+ QPID_BROKER_EXTERN boost::shared_ptr<Exchange> find(const std::string& name);
+
+ /**
+ * Get the named exchange. Throw exception if not found.
+ */
+ QPID_BROKER_EXTERN boost::shared_ptr<Exchange> get(const std::string& name);
+
+
+ /**
* Register the manageable parent for declared exchanges
*/
void setParent (management::Manageable* _parent) { parent = _parent; }
diff --git a/qpid/cpp/src/qpid/broker/QueueRegistry.cpp b/qpid/cpp/src/qpid/broker/QueueRegistry.cpp
index 135a3543d9..236d5ae34c 100644
--- a/qpid/cpp/src/qpid/broker/QueueRegistry.cpp
+++ b/qpid/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 <sstream>
#include <assert.h>
@@ -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: "<<name));
+ return q;
+}
+
string QueueRegistry::generateName(){
string name;
do {
diff --git a/qpid/cpp/src/qpid/broker/QueueRegistry.h b/qpid/cpp/src/qpid/broker/QueueRegistry.h
index 8a32a64f05..f724e6b10c 100644
--- a/qpid/cpp/src/qpid/broker/QueueRegistry.h
+++ b/qpid/cpp/src/qpid/broker/QueueRegistry.h
@@ -97,6 +97,11 @@ class QueueRegistry {
QPID_BROKER_EXTERN boost::shared_ptr<Queue> find(const std::string& name);
/**
+ * Get the named queue. Throw exception if not found.
+ */
+ QPID_BROKER_EXTERN boost::shared_ptr<Queue> get(const std::string& name);
+
+ /**
* Generate unique queue name.
*/
std::string generateName();