00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _PreviewConnection_
00022 #define _PreviewConnection_
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 "PreviewConnectionHandler.h"
00042 #include "ConnectionState.h"
00043 #include "PreviewSessionHandler.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 PreviewConnection : public sys::ConnectionInputHandler, public ConnectionState
00054 {
00055 public:
00056 PreviewConnection(sys::ConnectionOutputHandler* out, Broker& broker, const std::string& mgmtId, bool isLink = false);
00057 ~PreviewConnection ();
00058
00060 PreviewSessionHandler& getChannel(framing::ChannelId channel);
00061
00063 void close(framing::ReplyCode code, const string& text, framing::ClassId classId, framing::MethodId methodId);
00064
00065
00066 void received(framing::AMQFrame& frame);
00067 void idleOut();
00068 void idleIn();
00069 void closed();
00070 bool doOutput();
00071
00072 void closeChannel(framing::ChannelId channel);
00073
00074
00075 management::ManagementObject::shared_ptr GetManagementObject (void) const;
00076 management::Manageable::status_t
00077 ManagementMethod (uint32_t methodId, management::Args& args);
00078
00079
00080 private:
00081 typedef boost::ptr_map<framing::ChannelId, PreviewSessionHandler> ChannelMap;
00082 typedef std::vector<Queue::shared_ptr>::iterator queue_iterator;
00083
00090 class MgmtWrapper
00091 {
00092 public:
00093 virtual ~MgmtWrapper(){}
00094 virtual void received(framing::AMQFrame& frame) = 0;
00095 virtual management::ManagementObject::shared_ptr getManagementObject() const = 0;
00096 virtual void closing() = 0;
00097 virtual void processPending(){}
00098 virtual void process(PreviewConnection&, const management::Args&){}
00099 };
00100 class MgmtClient;
00101 class MgmtLink;
00102
00103 ChannelMap channels;
00104 framing::AMQP_ClientProxy::Connection* client;
00105 uint64_t stagingThreshold;
00106 PreviewConnectionHandler adapter;
00107 std::auto_ptr<MgmtWrapper> mgmtWrapper;
00108 bool mgmtClosing;
00109 const std::string mgmtId;
00110 };
00111
00112 }}
00113
00114 #endif