From 8c3baf496f9424249e2a666d79f0e3b38ba8d8fc Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Tue, 8 Jul 2008 22:58:37 +0000 Subject: HandlerChain: plug-in handler chain extension points. Replaces Handler::Chain. Updated Sessoin & Connection handler chains and Cluster. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@675017 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/cluster/ClusterPlugin.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'cpp/src/qpid/cluster/ClusterPlugin.cpp') diff --git a/cpp/src/qpid/cluster/ClusterPlugin.cpp b/cpp/src/qpid/cluster/ClusterPlugin.cpp index 6d3dca84be..c4b67de141 100644 --- a/cpp/src/qpid/cluster/ClusterPlugin.cpp +++ b/cpp/src/qpid/cluster/ClusterPlugin.cpp @@ -54,24 +54,29 @@ struct ClusterOptions : public Options { }; struct ClusterPlugin : public Plugin { + typedef PluginHandlerChain ConnectionChain; ClusterOptions options; boost::optional cluster; - Options* getOptions() { return &options; } + template void init(Plugin::Target& t) { + Chain* c = dynamic_cast(&t); + if (c) cluster->initialize(*c); + } void earlyInitialize(Plugin::Target&) {} void initialize(Plugin::Target& target) { broker::Broker* broker = dynamic_cast(&target); - // Only provide to a Broker, and only if the --cluster config is set. if (broker && !options.name.empty()) { - assert(!cluster); // A process can only belong to one cluster. + if (cluster) throw Exception("Cluster plugin cannot be initialized twice in a process."); cluster = boost::in_place(options.name, options.getUrl(broker->getPort()), boost::ref(*broker)); - broker->getConnectionManager().add(cluster->getObserver()); + return; } + if (!cluster) return; // Ignore chain handlers if we didn't init a cluster. + init(target); } }; -- cgit v1.2.1