00001 #ifndef QPID_BROKER_SESSION_H
00002 #define QPID_BROKER_SESSION_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 "qpid/SessionState.h"
00026 #include "qpid/framing/FrameHandler.h"
00027 #include "qpid/framing/SequenceSet.h"
00028 #include "qpid/sys/Mutex.h"
00029 #include "qpid/sys/Time.h"
00030 #include "qpid/management/Manageable.h"
00031 #include "qpid/management/Session.h"
00032 #include "SessionAdapter.h"
00033 #include "DeliveryAdapter.h"
00034 #include "IncompleteMessageList.h"
00035 #include "MessageBuilder.h"
00036 #include "SessionContext.h"
00037 #include "SemanticState.h"
00038
00039 #include <boost/noncopyable.hpp>
00040 #include <boost/scoped_ptr.hpp>
00041
00042 #include <set>
00043 #include <vector>
00044 #include <ostream>
00045
00046 namespace qpid {
00047
00048 namespace framing {
00049 class AMQP_ClientProxy;
00050 }
00051
00052 namespace broker {
00053
00054 class Broker;
00055 class ConnectionState;
00056 class Message;
00057 class SessionHandler;
00058 class SessionManager;
00059
00064 class SessionState : public qpid::SessionState,
00065 public SessionContext,
00066 public DeliveryAdapter,
00067 public management::Manageable,
00068 public framing::FrameHandler::InOutHandler
00069 {
00070 public:
00071 SessionState(Broker&, SessionHandler&, const SessionId&, const SessionState::Configuration&);
00072 ~SessionState();
00073 bool isAttached() const { return handler; }
00074
00075 void detach();
00076 void attach(SessionHandler& handler);
00077
00079 framing::AMQP_ClientProxy& getProxy();
00080
00082 ConnectionState& getConnection();
00083 bool isLocal(const ConnectionToken* t) const;
00084
00085 Broker& getBroker();
00086
00088 void activateOutput();
00089
00090 void senderCompleted(const framing::SequenceSet& ranges);
00091
00092 void sendCompletion();
00093
00094
00095 DeliveryId deliver(QueuedMessage& msg, DeliveryToken::shared_ptr token);
00096
00097
00098 management::ManagementObject* GetManagementObject (void) const;
00099 management::Manageable::status_t
00100 ManagementMethod (uint32_t methodId, management::Args& args);
00101
00102 void readyToSend();
00103
00104 private:
00105
00106 void handleCommand(framing::AMQMethodBody* method, const framing::SequenceNumber& id);
00107 void handleContent(framing::AMQFrame& frame, const framing::SequenceNumber& id);
00108 void enqueued(boost::intrusive_ptr<Message> msg);
00109
00110 void handleIn(framing::AMQFrame& frame);
00111 void handleOut(framing::AMQFrame& frame);
00112
00113
00114 void handleInLast(framing::AMQFrame& frame);
00115 void handleOutLast(framing::AMQFrame& frame);
00116
00117 Broker& broker;
00118 SessionHandler* handler;
00119 sys::AbsTime expiry;
00120 sys::Mutex lock;
00121 bool ignoring;
00122 std::string name;
00123 SemanticState semanticState;
00124 SessionAdapter adapter;
00125 MessageBuilder msgBuilder;
00126 IncompleteMessageList incomplete;
00127 IncompleteMessageList::CompletionListener enqueuedOp;
00128 management::Session* mgmtObject;
00129
00130 friend class SessionManager;
00131 };
00132
00133
00134 inline std::ostream& operator<<(std::ostream& out, const SessionState& session) {
00135 return out << session.getId();
00136 }
00137
00138 }}
00139
00140
00141
00142 #endif