00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _Bridge_
00022 #define _Bridge_
00023
00024 #include "PersistableConfig.h"
00025 #include "qpid/framing/AMQP_ServerProxy.h"
00026 #include "qpid/framing/ChannelHandler.h"
00027 #include "qpid/framing/Buffer.h"
00028 #include "qpid/framing/FrameHandler.h"
00029 #include "qpid/management/Manageable.h"
00030 #include "qmf/org/apache/qpid/broker/ArgsLinkBridge.h"
00031 #include "qmf/org/apache/qpid/broker/Bridge.h"
00032
00033 #include <boost/function.hpp>
00034 #include <memory>
00035
00036 namespace qpid {
00037 namespace broker {
00038
00039 class Connection;
00040 class ConnectionState;
00041 class Link;
00042 class LinkRegistry;
00043
00044 class Bridge : public PersistableConfig, public management::Manageable
00045 {
00046 public:
00047 typedef boost::shared_ptr<Bridge> shared_ptr;
00048 typedef boost::function<void(Bridge*)> CancellationListener;
00049
00050 Bridge(Link* link, framing::ChannelId id, CancellationListener l,
00051 const qmf::org::apache::qpid::broker::ArgsLinkBridge& args);
00052 ~Bridge();
00053
00054 void create(ConnectionState& c);
00055 void cancel();
00056 void destroy();
00057 bool isDurable() { return args.i_durable; }
00058
00059 management::ManagementObject* GetManagementObject() const;
00060 management::Manageable::status_t ManagementMethod(uint32_t methodId,
00061 management::Args& args,
00062 std::string& text);
00063
00064
00065 void setPersistenceId(uint64_t id) const;
00066 uint64_t getPersistenceId() const { return persistenceId; }
00067 uint32_t encodedSize() const;
00068 void encode(framing::Buffer& buffer) const;
00069 const std::string& getName() const;
00070 static Bridge::shared_ptr decode(LinkRegistry& links, framing::Buffer& buffer);
00071
00072 private:
00073 struct PushHandler : framing::FrameHandler {
00074 PushHandler(Connection* c) { conn = c; }
00075 void handle(framing::AMQFrame& frame);
00076 Connection* conn;
00077 };
00078
00079 std::auto_ptr<PushHandler> pushHandler;
00080 std::auto_ptr<framing::ChannelHandler> channelHandler;
00081 std::auto_ptr<framing::AMQP_ServerProxy::Session> session;
00082 std::auto_ptr<framing::AMQP_ServerProxy> peer;
00083
00084 Link* link;
00085 framing::ChannelId id;
00086 qmf::org::apache::qpid::broker::ArgsLinkBridge args;
00087 qmf::org::apache::qpid::broker::Bridge* mgmtObject;
00088 CancellationListener listener;
00089 std::string name;
00090 mutable uint64_t persistenceId;
00091 };
00092
00093
00094 }}
00095
00096 #endif