diff options
author | Ted Ross <tross@apache.org> | 2008-12-18 14:29:26 +0000 |
---|---|---|
committer | Ted Ross <tross@apache.org> | 2008-12-18 14:29:26 +0000 |
commit | 85ac83d0f66f6296ba4b72df234f5fe5326733ec (patch) | |
tree | e8775599b8cf24aaeb95cb1c83d8aff0c494d9fd | |
parent | 1e4fd5eaa140f5841d706cd9cf6999688b610c97 (diff) | |
download | qpid-python-85ac83d0f66f6296ba4b72df234f5fe5326733ec.tar.gz |
Added a general ConnectionSettings alternative for agent initialization.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@727726 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | qpid/cpp/examples/qmf-agent/example.cpp | 6 | ||||
-rw-r--r-- | qpid/cpp/src/qpid/agent/ManagementAgent.h | 6 | ||||
-rw-r--r-- | qpid/cpp/src/qpid/agent/ManagementAgentImpl.cpp | 26 | ||||
-rw-r--r-- | qpid/cpp/src/qpid/agent/ManagementAgentImpl.h | 4 | ||||
-rw-r--r-- | qpid/cpp/src/qpid/management/ManagementBroker.h | 7 |
5 files changed, 37 insertions, 12 deletions
diff --git a/qpid/cpp/examples/qmf-agent/example.cpp b/qpid/cpp/examples/qmf-agent/example.cpp index 8c47a0c366..4dec014370 100644 --- a/qpid/cpp/examples/qmf-agent/example.cpp +++ b/qpid/cpp/examples/qmf-agent/example.cpp @@ -164,6 +164,10 @@ int main_int(int argc, char** argv) singleton = new ManagementAgent::Singleton(); const char* host = argc>1 ? argv[1] : "127.0.0.1"; int port = argc>2 ? atoi(argv[2]) : 5672; + qpid::client::ConnectionSettings settings; + + settings.host = host; + settings.port = port; signal(SIGINT, shutdown); @@ -175,7 +179,7 @@ int main_int(int argc, char** argv) // Start the agent. It will attempt to make a connection to the // management broker - agent->init(string(host), port, 5, false, ".magentdata"); + agent->init(settings, 5, false, ".magentdata"); // Allocate some core objects CoreClass core1(agent, "Example Core Object #1"); diff --git a/qpid/cpp/src/qpid/agent/ManagementAgent.h b/qpid/cpp/src/qpid/agent/ManagementAgent.h index 296bb17e62..c94291c9e7 100644 --- a/qpid/cpp/src/qpid/agent/ManagementAgent.h +++ b/qpid/cpp/src/qpid/agent/ManagementAgent.h @@ -24,6 +24,7 @@ #include "qpid/management/ManagementEvent.h" #include "qpid/management/Manageable.h" #include "qpid/sys/Mutex.h" +#include "qpid/client/ConnectionSettings.h" namespace qpid { namespace management { @@ -91,6 +92,11 @@ class ManagementAgent const std::string& mech = "PLAIN", const std::string& proto = "tcp") = 0; + virtual void init(const client::ConnectionSettings& settings, + uint16_t intervalSeconds = 10, + bool useExternalThread = false, + const std::string& storeFile = "") = 0; + // Register a schema with the management agent. This is normally called by the // package initializer generated by the management code generator. // diff --git a/qpid/cpp/src/qpid/agent/ManagementAgentImpl.cpp b/qpid/cpp/src/qpid/agent/ManagementAgentImpl.cpp index 3e7898f0da..1e2f4cdd78 100644 --- a/qpid/cpp/src/qpid/agent/ManagementAgentImpl.cpp +++ b/qpid/cpp/src/qpid/agent/ManagementAgentImpl.cpp @@ -124,19 +124,29 @@ void ManagementAgentImpl::init(const string& brokerHost, const string& mech, const string& proto) { + client::ConnectionSettings settings; + settings.protocol = proto; + settings.host = brokerHost; + settings.port = brokerPort; + settings.username = uid; + settings.password = pwd; + settings.mechanism = mech; + init(settings, intervalSeconds, useExternalThread, _storeFile); +} + +void ManagementAgentImpl::init(const client::ConnectionSettings& settings, + uint16_t intervalSeconds, + bool useExternalThread, + const std::string& _storeFile) +{ interval = intervalSeconds; extThread = useExternalThread; storeFile = _storeFile; nextObjectId = 1; - connectionSettings.protocol = proto; - connectionSettings.host = brokerHost; - connectionSettings.port = brokerPort; - connectionSettings.username = uid; - connectionSettings.password = pwd; - connectionSettings.mechanism = mech; - - QPID_LOG(info, "QMF Agent Initialized: broker=" << brokerHost << ":" << brokerPort << + + QPID_LOG(info, "QMF Agent Initialized: broker=" << settings.host << ":" << settings.port << " interval=" << intervalSeconds << " storeFile=" << _storeFile); + connectionSettings = settings; // TODO: Abstract the socket calls for portability if (extThread) { diff --git a/qpid/cpp/src/qpid/agent/ManagementAgentImpl.h b/qpid/cpp/src/qpid/agent/ManagementAgentImpl.h index 8add0aba93..53eb690ba8 100644 --- a/qpid/cpp/src/qpid/agent/ManagementAgentImpl.h +++ b/qpid/cpp/src/qpid/agent/ManagementAgentImpl.h @@ -59,6 +59,10 @@ class ManagementAgentImpl : public ManagementAgent, public client::MessageListen const std::string& pwd = "guest", const std::string& mech = "PLAIN", const std::string& proto = "tcp"); + void init(const client::ConnectionSettings& settings, + uint16_t intervalSeconds = 10, + bool useExternalThread = false, + const std::string& storeFile = ""); bool isConnected() { return connected; } std::string& getLastFailure() { return lastFailure; } void registerClass(const std::string& packageName, diff --git a/qpid/cpp/src/qpid/management/ManagementBroker.h b/qpid/cpp/src/qpid/management/ManagementBroker.h index 77f4a53836..59dfb98596 100644 --- a/qpid/cpp/src/qpid/management/ManagementBroker.h +++ b/qpid/cpp/src/qpid/management/ManagementBroker.h @@ -71,9 +71,10 @@ public: const framing::Uuid& getUuid() const { return uuid; } // Stubs for remote management agent calls - void init (const std::string&, uint16_t, uint16_t, bool, - const std::string&, const std::string&, const std::string&, - const std::string&, const std::string&) { assert(0); } + void init(const std::string&, uint16_t, uint16_t, bool, + const std::string&, const std::string&, const std::string&, + const std::string&, const std::string&) { assert(0); } + void init(const client::ConnectionSettings&, uint16_t, bool, const std::string&) { assert(0); } uint32_t pollCallbacks (uint32_t) { assert(0); return 0; } int getSignalFd () { assert(0); return -1; } |