diff options
author | Andrew Stitcher <astitcher@apache.org> | 2008-04-18 21:03:49 +0000 |
---|---|---|
committer | Andrew Stitcher <astitcher@apache.org> | 2008-04-18 21:03:49 +0000 |
commit | df28afb19a10c804cd02696bd94b09fed1719478 (patch) | |
tree | 9aafbc5ee664b561257cebe8edd2c46955b0999d /cpp/src/qpid/sys/TCPIOPlugin.cpp | |
parent | 8633240562fad63a493b319d12b9c663ca081c75 (diff) | |
download | qpid-python-df28afb19a10c804cd02696bd94b09fed1719478.tar.gz |
Refactored Acceptor code to allow multiple acceptors to be present in the broker
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@649689 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/sys/TCPIOPlugin.cpp')
-rw-r--r-- | cpp/src/qpid/sys/TCPIOPlugin.cpp | 29 |
1 files changed, 22 insertions, 7 deletions
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) { |