diff options
author | Alan Conway <aconway@apache.org> | 2006-10-16 13:50:26 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2006-10-16 13:50:26 +0000 |
commit | 8a6ab3aa61d441b9210c05c84dc9998acfc38737 (patch) | |
tree | 1eb9d7f39b5c2d04a85a1f66caef3d398567b740 /cpp/broker/inc | |
parent | 9a808fb13aba243d41bbdab75158dae5939a80a4 (diff) | |
download | qpid-python-8a6ab3aa61d441b9210c05c84dc9998acfc38737.tar.gz |
Build system reorg, see README and Makefile comments for details.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@464494 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/broker/inc')
-rw-r--r-- | cpp/broker/inc/AutoDelete.h | 54 | ||||
-rw-r--r-- | cpp/broker/inc/Binding.h | 35 | ||||
-rw-r--r-- | cpp/broker/inc/Broker.h | 86 | ||||
-rw-r--r-- | cpp/broker/inc/Channel.h | 199 | ||||
-rw-r--r-- | cpp/broker/inc/Configuration.h | 135 | ||||
-rw-r--r-- | cpp/broker/inc/ConnectionToken.h | 35 | ||||
-rw-r--r-- | cpp/broker/inc/Consumer.h | 34 | ||||
-rw-r--r-- | cpp/broker/inc/DirectExchange.h | 52 | ||||
-rw-r--r-- | cpp/broker/inc/Exchange.h | 41 | ||||
-rw-r--r-- | cpp/broker/inc/ExchangeBinding.h | 45 | ||||
-rw-r--r-- | cpp/broker/inc/ExchangeRegistry.h | 44 | ||||
-rw-r--r-- | cpp/broker/inc/FanOutExchange.h | 55 | ||||
-rw-r--r-- | cpp/broker/inc/HeadersExchange.h | 60 | ||||
-rw-r--r-- | cpp/broker/inc/Message.h | 89 | ||||
-rw-r--r-- | cpp/broker/inc/NameGenerator.h | 36 | ||||
-rw-r--r-- | cpp/broker/inc/Queue.h | 106 | ||||
-rw-r--r-- | cpp/broker/inc/QueueRegistry.h | 88 | ||||
-rw-r--r-- | cpp/broker/inc/Router.h | 39 | ||||
-rw-r--r-- | cpp/broker/inc/SessionHandlerFactoryImpl.h | 49 | ||||
-rw-r--r-- | cpp/broker/inc/SessionHandlerImpl.h | 233 | ||||
-rw-r--r-- | cpp/broker/inc/TopicExchange.h | 94 |
21 files changed, 0 insertions, 1609 deletions
diff --git a/cpp/broker/inc/AutoDelete.h b/cpp/broker/inc/AutoDelete.h deleted file mode 100644 index 864d68358f..0000000000 --- a/cpp/broker/inc/AutoDelete.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * - * Copyright (c) 2006 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -#ifndef _AutoDelete_ -#define _AutoDelete_ - -#include <iostream> -#include <queue> -#include "MonitorImpl.h" -#include "Queue.h" -#include "QueueRegistry.h" -#include "ThreadFactoryImpl.h" - -namespace qpid { - namespace broker{ - class AutoDelete : private virtual qpid::concurrent::Runnable{ - qpid::concurrent::ThreadFactoryImpl factory; - qpid::concurrent::MonitorImpl lock; - qpid::concurrent::MonitorImpl monitor; - std::queue<Queue::shared_ptr> queues; - QueueRegistry* const registry; - const u_int32_t period; - volatile bool stopped; - qpid::concurrent::Thread* runner; - - Queue::shared_ptr const pop(); - void process(); - virtual void run(); - - public: - AutoDelete(QueueRegistry* const registry, u_int32_t period); - void add(Queue::shared_ptr const); - void start(); - void stop(); - }; - } -} - - -#endif diff --git a/cpp/broker/inc/Binding.h b/cpp/broker/inc/Binding.h deleted file mode 100644 index b11419e92c..0000000000 --- a/cpp/broker/inc/Binding.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * Copyright (c) 2006 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -#ifndef _Binding_ -#define _Binding_ - -#include "FieldTable.h" - -namespace qpid { - namespace broker { - class Binding{ - public: - virtual void cancel() = 0; - virtual ~Binding(){} - }; - } -} - - -#endif - diff --git a/cpp/broker/inc/Broker.h b/cpp/broker/inc/Broker.h deleted file mode 100644 index 0cd2bd749e..0000000000 --- a/cpp/broker/inc/Broker.h +++ /dev/null @@ -1,86 +0,0 @@ -#ifndef _Broker_ -#define _Broker_ - -/* - * - * Copyright (c) 2006 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include "Acceptor.h" -#include "Configuration.h" -#include "Runnable.h" -#include "SessionHandlerFactoryImpl.h" -#include <boost/noncopyable.hpp> -#include <tr1/memory> - -namespace qpid { - namespace broker { - /** - * A broker instance. - */ - class Broker : public qpid::concurrent::Runnable, private boost::noncopyable { - Broker(const Configuration& config); // Private, use create() - std::auto_ptr<qpid::io::Acceptor> acceptor; - SessionHandlerFactoryImpl factory; - int16_t port; - bool isBound; - - public: - static const int16_t DEFAULT_PORT; - - virtual ~Broker(); - typedef std::tr1::shared_ptr<Broker> shared_ptr; - - /** - * Create a broker. - * @param port Port to listen on or 0 to pick a port dynamically. - */ - static shared_ptr create(int port = DEFAULT_PORT); - - /** - * Create a broker from a Configuration. - */ - static shared_ptr create(const Configuration& config); - - /** - * Bind to the listening port. - * @return The port number bound. - */ - virtual int16_t bind(); - - /** - * Return listening port. If called before bind this is - * the configured port. If called after it is the actual - * port, which will be different if the configured port is - * 0. - */ - virtual int16_t getPort() { return port; } - - /** - * Run the broker. Implements Runnable::run() so the broker - * can be run in a separate thread. - */ - virtual void run(); - - /** Shut down the broker */ - virtual void shutdown(); - }; - } -} - - - -#endif /*!_Broker_*/ diff --git a/cpp/broker/inc/Channel.h b/cpp/broker/inc/Channel.h deleted file mode 100644 index 862d249ce1..0000000000 --- a/cpp/broker/inc/Channel.h +++ /dev/null @@ -1,199 +0,0 @@ -/* - * - * Copyright (c) 2006 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -#ifndef _Channel_ -#define _Channel_ - -#include <algorithm> -#include <map> -#include "AMQContentBody.h" -#include "AMQHeaderBody.h" -#include "BasicPublishBody.h" -#include "Binding.h" -#include "Consumer.h" -#include "Message.h" -#include "MonitorImpl.h" -#include "NameGenerator.h" -#include "OutputHandler.h" -#include "Queue.h" - -namespace qpid { - namespace broker { - /** - * Maintains state for an AMQP channel. Handles incoming and - * outgoing messages for that channel. - */ - class Channel{ - private: - class ConsumerImpl : public virtual Consumer{ - Channel* parent; - string tag; - Queue::shared_ptr queue; - ConnectionToken* const connection; - const bool ackExpected; - bool blocked; - public: - ConsumerImpl(Channel* parent, string& tag, Queue::shared_ptr queue, ConnectionToken* const connection, bool ack); - virtual bool deliver(Message::shared_ptr& msg); - void cancel(); - void requestDispatch(); - }; - - typedef std::map<string,ConsumerImpl*>::iterator consumer_iterator; - - struct AckRecord{ - Message::shared_ptr msg; - Queue::shared_ptr queue; - string consumerTag; - u_int64_t deliveryTag; - bool pull; - - AckRecord(Message::shared_ptr _msg, - Queue::shared_ptr _queue, - const string _consumerTag, - const u_int64_t _deliveryTag) : msg(_msg), - queue(_queue), - consumerTag(_consumerTag), - deliveryTag(_deliveryTag), - pull(false){} - - AckRecord(Message::shared_ptr _msg, - Queue::shared_ptr _queue, - const u_int64_t _deliveryTag) : msg(_msg), - queue(_queue), - consumerTag(""), - deliveryTag(_deliveryTag), - pull(true){} - }; - - typedef std::vector<AckRecord>::iterator ack_iterator; - - class MatchAck{ - const u_int64_t tag; - public: - MatchAck(u_int64_t tag); - bool operator()(AckRecord& record) const; - }; - - class Requeue{ - public: - void operator()(AckRecord& record) const; - }; - - class Redeliver{ - Channel* const channel; - public: - Redeliver(Channel* const channel); - void operator()(AckRecord& record) const; - }; - - class CalculatePrefetch{ - u_int32_t size; - u_int16_t count; - public: - CalculatePrefetch(); - void operator()(AckRecord& record); - u_int32_t getSize(); - u_int16_t getCount(); - }; - - const int id; - qpid::framing::OutputHandler* out; - u_int64_t deliveryTag; - Queue::shared_ptr defaultQueue; - bool transactional; - std::map<string, ConsumerImpl*> consumers; - u_int32_t prefetchSize; - u_int16_t prefetchCount; - u_int32_t outstandingSize; - u_int16_t outstandingCount; - u_int32_t framesize; - Message::shared_ptr message; - NameGenerator tagGenerator; - std::vector<AckRecord> unacknowledged; - qpid::concurrent::MonitorImpl deliveryLock; - - void deliver(Message::shared_ptr& msg, string& tag, Queue::shared_ptr& queue, bool ackExpected); - void checkMessage(const std::string& text); - bool checkPrefetch(Message::shared_ptr& msg); - void cancel(consumer_iterator consumer); - - template<class Operation> Operation processMessage(Operation route){ - if(message->isComplete()){ - route(message); - message.reset(); - } - return route; - } - - - public: - Channel(qpid::framing::OutputHandler* out, int id, u_int32_t framesize); - ~Channel(); - inline void setDefaultQueue(Queue::shared_ptr queue){ defaultQueue = queue; } - inline Queue::shared_ptr getDefaultQueue(){ return defaultQueue; } - inline u_int32_t setPrefetchSize(u_int32_t size){ return prefetchSize = size; } - inline u_int16_t setPrefetchCount(u_int16_t count){ return prefetchCount = count; } - bool exists(const string& consumerTag); - void consume(string& tag, Queue::shared_ptr queue, bool acks, bool exclusive, ConnectionToken* const connection = 0); - void cancel(const string& tag); - bool get(Queue::shared_ptr queue, bool ackExpected); - void begin(); - void close(); - void commit(); - void rollback(); - void ack(u_int64_t deliveryTag, bool multiple); - void recover(bool requeue); - - /** - * Handles the initial publish request though a - * channel. The header and (if applicable) content will be - * accumulated through calls to handleHeader() and - * handleContent() - */ - void handlePublish(Message* msg); - - /** - * A template method that handles a received header and if - * there is no content routes it using the functor passed - * in. - */ - template<class Operation> Operation handleHeader(qpid::framing::AMQHeaderBody::shared_ptr header, Operation route){ - checkMessage("Invalid message sequence: got header before publish."); - message->setHeader(header); - return processMessage(route); - } - - /** - * A template method that handles a received content and - * if this completes the message, routes it using the - * functor passed in. - */ - template<class Operation> Operation handleContent(qpid::framing::AMQContentBody::shared_ptr content, Operation route){ - checkMessage("Invalid message sequence: got content before publish."); - message->addContent(content); - return processMessage(route); - } - - }; - - struct InvalidAckException{}; - } -} - - -#endif diff --git a/cpp/broker/inc/Configuration.h b/cpp/broker/inc/Configuration.h deleted file mode 100644 index aaabdd23a0..0000000000 --- a/cpp/broker/inc/Configuration.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - * - * Copyright (c) 2006 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -#ifndef _Configuration_ -#define _Configuration_ - -#include <cstdlib> -#include <iostream> -#include <vector> -#include "Exception.h" - -namespace qpid { - namespace broker { - class Configuration{ - class Option { - const std::string flag; - const std::string name; - const std::string desc; - - bool match(const std::string& arg); - - protected: - virtual bool needsValue() const = 0; - virtual void setValue(const std::string& value) = 0; - - public: - Option(const char flag, const std::string& name, const std::string& desc); - Option(const std::string& name, const std::string& desc); - virtual ~Option(); - - bool parse(int& i, char** argv, int argc); - void print(std::ostream& out) const; - }; - - class IntOption : public Option{ - const int defaultValue; - int value; - public: - IntOption(char flag, const std::string& name, const std::string& desc, const int value = 0); - IntOption(const std::string& name, const std::string& desc, const int value = 0); - virtual ~IntOption(); - - int getValue() const; - virtual bool needsValue() const; - virtual void setValue(const std::string& value); - virtual void setValue(int _value) { value = _value; } - }; - - class StringOption : public Option{ - const std::string defaultValue; - std::string value; - public: - StringOption(char flag, const std::string& name, const std::string& desc, const std::string value = ""); - StringOption(const std::string& name, const std::string& desc, const std::string value = ""); - virtual ~StringOption(); - - const std::string& getValue() const; - virtual bool needsValue() const; - virtual void setValue(const std::string& value); - }; - - class BoolOption : public Option{ - const bool defaultValue; - bool value; - public: - BoolOption(char flag, const std::string& name, const std::string& desc, const bool value = 0); - BoolOption(const std::string& name, const std::string& desc, const bool value = 0); - virtual ~BoolOption(); - - bool getValue() const; - virtual bool needsValue() const; - virtual void setValue(const std::string& value); - virtual void setValue(bool _value) { value = _value; } - }; - - BoolOption trace; - IntOption port; - IntOption workerThreads; - IntOption maxConnections; - IntOption connectionBacklog; - StringOption acceptor; - BoolOption help; - - typedef std::vector<Option*>::iterator op_iterator; - std::vector<Option*> options; - - public: - class ParseException : public Exception { - public: - ParseException(const std::string& msg) : Exception(msg) {} - }; - - - Configuration(); - ~Configuration(); - - void parse(int argc, char** argv); - - bool isHelp() const; - bool isTrace() const; - int getPort() const; - int getWorkerThreads() const; - int getMaxConnections() const; - int getConnectionBacklog() const; - std::string getAcceptor() const; - - void setHelp(bool b) { help.setValue(b); } - void setTrace(bool b) { trace.setValue(b); } - void setPort(int i) { port.setValue(i); } - void setWorkerThreads(int i) { workerThreads.setValue(i); } - void setMaxConnections(int i) { maxConnections.setValue(i); } - void setConnectionBacklog(int i) { connectionBacklog.setValue(i); } - void setAcceptor(const std::string& val) { acceptor.setValue(val); } - - void usage(); - }; - } -} - - -#endif diff --git a/cpp/broker/inc/ConnectionToken.h b/cpp/broker/inc/ConnectionToken.h deleted file mode 100644 index 1faefec2cc..0000000000 --- a/cpp/broker/inc/ConnectionToken.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * Copyright (c) 2006 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -#ifndef _ConnectionToken_ -#define _ConnectionToken_ - -namespace qpid { - namespace broker { - /** - * An empty interface allowing opaque implementations of some - * form of token to identify a connection. - */ - class ConnectionToken{ - public: - virtual ~ConnectionToken(){} - }; - } -} - - -#endif diff --git a/cpp/broker/inc/Consumer.h b/cpp/broker/inc/Consumer.h deleted file mode 100644 index af2d5d7812..0000000000 --- a/cpp/broker/inc/Consumer.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * - * Copyright (c) 2006 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -#ifndef _Consumer_ -#define _Consumer_ - -#include "Message.h" - -namespace qpid { - namespace broker { - class Consumer{ - public: - virtual bool deliver(Message::shared_ptr& msg) = 0; - virtual ~Consumer(){} - }; - } -} - - -#endif diff --git a/cpp/broker/inc/DirectExchange.h b/cpp/broker/inc/DirectExchange.h deleted file mode 100644 index faf5a0b949..0000000000 --- a/cpp/broker/inc/DirectExchange.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * - * Copyright (c) 2006 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -#ifndef _DirectExchange_ -#define _DirectExchange_ - -#include <map> -#include <vector> -#include "Exchange.h" -#include "FieldTable.h" -#include "Message.h" -#include "MonitorImpl.h" -#include "Queue.h" - -namespace qpid { -namespace broker { - class DirectExchange : public virtual Exchange{ - std::map<string, std::vector<Queue::shared_ptr> > bindings; - qpid::concurrent::MonitorImpl lock; - - public: - static const std::string typeName; - - DirectExchange(const std::string& name); - - virtual void bind(Queue::shared_ptr queue, const std::string& routingKey, qpid::framing::FieldTable* args); - - virtual void unbind(Queue::shared_ptr queue, const std::string& routingKey, qpid::framing::FieldTable* args); - - virtual void route(Message::shared_ptr& msg, const std::string& routingKey, qpid::framing::FieldTable* args); - - virtual ~DirectExchange(); - }; -} -} - - -#endif diff --git a/cpp/broker/inc/Exchange.h b/cpp/broker/inc/Exchange.h deleted file mode 100644 index 1fdc00fae5..0000000000 --- a/cpp/broker/inc/Exchange.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * - * Copyright (c) 2006 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -#ifndef _Exchange_ -#define _Exchange_ - -#include "FieldTable.h" -#include "Message.h" -#include "Queue.h" - -namespace qpid { -namespace broker { - class Exchange{ - const std::string name; - public: - explicit Exchange(const std::string& _name) : name(_name) {} - virtual ~Exchange(){} - std::string getName() { return name; } - virtual void bind(Queue::shared_ptr queue, const string& routingKey, qpid::framing::FieldTable* args) = 0; - virtual void unbind(Queue::shared_ptr queue, const string& routingKey, qpid::framing::FieldTable* args) = 0; - virtual void route(Message::shared_ptr& msg, const string& routingKey, qpid::framing::FieldTable* args) = 0; - }; -} -} - - -#endif diff --git a/cpp/broker/inc/ExchangeBinding.h b/cpp/broker/inc/ExchangeBinding.h deleted file mode 100644 index 4cbb73acbf..0000000000 --- a/cpp/broker/inc/ExchangeBinding.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * - * Copyright (c) 2006 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -#ifndef _ExchangeBinding_ -#define _ExchangeBinding_ - -#include "Binding.h" -#include "FieldTable.h" -#include "Queue.h" - -namespace qpid { - namespace broker { - class Exchange; - class Queue; - - class ExchangeBinding : public virtual Binding{ - Exchange* e; - Queue::shared_ptr q; - const string key; - qpid::framing::FieldTable* args; - public: - ExchangeBinding(Exchange* _e, Queue::shared_ptr _q, const string& _key, qpid::framing::FieldTable* _args); - virtual void cancel(); - virtual ~ExchangeBinding(); - }; - } -} - - -#endif - diff --git a/cpp/broker/inc/ExchangeRegistry.h b/cpp/broker/inc/ExchangeRegistry.h deleted file mode 100644 index a4a778482c..0000000000 --- a/cpp/broker/inc/ExchangeRegistry.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * - * Copyright (c) 2006 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -#ifndef _ExchangeRegistry_ -#define _ExchangeRegistry_ - -#include <map> -#include "Exchange.h" -#include "Monitor.h" - -namespace qpid { -namespace broker { - class ExchangeRegistry{ - typedef std::map<string, Exchange*> ExchangeMap; - ExchangeMap exchanges; - qpid::concurrent::Monitor* lock; - public: - ExchangeRegistry(); - void declare(Exchange* exchange); - void destroy(const string& name); - Exchange* get(const string& name); - Exchange* getDefault(); - inline qpid::concurrent::Monitor* getLock(){ return lock; } - ~ExchangeRegistry(); - }; -} -} - - -#endif diff --git a/cpp/broker/inc/FanOutExchange.h b/cpp/broker/inc/FanOutExchange.h deleted file mode 100644 index 1932e8429c..0000000000 --- a/cpp/broker/inc/FanOutExchange.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * - * Copyright (c) 2006 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -#ifndef _FanOutExchange_ -#define _FanOutExchange_ - -#include <map> -#include <vector> -#include "Exchange.h" -#include "FieldTable.h" -#include "Message.h" -#include "MonitorImpl.h" -#include "Queue.h" - -namespace qpid { -namespace broker { - -class FanOutExchange : public virtual Exchange { - std::vector<Queue::shared_ptr> bindings; - qpid::concurrent::MonitorImpl lock; - - public: - static const std::string typeName; - - FanOutExchange(const std::string& name); - - virtual void bind(Queue::shared_ptr queue, const std::string& routingKey, qpid::framing::FieldTable* args); - - virtual void unbind(Queue::shared_ptr queue, const std::string& routingKey, qpid::framing::FieldTable* args); - - virtual void route(Message::shared_ptr& msg, const std::string& routingKey, qpid::framing::FieldTable* args); - - virtual ~FanOutExchange(); -}; - -} -} - - - -#endif diff --git a/cpp/broker/inc/HeadersExchange.h b/cpp/broker/inc/HeadersExchange.h deleted file mode 100644 index 08bf0bb735..0000000000 --- a/cpp/broker/inc/HeadersExchange.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * - * Copyright (c) 2006 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -#ifndef _HeadersExchange_ -#define _HeadersExchange_ - -#include <vector> -#include "Exchange.h" -#include "FieldTable.h" -#include "Message.h" -#include "MonitorImpl.h" -#include "Queue.h" - -namespace qpid { -namespace broker { - - -class HeadersExchange : public virtual Exchange { - typedef std::pair<qpid::framing::FieldTable, Queue::shared_ptr> Binding; - typedef std::vector<Binding> Bindings; - - Bindings bindings; - qpid::concurrent::MonitorImpl lock; - - public: - static const std::string typeName; - - HeadersExchange(const string& name); - - virtual void bind(Queue::shared_ptr queue, const string& routingKey, qpid::framing::FieldTable* args); - - virtual void unbind(Queue::shared_ptr queue, const string& routingKey, qpid::framing::FieldTable* args); - - virtual void route(Message::shared_ptr& msg, const string& routingKey, qpid::framing::FieldTable* args); - - virtual ~HeadersExchange(); - - static bool match(const qpid::framing::FieldTable& bindArgs, const qpid::framing::FieldTable& msgArgs); -}; - - - -} -} - -#endif diff --git a/cpp/broker/inc/Message.h b/cpp/broker/inc/Message.h deleted file mode 100644 index 94b9aa5bdd..0000000000 --- a/cpp/broker/inc/Message.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * - * Copyright (c) 2006 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -#ifndef _Message_ -#define _Message_ - -#include "memory.h" -#include "AMQContentBody.h" -#include "AMQHeaderBody.h" -#include "BasicHeaderProperties.h" -#include "BasicPublishBody.h" -#include "ConnectionToken.h" -#include "OutputHandler.h" - -namespace qpid { - namespace broker { - class ExchangeRegistry; - - /** - * Represents an AMQP message, i.e. a header body, a list of - * content bodies and some details about the publication - * request. - */ - class Message{ - typedef std::vector<qpid::framing::AMQContentBody::shared_ptr> content_list; - typedef content_list::iterator content_iterator; - - const ConnectionToken* const publisher; - const string exchange; - const string routingKey; - const bool mandatory; - const bool immediate; - bool redelivered; - qpid::framing::AMQHeaderBody::shared_ptr header; - content_list content; - u_int64_t size; - - void sendContent(qpid::framing::OutputHandler* out, - int channel, u_int32_t framesize); - - public: - typedef std::tr1::shared_ptr<Message> shared_ptr; - - Message(const ConnectionToken* const publisher, - const string& exchange, const string& routingKey, - bool mandatory, bool immediate); - ~Message(); - void setHeader(qpid::framing::AMQHeaderBody::shared_ptr header); - void addContent(qpid::framing::AMQContentBody::shared_ptr data); - bool isComplete(); - const ConnectionToken* const getPublisher(); - - void deliver(qpid::framing::OutputHandler* out, - int channel, - const string& consumerTag, - u_int64_t deliveryTag, - u_int32_t framesize); - void sendGetOk(qpid::framing::OutputHandler* out, - int channel, - u_int32_t messageCount, - u_int64_t deliveryTag, - u_int32_t framesize); - void redeliver(); - - qpid::framing::BasicHeaderProperties* getHeaderProperties(); - const string& getRoutingKey() const { return routingKey; } - const string& getExchange() const { return exchange; } - u_int64_t contentSize() const{ return size; } - - }; - } -} - - -#endif diff --git a/cpp/broker/inc/NameGenerator.h b/cpp/broker/inc/NameGenerator.h deleted file mode 100644 index 6e6e0acf28..0000000000 --- a/cpp/broker/inc/NameGenerator.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * - * Copyright (c) 2006 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -#ifndef _NameGenerator_ -#define _NameGenerator_ - -#include "Message.h" - -namespace qpid { - namespace broker { - class NameGenerator{ - const std::string base; - unsigned int counter; - public: - NameGenerator(const std::string& base); - std::string generate(); - }; - } -} - - -#endif diff --git a/cpp/broker/inc/Queue.h b/cpp/broker/inc/Queue.h deleted file mode 100644 index 2229ba6235..0000000000 --- a/cpp/broker/inc/Queue.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * - * Copyright (c) 2006 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -#ifndef _Queue_ -#define _Queue_ - -#include <vector> -#include <queue> -#include "memory.h" -#include "apr_time.h" -#include "amqp_types.h" -#include "Binding.h" -#include "ConnectionToken.h" -#include "Consumer.h" -#include "Message.h" -#include "MonitorImpl.h" - -namespace qpid { - namespace broker { - - /** - * Thrown when exclusive access would be violated. - */ - struct ExclusiveAccessException{}; - - /** - * The brokers representation of an amqp queue. Messages are - * delivered to a queue from where they can be dispatched to - * registered consumers or be stored until dequeued or until one - * or more consumers registers. - */ - class Queue{ - const string name; - const u_int32_t autodelete; - const bool durable; - const ConnectionToken* const owner; - std::vector<Consumer*> consumers; - std::queue<Binding*> bindings; - std::queue<Message::shared_ptr> messages; - bool queueing; - bool dispatching; - int next; - mutable qpid::concurrent::MonitorImpl lock; - apr_time_t lastUsed; - Consumer* exclusive; - - bool startDispatching(); - bool dispatch(Message::shared_ptr& msg); - - public: - - typedef std::tr1::shared_ptr<Queue> shared_ptr; - - typedef std::vector<shared_ptr> vector; - - Queue(const string& name, bool durable = false, u_int32_t autodelete = 0, const ConnectionToken* const owner = 0); - ~Queue(); - /** - * Informs the queue of a binding that should be cancelled on - * destruction of the queue. - */ - void bound(Binding* b); - /** - * Delivers a message to the queue from where it will be - * dispatched to immediately to a consumer if one is - * available or stored for dequeue or later dispatch if - * not. - */ - void deliver(Message::shared_ptr& msg); - /** - * Dispatch any queued messages providing there are - * consumers for them. Only one thread can be dispatching - * at any time, but this method (rather than the caller) - * is responsible for ensuring that. - */ - void dispatch(); - void consume(Consumer* c, bool exclusive = false); - void cancel(Consumer* c); - Message::shared_ptr dequeue(); - u_int32_t purge(); - u_int32_t getMessageCount() const; - u_int32_t getConsumerCount() const; - inline const string& getName() const { return name; } - inline const bool isExclusiveOwner(const ConnectionToken* const o) const { return o == owner; } - inline bool hasExclusiveConsumer() const { return exclusive; } - bool canAutoDelete() const; - }; - } -} - - -#endif diff --git a/cpp/broker/inc/QueueRegistry.h b/cpp/broker/inc/QueueRegistry.h deleted file mode 100644 index ac12aa8f88..0000000000 --- a/cpp/broker/inc/QueueRegistry.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * - * Copyright (c) 2006 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -#ifndef _QueueRegistry_ -#define _QueueRegistry_ - -#include <map> -#include "MonitorImpl.h" -#include "Queue.h" - -namespace qpid { -namespace broker { - -class SessionHandlerImpl; - -/** - * A registry of queues indexed by queue name. - * - * Queues are reference counted using shared_ptr to ensure that they - * are deleted when and only when they are no longer in use. - * - */ -class QueueRegistry{ - - public: - QueueRegistry(); - ~QueueRegistry(); - - /** - * Declare a queue. - * - * @return The queue and a boolean flag which is true if the queue - * was created by this declare call false if it already existed. - */ - std::pair<Queue::shared_ptr, bool> declare(const string& name, bool durable = false, u_int32_t autodelete = 0, const ConnectionToken* const owner = 0); - - /** - * Destroy the named queue. - * - * Note: if the queue is in use it is not actually destroyed until - * all shared_ptrs to it are destroyed. During that time it is - * possible that a new queue with the same name may be - * created. This should not create any problems as the new and - * old queues exist independently. The registry has - * forgotten the old queue so there can be no confusion for - * subsequent calls to find or declare with the same name. - * - */ - void destroy(const string& name); - - /** - * Find the named queue. Return 0 if not found. - */ - Queue::shared_ptr find(const string& name); - - /** - * Generate unique queue name. - */ - string generateName(); - - private: - typedef std::map<string, Queue::shared_ptr> QueueMap; - QueueMap queues; - qpid::concurrent::MonitorImpl lock; - int counter; - -}; - - -} -} - - -#endif diff --git a/cpp/broker/inc/Router.h b/cpp/broker/inc/Router.h deleted file mode 100644 index d462b69832..0000000000 --- a/cpp/broker/inc/Router.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * - * Copyright (c) 2006 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -#ifndef _Router_ -#define _Router_ - -#include "ExchangeRegistry.h" -#include "Message.h" - -/** - * A routing functor - */ -namespace qpid { - namespace broker { - class Router{ - ExchangeRegistry& registry; - public: - Router(ExchangeRegistry& registry); - void operator()(Message::shared_ptr& msg); - }; - } -} - - -#endif diff --git a/cpp/broker/inc/SessionHandlerFactoryImpl.h b/cpp/broker/inc/SessionHandlerFactoryImpl.h deleted file mode 100644 index 2317a6667b..0000000000 --- a/cpp/broker/inc/SessionHandlerFactoryImpl.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * - * Copyright (c) 2006 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -#ifndef _SessionHandlerFactoryImpl_ -#define _SessionHandlerFactoryImpl_ - -#include "AMQFrame.h" -#include "AutoDelete.h" -#include "DirectExchange.h" -#include "ExchangeRegistry.h" -#include "ProtocolInitiation.h" -#include "QueueRegistry.h" -#include "SessionHandlerFactory.h" -#include "TimeoutHandler.h" - -namespace qpid { - namespace broker { - - class SessionHandlerFactoryImpl : public virtual qpid::io::SessionHandlerFactory - { - QueueRegistry queues; - ExchangeRegistry exchanges; - const u_int32_t timeout;//timeout for auto-deleted queues (in ms) - AutoDelete cleaner; - public: - SessionHandlerFactoryImpl(u_int32_t timeout = 30000); - virtual qpid::io::SessionHandler* create(qpid::io::SessionContext* ctxt); - virtual ~SessionHandlerFactoryImpl(); - }; - - } -} - - -#endif diff --git a/cpp/broker/inc/SessionHandlerImpl.h b/cpp/broker/inc/SessionHandlerImpl.h deleted file mode 100644 index 549f51f5a1..0000000000 --- a/cpp/broker/inc/SessionHandlerImpl.h +++ /dev/null @@ -1,233 +0,0 @@ -/* - * - * Copyright (c) 2006 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -#ifndef _SessionHandlerImpl_ -#define _SessionHandlerImpl_ - -#include <map> -#include <sstream> -#include <vector> -#include <exception> -#include "AMQFrame.h" -#include "AMQP_ClientProxy.h" -#include "AMQP_ServerOperations.h" -#include "AutoDelete.h" -#include "ExchangeRegistry.h" -#include "Channel.h" -#include "ConnectionToken.h" -#include "DirectExchange.h" -#include "OutputHandler.h" -#include "ProtocolInitiation.h" -#include "QueueRegistry.h" -#include "SessionContext.h" -#include "SessionHandler.h" -#include "TimeoutHandler.h" -#include "TopicExchange.h" - -namespace qpid { -namespace broker { - -struct ChannelException : public std::exception { - u_int16_t code; - string text; - ChannelException(u_int16_t _code, string _text) : code(_code), text(_text) {} - ~ChannelException() throw() {} - const char* what() const throw() { return text.c_str(); } -}; - -struct ConnectionException : public std::exception { - u_int16_t code; - string text; - ConnectionException(u_int16_t _code, string _text) : code(_code), text(_text) {} - ~ConnectionException() throw() {} - const char* what() const throw() { return text.c_str(); } -}; - -class SessionHandlerImpl : public virtual qpid::io::SessionHandler, - public virtual qpid::framing::AMQP_ServerOperations, - public virtual ConnectionToken -{ - typedef std::map<u_int16_t, Channel*>::iterator channel_iterator; - typedef std::vector<Queue::shared_ptr>::iterator queue_iterator; - - qpid::io::SessionContext* context; - qpid::framing::AMQP_ClientProxy client; - QueueRegistry* queues; - ExchangeRegistry* const exchanges; - AutoDelete* const cleaner; - const u_int32_t timeout;//timeout for auto-deleted queues (in ms) - - ConnectionHandler* connectionHandler; - ChannelHandler* channelHandler; - BasicHandler* basicHandler; - ExchangeHandler* exchangeHandler; - QueueHandler* queueHandler; - - std::map<u_int16_t, Channel*> channels; - std::vector<Queue::shared_ptr> exclusiveQueues; - - u_int32_t framemax; - u_int16_t heartbeat; - - void handleHeader(u_int16_t channel, qpid::framing::AMQHeaderBody::shared_ptr body); - void handleContent(u_int16_t channel, qpid::framing::AMQContentBody::shared_ptr body); - void handleHeartbeat(qpid::framing::AMQHeartbeatBody::shared_ptr body); - - Channel* getChannel(u_int16_t channel); - /** - * Get named queue, never returns 0. - * @return: named queue or default queue for channel if name="" - * @exception: ChannelException if no queue of that name is found. - * @exception: ConnectionException if no queue specified and channel has not declared one. - */ - Queue::shared_ptr getQueue(const string& name, u_int16_t channel); - - Exchange* findExchange(const string& name); - - public: - SessionHandlerImpl(qpid::io::SessionContext* context, QueueRegistry* queues, - ExchangeRegistry* exchanges, AutoDelete* cleaner, const u_int32_t timeout); - virtual void received(qpid::framing::AMQFrame* frame); - virtual void initiated(qpid::framing::ProtocolInitiation* header); - virtual void idleOut(); - virtual void idleIn(); - virtual void closed(); - virtual ~SessionHandlerImpl(); - - class ConnectionHandlerImpl : public virtual ConnectionHandler{ - SessionHandlerImpl* parent; - public: - inline ConnectionHandlerImpl(SessionHandlerImpl* _parent) : parent(_parent) {} - - virtual void startOk(u_int16_t channel, qpid::framing::FieldTable& clientProperties, string& mechanism, - string& response, string& locale); - - virtual void secureOk(u_int16_t channel, string& response); - - virtual void tuneOk(u_int16_t channel, u_int16_t channelMax, u_int32_t frameMax, u_int16_t heartbeat); - - virtual void open(u_int16_t channel, string& virtualHost, string& capabilities, bool insist); - - virtual void close(u_int16_t channel, u_int16_t replyCode, string& replyText, u_int16_t classId, - u_int16_t methodId); - - virtual void closeOk(u_int16_t channel); - - virtual ~ConnectionHandlerImpl(){} - }; - - class ChannelHandlerImpl : public virtual ChannelHandler{ - SessionHandlerImpl* parent; - public: - inline ChannelHandlerImpl(SessionHandlerImpl* _parent) : parent(_parent) {} - - virtual void open(u_int16_t channel, string& outOfBand); - - virtual void flow(u_int16_t channel, bool active); - - virtual void flowOk(u_int16_t channel, bool active); - - virtual void close(u_int16_t channel, u_int16_t replyCode, string& replyText, - u_int16_t classId, u_int16_t methodId); - - virtual void closeOk(u_int16_t channel); - - virtual ~ChannelHandlerImpl(){} - }; - - class ExchangeHandlerImpl : public virtual ExchangeHandler{ - SessionHandlerImpl* parent; - public: - inline ExchangeHandlerImpl(SessionHandlerImpl* _parent) : parent(_parent) {} - - virtual void declare(u_int16_t channel, u_int16_t ticket, string& exchange, string& type, - bool passive, bool durable, bool autoDelete, bool internal, bool nowait, - qpid::framing::FieldTable& arguments); - - virtual void delete_(u_int16_t channel, u_int16_t ticket, string& exchange, bool ifUnused, bool nowait); - - virtual ~ExchangeHandlerImpl(){} - }; - - - class QueueHandlerImpl : public virtual QueueHandler{ - SessionHandlerImpl* parent; - public: - inline QueueHandlerImpl(SessionHandlerImpl* _parent) : parent(_parent) {} - - virtual void declare(u_int16_t channel, u_int16_t ticket, string& queue, - bool passive, bool durable, bool exclusive, - bool autoDelete, bool nowait, qpid::framing::FieldTable& arguments); - - virtual void bind(u_int16_t channel, u_int16_t ticket, string& queue, - string& exchange, string& routingKey, bool nowait, - qpid::framing::FieldTable& arguments); - - virtual void purge(u_int16_t channel, u_int16_t ticket, string& queue, - bool nowait); - - virtual void delete_(u_int16_t channel, u_int16_t ticket, string& queue, bool ifUnused, bool ifEmpty, - bool nowait); - - virtual ~QueueHandlerImpl(){} - }; - - class BasicHandlerImpl : public virtual BasicHandler{ - SessionHandlerImpl* parent; - public: - inline BasicHandlerImpl(SessionHandlerImpl* _parent) : parent(_parent) {} - - virtual void qos(u_int16_t channel, u_int32_t prefetchSize, u_int16_t prefetchCount, bool global); - - virtual void consume(u_int16_t channel, u_int16_t ticket, string& queue, string& consumerTag, - bool noLocal, bool noAck, bool exclusive, bool nowait); - - virtual void cancel(u_int16_t channel, string& consumerTag, bool nowait); - - virtual void publish(u_int16_t channel, u_int16_t ticket, string& exchange, string& routingKey, - bool mandatory, bool immediate); - - virtual void get(u_int16_t channel, u_int16_t ticket, string& queue, bool noAck); - - virtual void ack(u_int16_t channel, u_int64_t deliveryTag, bool multiple); - - virtual void reject(u_int16_t channel, u_int64_t deliveryTag, bool requeue); - - virtual void recover(u_int16_t channel, bool requeue); - - virtual ~BasicHandlerImpl(){} - }; - - inline virtual ChannelHandler* getChannelHandler(){ return channelHandler; } - inline virtual ConnectionHandler* getConnectionHandler(){ return connectionHandler; } - inline virtual BasicHandler* getBasicHandler(){ return basicHandler; } - inline virtual ExchangeHandler* getExchangeHandler(){ return exchangeHandler; } - inline virtual QueueHandler* getQueueHandler(){ return queueHandler; } - - inline virtual AccessHandler* getAccessHandler(){ return 0; } - inline virtual FileHandler* getFileHandler(){ return 0; } - inline virtual StreamHandler* getStreamHandler(){ return 0; } - inline virtual TxHandler* getTxHandler(){ return 0; } - inline virtual DtxHandler* getDtxHandler(){ return 0; } - inline virtual TunnelHandler* getTunnelHandler(){ return 0; } -}; - -} -} - - -#endif diff --git a/cpp/broker/inc/TopicExchange.h b/cpp/broker/inc/TopicExchange.h deleted file mode 100644 index 227280103f..0000000000 --- a/cpp/broker/inc/TopicExchange.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * - * Copyright (c) 2006 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -#ifndef _TopicExchange_ -#define _TopicExchange_ - -#include <tr1/unordered_map> -#include <vector> -#include "Exchange.h" -#include "FieldTable.h" -#include "Message.h" -#include "MonitorImpl.h" -#include "Queue.h" - -namespace qpid { -namespace broker { - -/** A vector of string tokens */ -class Tokens : public std::vector<std::string> { - public: - Tokens() {}; - // Default copy, assign, dtor are sufficient. - - /** Tokenize s, provides automatic conversion of string to Tokens */ - Tokens(const std::string& s) { operator=(s); } - /** Tokenize s */ - Tokens & operator=(const std::string& s); - - struct Hash { size_t operator()(const Tokens&) const; }; - typedef std::equal_to<Tokens> Equal; -}; - -/** - * Tokens that have been normalized as a pattern and can be matched - * with topic Tokens. Normalized meands all sequences of mixed * and - * # are reduced to a series of * followed by at most one #. - */ -class TopicPattern : public Tokens -{ - public: - TopicPattern() {} - // Default copy, assign, dtor are sufficient. - TopicPattern(const Tokens& tokens) { operator=(tokens); } - TopicPattern(const std::string& str) { operator=(str); } - TopicPattern& operator=(const Tokens&); - TopicPattern& operator=(const std::string& str) { return operator=(Tokens(str)); } - - /** Match a topic */ - bool match(const std::string& topic) { return match(Tokens(topic)); } - bool match(const Tokens& topic) const; - - private: - void normalize(); -}; - -class TopicExchange : public virtual Exchange{ - typedef std::tr1::unordered_map<TopicPattern, Queue::vector, TopicPattern::Hash> BindingMap; - BindingMap bindings; - qpid::concurrent::MonitorImpl lock; - - public: - static const std::string typeName; - - TopicExchange(const string& name); - - virtual void bind(Queue::shared_ptr queue, const string& routingKey, qpid::framing::FieldTable* args); - - virtual void unbind(Queue::shared_ptr queue, const string& routingKey, qpid::framing::FieldTable* args); - - virtual void route(Message::shared_ptr& msg, const string& routingKey, qpid::framing::FieldTable* args); - - virtual ~TopicExchange(); -}; - - - -} -} - -#endif |