diff options
Diffstat (limited to 'cpp/src/qpid/sys')
-rw-r--r-- | cpp/src/qpid/sys/Acceptor.h | 1 | ||||
-rw-r--r-- | cpp/src/qpid/sys/TCPIOPlugin.cpp | 29 |
2 files changed, 22 insertions, 8 deletions
diff --git a/cpp/src/qpid/sys/Acceptor.h b/cpp/src/qpid/sys/Acceptor.h index 243e791eeb..69a6eb8d7c 100644 --- a/cpp/src/qpid/sys/Acceptor.h +++ b/cpp/src/qpid/sys/Acceptor.h @@ -35,7 +35,6 @@ class Poller; class Acceptor : public qpid::SharedObject<Acceptor> { public: - static Acceptor::shared_ptr create(int16_t port, int backlog); virtual ~Acceptor() = 0; virtual uint16_t getPort() const = 0; virtual std::string getHost() const = 0; diff --git a/cpp/src/qpid/sys/TCPIOPlugin.cpp b/cpp/src/qpid/sys/TCPIOPlugin.cpp index 779319b7e4..eb6bcb3dee 100644 --- a/cpp/src/qpid/sys/TCPIOPlugin.cpp +++ b/cpp/src/qpid/sys/TCPIOPlugin.cpp @@ -20,10 +20,13 @@ */ #include "Acceptor.h" - #include "AsynchIOHandler.h" #include "AsynchIO.h" +#include "qpid/Plugin.h" +#include "qpid/broker/Broker.h" +#include "qpid/log/Statement.h" + #include <boost/bind.hpp> #include <memory> @@ -47,14 +50,26 @@ class AsynchIOAcceptor : public Acceptor { void accepted(Poller::shared_ptr, const Socket&, ConnectionCodec::Factory*); }; -Acceptor::shared_ptr Acceptor::create(int16_t port, int backlog) -{ - return Acceptor::shared_ptr(new AsynchIOAcceptor(port, backlog)); -} +// Static instance to initialise plugin +static class TCPIOPlugin : public Plugin { + void earlyInitialize(Target&) { + } + + void initialize(Target& target) { + + broker::Broker* broker = dynamic_cast<broker::Broker*>(&target); + // Only provide to a Broker + if (broker) { + const broker::Broker::Options& opts = broker->getOptions(); + Acceptor::shared_ptr acceptor(new AsynchIOAcceptor(opts.port, opts.connectionBacklog)); + QPID_LOG(info, "Listening on TCP port " << acceptor->getPort()); + broker->registerAccepter(acceptor); + } + } +} acceptor; AsynchIOAcceptor::AsynchIOAcceptor(int16_t port, int backlog) : - listeningPort(listener.listen(port, backlog)), - acceptor(0) + listeningPort(listener.listen(port, backlog)) {} void AsynchIOAcceptor::accepted(Poller::shared_ptr poller, const Socket& s, ConnectionCodec::Factory* f) { |