00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _Connection_
00022 #define _Connection_
00023
00024 #include <memory>
00025 #include <sstream>
00026 #include <vector>
00027
00028 #include <boost/ptr_container/ptr_map.hpp>
00029
00030 #include "qpid/framing/AMQFrame.h"
00031 #include "qpid/framing/AMQP_ServerOperations.h"
00032 #include "qpid/framing/AMQP_ClientProxy.h"
00033 #include "qpid/sys/AggregateOutput.h"
00034 #include "qpid/sys/ConnectionOutputHandler.h"
00035 #include "qpid/sys/ConnectionInputHandler.h"
00036 #include "qpid/sys/TimeoutHandler.h"
00037 #include "qpid/framing/ProtocolVersion.h"
00038 #include "Broker.h"
00039 #include "qpid/sys/Socket.h"
00040 #include "qpid/Exception.h"
00041 #include "ConnectionHandler.h"
00042 #include "ConnectionState.h"
00043 #include "SessionHandler.h"
00044 #include "qpid/management/Manageable.h"
00045 #include "qpid/management/Client.h"
00046 #include "qpid/management/Link.h"
00047
00048 #include <boost/ptr_container/ptr_map.hpp>
00049
00050 namespace qpid {
00051 namespace broker {
00052
00053 class Connection : public sys::ConnectionInputHandler,
00054 public ConnectionState
00055 {
00056 public:
00057 Connection(sys::ConnectionOutputHandler* out, Broker& broker, const std::string& mgmtId);
00058 ~Connection ();
00059
00061 SessionHandler& getChannel(framing::ChannelId channel);
00062
00064 void close(framing::ReplyCode code, const string& text, framing::ClassId classId, framing::MethodId methodId);
00065
00066
00067 void received(framing::AMQFrame& frame);
00068 void idleOut();
00069 void idleIn();
00070 void closed();
00071 bool doOutput();
00072
00073 void closeChannel(framing::ChannelId channel);
00074
00075
00076 management::ManagementObject::shared_ptr GetManagementObject (void) const;
00077 management::Manageable::status_t
00078 ManagementMethod (uint32_t methodId, management::Args& args);
00079
00080 void initMgmt(bool asLink = false);
00081
00082 private:
00083 typedef boost::ptr_map<framing::ChannelId, SessionHandler> ChannelMap;
00084 typedef std::vector<Queue::shared_ptr>::iterator queue_iterator;
00085
00092 class MgmtWrapper
00093 {
00094 public:
00095 virtual ~MgmtWrapper(){}
00096 virtual void received(framing::AMQFrame& frame) = 0;
00097 virtual management::ManagementObject::shared_ptr getManagementObject() const = 0;
00098 virtual void closing() = 0;
00099 virtual void processPending(){}
00100 virtual void process(Connection&, const management::Args&){}
00101 };
00102 class MgmtClient;
00103 class MgmtLink;
00104
00105 ChannelMap channels;
00106 framing::AMQP_ClientProxy::Connection* client;
00107 ConnectionHandler adapter;
00108 std::auto_ptr<MgmtWrapper> mgmtWrapper;
00109 bool mgmtClosing;
00110 const std::string mgmtId;
00111 };
00112
00113 }}
00114
00115 #endif