00001 #ifndef QPID_BROKER_CONNECTION_H
00002 #define QPID_BROKER_CONNECTION_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <memory>
00026 #include <sstream>
00027 #include <vector>
00028
00029 #include <boost/ptr_container/ptr_map.hpp>
00030
00031 #include "Broker.h"
00032 #include "ConnectionHandler.h"
00033 #include "ConnectionState.h"
00034 #include "SessionHandler.h"
00035 #include "qmf/org/apache/qpid/broker/Connection.h"
00036 #include "qpid/Exception.h"
00037 #include "qpid/RefCounted.h"
00038 #include "qpid/framing/AMQFrame.h"
00039 #include "qpid/framing/AMQP_ClientProxy.h"
00040 #include "qpid/framing/AMQP_ServerOperations.h"
00041 #include "qpid/framing/ProtocolVersion.h"
00042 #include "qpid/management/Manageable.h"
00043 #include "qpid/ptr_map.h"
00044 #include "qpid/sys/AggregateOutput.h"
00045 #include "qpid/sys/ConnectionInputHandler.h"
00046 #include "qpid/sys/ConnectionOutputHandler.h"
00047 #include "qpid/sys/Socket.h"
00048 #include "qpid/sys/TimeoutHandler.h"
00049
00050 #include <boost/ptr_container/ptr_map.hpp>
00051 #include <boost/bind.hpp>
00052
00053 #include <algorithm>
00054
00055 namespace qpid {
00056 namespace broker {
00057
00058 class LinkRegistry;
00059
00060 class Connection : public sys::ConnectionInputHandler,
00061 public ConnectionState,
00062 public RefCounted
00063 {
00064 public:
00065 Connection(sys::ConnectionOutputHandler* out, Broker& broker, const std::string& mgmtId, bool isLink = false);
00066 ~Connection ();
00067
00069 SessionHandler& getChannel(framing::ChannelId channel);
00070
00072 void close(framing::ReplyCode code = 403,
00073 const string& text = string(),
00074 framing::ClassId classId = 0,
00075 framing::MethodId methodId = 0);
00076
00077
00078 void received(framing::AMQFrame& frame);
00079 void idleOut();
00080 void idleIn();
00081 bool hasOutput();
00082 bool doOutput();
00083 void closed();
00084
00085 void closeChannel(framing::ChannelId channel);
00086
00087
00088 management::ManagementObject* GetManagementObject (void) const;
00089 management::Manageable::status_t
00090 ManagementMethod (uint32_t methodId, management::Args& args, std::string&);
00091
00092 void requestIOProcessing (boost::function0<void>);
00093 void recordFromServer (framing::AMQFrame& frame);
00094 void recordFromClient (framing::AMQFrame& frame);
00095 std::string getAuthMechanism();
00096 std::string getAuthCredentials();
00097 void notifyConnectionForced(const std::string& text);
00098 void setUserId(const string& uid);
00099 void setFederationLink(bool b);
00100
00101 template <class F> void eachSessionHandler(F f) {
00102 for (ChannelMap::iterator i = channels.begin(); i != channels.end(); ++i)
00103 f(*ptr_map_ptr(i));
00104 }
00105
00106 void sendClose();
00107
00108 private:
00109 typedef boost::ptr_map<framing::ChannelId, SessionHandler> ChannelMap;
00110 typedef std::vector<Queue::shared_ptr>::iterator queue_iterator;
00111
00112 ChannelMap channels;
00113 framing::AMQP_ClientProxy::Connection* client;
00114 ConnectionHandler adapter;
00115 bool isLink;
00116 bool mgmtClosing;
00117 const std::string mgmtId;
00118 boost::function0<void> ioCallback;
00119 qmf::org::apache::qpid::broker::Connection* mgmtObject;
00120 LinkRegistry& links;
00121 };
00122
00123 }}
00124
00125 #endif