From 9e115470654bf67fbb4720ab3bfb3768b9331e55 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Thu, 26 Jun 2008 21:39:28 +0000 Subject: Plugin framework change: single PluginFactory creates per-target Plugin instances. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@672032 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/sys/TCPIOPlugin.cpp | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'cpp/src/qpid/sys/TCPIOPlugin.cpp') diff --git a/cpp/src/qpid/sys/TCPIOPlugin.cpp b/cpp/src/qpid/sys/TCPIOPlugin.cpp index e82a6a9102..9d272ee69c 100644 --- a/cpp/src/qpid/sys/TCPIOPlugin.cpp +++ b/cpp/src/qpid/sys/TCPIOPlugin.cpp @@ -53,22 +53,20 @@ class AsynchIOProtocolFactory : public ProtocolFactory { bool isClient); }; -// Static instance to initialise plugin -static class TCPIOPlugin : public Plugin { - void earlyInitialize(Target&) { +struct TCPIOPlugin : public PluginT { + void initializeT(broker::Broker& broker) { + const broker::Broker::Options& opts = broker.getOptions(); + ProtocolFactory::shared_ptr protocol(new AsynchIOProtocolFactory(opts.port, opts.connectionBacklog)); + QPID_LOG(info, "Listening on TCP port " << protocol->getPort()); + broker.registerProtocolFactory(protocol); } - - void initialize(Target& target) { - broker::Broker* broker = dynamic_cast(&target); - // Only provide to a Broker - if (broker) { - const broker::Broker::Options& opts = broker->getOptions(); - ProtocolFactory::shared_ptr protocol(new AsynchIOProtocolFactory(opts.port, opts.connectionBacklog)); - QPID_LOG(info, "Listening on TCP port " << protocol->getPort()); - broker->registerProtocolFactory(protocol); - } +}; + +static struct TCPIOPluginFactory : public Plugin::FactoryT { + boost::shared_ptr createT(broker::Broker&) { + return make_shared_ptr(new TCPIOPlugin()); } -} tcpPlugin; +} theTCPIOPluginFactory; // Static plugin factory instance. AsynchIOProtocolFactory::AsynchIOProtocolFactory(int16_t port, int backlog) : listeningPort(listener.listen(port, backlog)) -- cgit v1.2.1