00001 /* 00002 * Licensed to the Apache Software Foundation (ASF) under one or more 00003 * contributor license agreements. See the NOTICE file distributed with 00004 * this work for additional information regarding copyright ownership. 00005 * The ASF licenses this file to You under the Apache License, Version 2.0 00006 * (the "License"); you may not use this file except in compliance with 00007 * the License. You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 00018 #ifndef _ACTIVEMQ_CORE_ACTIVEMQQUEUEBROWSER_H_ 00019 #define _ACTIVEMQ_CORE_ACTIVEMQQUEUEBROWSER_H_ 00020 00021 #include <activemq/util/Config.h> 00022 00023 #include <cms/Queue.h> 00024 #include <cms/QueueBrowser.h> 00025 #include <cms/MessageEnumeration.h> 00026 #include <activemq/commands/ConsumerId.h> 00027 #include <activemq/commands/ActiveMQDestination.h> 00028 #include <activemq/core/kernels/ActiveMQSessionKernel.h> 00029 #include <decaf/lang/Pointer.h> 00030 #include <decaf/util/concurrent/Mutex.h> 00031 #include <decaf/util/concurrent/atomic/AtomicBoolean.h> 00032 00033 #include <string> 00034 00035 namespace activemq { 00036 namespace core { 00037 namespace kernels { 00038 class ActiveMQConsumerKernel; 00039 } 00040 00041 class ActiveMQSession; 00042 class Browser; 00043 00044 using decaf::lang::Pointer; 00045 00046 class AMQCPP_API ActiveMQQueueBrowser : public cms::QueueBrowser, 00047 public cms::MessageEnumeration { 00048 private: 00049 00050 friend class Browser; 00051 00052 activemq::core::kernels::ActiveMQSessionKernel* session; 00053 Pointer<commands::ConsumerId> consumerId; 00054 Pointer<commands::ActiveMQDestination> destination; 00055 std::string selector; 00056 bool dispatchAsync; 00057 cms::Queue* queue; 00058 volatile bool closed; 00059 00060 mutable decaf::util::concurrent::Mutex mutex; 00061 mutable decaf::util::concurrent::Mutex wait; 00062 decaf::util::concurrent::atomic::AtomicBoolean browseDone; 00063 00064 mutable Pointer<activemq::core::kernels::ActiveMQConsumerKernel> browser; 00065 00066 private: 00067 00068 ActiveMQQueueBrowser(const ActiveMQQueueBrowser&); 00069 ActiveMQQueueBrowser& operator=(const ActiveMQQueueBrowser&); 00070 00071 public: 00072 00073 ActiveMQQueueBrowser(activemq::core::kernels::ActiveMQSessionKernel* session, 00074 const Pointer<commands::ConsumerId>& consumerId, 00075 const Pointer<commands::ActiveMQDestination>& destination, 00076 const std::string& selector, 00077 bool dispatchAsync); 00078 00079 virtual ~ActiveMQQueueBrowser(); 00080 00081 public: 00082 00083 virtual const cms::Queue* getQueue() const; 00084 00085 virtual std::string getMessageSelector() const; 00086 00087 virtual cms::MessageEnumeration* getEnumeration(); 00088 00089 virtual void close(); 00090 00091 virtual bool hasMoreMessages(); 00092 00093 virtual cms::Message* nextMessage(); 00094 00095 private: 00096 00097 void checkClosed(); 00098 void notifyMessageAvailable(); 00099 void waitForMessageAvailable(); 00100 00101 Pointer<activemq::core::kernels::ActiveMQConsumerKernel> createConsumer(); 00102 void destroyConsumer(); 00103 00104 }; 00105 00106 }} 00107 00108 #endif /* _ACTIVEMQ_CORE_ACTIVEMQQUEUEBROWSER_H_ */
1.6.1