diff options
| author | Alan Conway <aconway@apache.org> | 2008-07-08 22:58:37 +0000 |
|---|---|---|
| committer | Alan Conway <aconway@apache.org> | 2008-07-08 22:58:37 +0000 |
| commit | 8c3baf496f9424249e2a666d79f0e3b38ba8d8fc (patch) | |
| tree | 5fd950f023cacb47cf3cc9dc11aed91c94f380f8 /cpp/src/qpid/cluster/ClusterPlugin.cpp | |
| parent | 391608a73f18a1797ab0c358f0a94364dc888eb2 (diff) | |
| download | qpid-python-8c3baf496f9424249e2a666d79f0e3b38ba8d8fc.tar.gz | |
HandlerChain: plug-in handler chain extension points. Replaces Handler<T>::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
Diffstat (limited to 'cpp/src/qpid/cluster/ClusterPlugin.cpp')
| -rw-r--r-- | cpp/src/qpid/cluster/ClusterPlugin.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
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<framing::FrameHandler, broker::Connection> ConnectionChain; ClusterOptions options; boost::optional<Cluster> cluster; - Options* getOptions() { return &options; } + template <class Chain> void init(Plugin::Target& t) { + Chain* c = dynamic_cast<Chain*>(&t); + if (c) cluster->initialize(*c); + } void earlyInitialize(Plugin::Target&) {} void initialize(Plugin::Target& target) { broker::Broker* broker = dynamic_cast<broker::Broker*>(&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<ConnectionChain>(target); } }; |
