summaryrefslogtreecommitdiff
path: root/cpp/lib/broker
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2007-01-29 16:13:24 +0000
committerAlan Conway <aconway@apache.org>2007-01-29 16:13:24 +0000
commit5a1b8a846bdfa5cb517da0c507f3dc3a8ceec25d (patch)
treef9a982b65400154a86edd02faf75da143a96404c /cpp/lib/broker
parent5d28464c46c1e64ded078a4585f0f49e30b8b5d6 (diff)
downloadqpid-python-5a1b8a846bdfa5cb517da0c507f3dc3a8ceec25d.tar.gz
* Added ClientAdapter - client side ChannelAdapter. Updated client side.
* Moved ChannelAdapter initialization from ctor to init(), updated broker side. * Improved various exception messages with boost::format messages. * Removed unnecssary virtual inheritance. * Widespread: fixed incorrect non-const ProtocolVersion& parameters. * Client API: pass channels by reference, not pointer. * codegen: - MethodBodyClass.h.templ: Added CLASS_ID, METHOD_ID and isA() template. - Various: fixed non-const ProtocolVersion& parameters. * cpp/bootstrap: Allow config arguments with -build. * cpp/gen/Makefile.am: Merged codegen fixes from trunk. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/qpid.0-9@501087 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/lib/broker')
-rw-r--r--cpp/lib/broker/BrokerAdapter.cpp21
-rw-r--r--cpp/lib/broker/BrokerAdapter.h2
-rw-r--r--cpp/lib/broker/BrokerChannel.h1
-rw-r--r--cpp/lib/broker/Connection.cpp1
-rw-r--r--cpp/lib/broker/Content.h2
-rw-r--r--cpp/lib/broker/InMemoryContent.cpp2
-rw-r--r--cpp/lib/broker/InMemoryContent.h2
-rw-r--r--cpp/lib/broker/LazyLoadedContent.cpp2
-rw-r--r--cpp/lib/broker/LazyLoadedContent.h2
9 files changed, 20 insertions, 15 deletions
diff --git a/cpp/lib/broker/BrokerAdapter.cpp b/cpp/lib/broker/BrokerAdapter.cpp
index 585be5f79d..5cf767a8e1 100644
--- a/cpp/lib/broker/BrokerAdapter.cpp
+++ b/cpp/lib/broker/BrokerAdapter.cpp
@@ -212,22 +212,21 @@ void BrokerAdapter::ServerOps::ConnectionHandlerImpl::closeOk(const MethodContex
void BrokerAdapter::ServerOps::ChannelHandlerImpl::open(
const MethodContext& context, const string& /*outOfBand*/){
- // FIXME aconway 2007-01-17: Assertions on all channel methods,
- assertChannelNonZero(channel.getId());
- if (channel.isOpen())
- throw ConnectionException(504, "Channel already open");
channel.open();
- // FIXME aconway 2007-01-04: provide valid channel Id as per ampq 0-9
+ // FIXME aconway 2007-01-04: provide valid ID as per ampq 0-9
connection.client->getChannel().openOk(context, std::string()/* ID */);
}
void BrokerAdapter::ServerOps::ChannelHandlerImpl::flow(const MethodContext&, bool /*active*/){}
void BrokerAdapter::ServerOps::ChannelHandlerImpl::flowOk(const MethodContext&, bool /*active*/){}
-void BrokerAdapter::ServerOps::ChannelHandlerImpl::close(const MethodContext& context, u_int16_t /*replyCode*/, const string& /*replyText*/,
- u_int16_t /*classId*/, u_int16_t /*methodId*/){
+void BrokerAdapter::ServerOps::ChannelHandlerImpl::close(
+ const MethodContext& context, u_int16_t /*replyCode*/,
+ const string& /*replyText*/,
+ u_int16_t /*classId*/, u_int16_t /*methodId*/)
+{
connection.client->getChannel().closeOk(context);
- // FIXME aconway 2007-01-18: Following line destroys this. Ugly.
+ // FIXME aconway 2007-01-18: Following line will "delete this". Ugly.
connection.closeChannel(channel.getId());
}
@@ -499,13 +498,12 @@ BrokerAdapter::ServerOps::ChannelHandlerImpl::resume(
BrokerAdapter::BrokerAdapter(
Channel* ch, Connection& c, Broker& b
) :
- ChannelAdapter(c.getOutput(), ch->getId()),
channel(ch),
connection(c),
broker(b),
serverOps(new ServerOps(*ch,c,b))
{
- assert(ch);
+ init(ch->getId(), c.getOutput(), ch->getVersion());
}
void BrokerAdapter::handleMethodInContext(
@@ -544,6 +542,9 @@ void BrokerAdapter::handleHeartbeat(AMQHeartbeatBody::shared_ptr) {
}
+bool BrokerAdapter::isOpen() const {
+ return channel->isOpen();
+}
}} // namespace qpid::broker
diff --git a/cpp/lib/broker/BrokerAdapter.h b/cpp/lib/broker/BrokerAdapter.h
index 37eba7d52b..339a7f6b48 100644
--- a/cpp/lib/broker/BrokerAdapter.h
+++ b/cpp/lib/broker/BrokerAdapter.h
@@ -52,6 +52,8 @@ class BrokerAdapter : public qpid::framing::ChannelAdapter
void handleContent(boost::shared_ptr<qpid::framing::AMQContentBody>);
void handleHeartbeat(boost::shared_ptr<qpid::framing::AMQHeartbeatBody>);
+ bool isOpen() const;
+
private:
void handleMethodInContext(
boost::shared_ptr<qpid::framing::AMQMethodBody> method,
diff --git a/cpp/lib/broker/BrokerChannel.h b/cpp/lib/broker/BrokerChannel.h
index 7cfb96241d..e578101cfa 100644
--- a/cpp/lib/broker/BrokerChannel.h
+++ b/cpp/lib/broker/BrokerChannel.h
@@ -108,6 +108,7 @@ class Channel : private MessageBuilder::CompletionHandler {
MessageStore* const _store = 0, u_int64_t stagingThreshold = 0);
~Channel();
bool isOpen() const { return opened; }
+ const framing::ProtocolVersion& getVersion() const { return version; }
void open() { opened = true; }
u_int16_t getId() const { return id; }
void setDefaultQueue(Queue::shared_ptr queue){ defaultQueue = queue; }
diff --git a/cpp/lib/broker/Connection.cpp b/cpp/lib/broker/Connection.cpp
index 84bd23b2a7..d34422c93d 100644
--- a/cpp/lib/broker/Connection.cpp
+++ b/cpp/lib/broker/Connection.cpp
@@ -77,6 +77,7 @@ void Connection::initiated(qpid::framing::ProtocolInitiation* header) {
MethodContext(0, &getAdapter(0)),
header->getMajor(), header->getMinor(),
properties, mechanisms, locales);
+ getAdapter(0).init(0, *out, client->getProtocolVersion());
}
void Connection::idleOut(){}
diff --git a/cpp/lib/broker/Content.h b/cpp/lib/broker/Content.h
index 8aacf02959..a793bd8f72 100644
--- a/cpp/lib/broker/Content.h
+++ b/cpp/lib/broker/Content.h
@@ -32,7 +32,7 @@ namespace qpid {
public:
virtual void add(qpid::framing::AMQContentBody::shared_ptr data) = 0;
virtual u_int32_t size() = 0;
- virtual void send(qpid::framing::ProtocolVersion& version, qpid::framing::OutputHandler* out, int channel, u_int32_t framesize) = 0;
+ virtual void send(const qpid::framing::ProtocolVersion& version, qpid::framing::OutputHandler* out, int channel, u_int32_t framesize) = 0;
virtual void encode(qpid::framing::Buffer& buffer) = 0;
virtual void destroy() = 0;
virtual ~Content(){}
diff --git a/cpp/lib/broker/InMemoryContent.cpp b/cpp/lib/broker/InMemoryContent.cpp
index e6db6b0539..12721fe86e 100644
--- a/cpp/lib/broker/InMemoryContent.cpp
+++ b/cpp/lib/broker/InMemoryContent.cpp
@@ -39,7 +39,7 @@ u_int32_t InMemoryContent::size()
return sum;
}
-void InMemoryContent::send(qpid::framing::ProtocolVersion& version, OutputHandler* out, int channel, u_int32_t framesize)
+void InMemoryContent::send(const qpid::framing::ProtocolVersion& version, OutputHandler* out, int channel, u_int32_t framesize)
{
for (content_iterator i = content.begin(); i != content.end(); i++) {
if ((*i)->size() > framesize) {
diff --git a/cpp/lib/broker/InMemoryContent.h b/cpp/lib/broker/InMemoryContent.h
index 1db1acd7e1..72c6b46a7f 100644
--- a/cpp/lib/broker/InMemoryContent.h
+++ b/cpp/lib/broker/InMemoryContent.h
@@ -35,7 +35,7 @@ namespace qpid {
public:
void add(qpid::framing::AMQContentBody::shared_ptr data);
u_int32_t size();
- void send(qpid::framing::ProtocolVersion& version, qpid::framing::OutputHandler* out, int channel, u_int32_t framesize);
+ void send(const qpid::framing::ProtocolVersion& version, qpid::framing::OutputHandler* out, int channel, u_int32_t framesize);
void encode(qpid::framing::Buffer& buffer);
void destroy();
~InMemoryContent(){}
diff --git a/cpp/lib/broker/LazyLoadedContent.cpp b/cpp/lib/broker/LazyLoadedContent.cpp
index 3bf1b374ea..2c7a764ec9 100644
--- a/cpp/lib/broker/LazyLoadedContent.cpp
+++ b/cpp/lib/broker/LazyLoadedContent.cpp
@@ -37,7 +37,7 @@ u_int32_t LazyLoadedContent::size()
return 0;//all content is written as soon as it is added
}
-void LazyLoadedContent::send(qpid::framing::ProtocolVersion& version, OutputHandler* out, int channel, u_int32_t framesize)
+void LazyLoadedContent::send(const qpid::framing::ProtocolVersion& version, OutputHandler* out, int channel, u_int32_t framesize)
{
if (expectedSize > framesize) {
for (u_int64_t offset = 0; offset < expectedSize; offset += framesize) {
diff --git a/cpp/lib/broker/LazyLoadedContent.h b/cpp/lib/broker/LazyLoadedContent.h
index 80f8cce4eb..5322e5e711 100644
--- a/cpp/lib/broker/LazyLoadedContent.h
+++ b/cpp/lib/broker/LazyLoadedContent.h
@@ -34,7 +34,7 @@ namespace qpid {
LazyLoadedContent(MessageStore* const store, Message* const msg, u_int64_t expectedSize);
void add(qpid::framing::AMQContentBody::shared_ptr data);
u_int32_t size();
- void send(qpid::framing::ProtocolVersion& version, qpid::framing::OutputHandler* out, int channel, u_int32_t framesize);
+ void send(const qpid::framing::ProtocolVersion& version, qpid::framing::OutputHandler* out, int channel, u_int32_t framesize);
void encode(qpid::framing::Buffer& buffer);
void destroy();
~LazyLoadedContent(){}