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 #ifndef _ACTIVEMQ_CORE_ACTIVEMQSESSION_H_ 00018 #define _ACTIVEMQ_CORE_ACTIVEMQSESSION_H_ 00019 00020 #include <cms/Session.h> 00021 #include <cms/ExceptionListener.h> 00022 00023 #include <activemq/util/Config.h> 00024 #include <activemq/core/kernels/ActiveMQConsumerKernel.h> 00025 #include <activemq/core/kernels/ActiveMQProducerKernel.h> 00026 #include <activemq/core/kernels/ActiveMQSessionKernel.h> 00027 #include <activemq/commands/SessionInfo.h> 00028 00029 #include <decaf/lang/Pointer.h> 00030 00031 #include <string> 00032 #include <memory> 00033 00034 namespace activemq{ 00035 namespace core{ 00036 00037 using decaf::lang::Pointer; 00038 using decaf::util::concurrent::atomic::AtomicBoolean; 00039 00040 class ActiveMQConnection; 00041 00042 class AMQCPP_API ActiveMQSession : public virtual cms::Session { 00043 protected: 00044 00045 Pointer<activemq::core::kernels::ActiveMQSessionKernel> kernel; 00046 00047 private: 00048 00049 ActiveMQSession(const ActiveMQSession&); 00050 ActiveMQSession& operator=(const ActiveMQSession&); 00051 00052 public: 00053 00054 ActiveMQSession(Pointer<activemq::core::kernels::ActiveMQSessionKernel> kernel); 00055 00056 virtual ~ActiveMQSession(); 00057 00061 virtual void start(); 00062 00066 virtual void stop(); 00067 00072 bool isStarted() const { 00073 return this->kernel->isStarted(); 00074 } 00075 00076 public: // Implements Methods 00077 00078 virtual void close(); 00079 00080 virtual void commit(); 00081 00082 virtual void rollback(); 00083 00084 virtual void recover(); 00085 00086 virtual cms::MessageConsumer* createConsumer(const cms::Destination* destination); 00087 00088 virtual cms::MessageConsumer* createConsumer(const cms::Destination* destination, 00089 const std::string& selector); 00090 00091 virtual cms::MessageConsumer* createConsumer(const cms::Destination* destination, 00092 const std::string& selector, 00093 bool noLocal); 00094 00095 virtual cms::MessageConsumer* createDurableConsumer(const cms::Topic* destination, 00096 const std::string& name, 00097 const std::string& selector, 00098 bool noLocal = false); 00099 00100 virtual cms::MessageProducer* createProducer(const cms::Destination* destination); 00101 00102 virtual cms::QueueBrowser* createBrowser(const cms::Queue* queue); 00103 00104 virtual cms::QueueBrowser* createBrowser(const cms::Queue* queue, const std::string& selector); 00105 00106 virtual cms::Queue* createQueue(const std::string& queueName); 00107 00108 virtual cms::Topic* createTopic(const std::string& topicName); 00109 00110 virtual cms::TemporaryQueue* createTemporaryQueue(); 00111 00112 virtual cms::TemporaryTopic* createTemporaryTopic(); 00113 00114 virtual cms::Message* createMessage(); 00115 00116 virtual cms::BytesMessage* createBytesMessage(); 00117 00118 virtual cms::BytesMessage* createBytesMessage(const unsigned char* bytes, int bytesSize); 00119 00120 virtual cms::StreamMessage* createStreamMessage(); 00121 00122 virtual cms::TextMessage* createTextMessage(); 00123 00124 virtual cms::TextMessage* createTextMessage(const std::string& text); 00125 00126 virtual cms::MapMessage* createMapMessage(); 00127 00128 virtual cms::Session::AcknowledgeMode getAcknowledgeMode() const { 00129 return this->kernel->getAcknowledgeMode(); 00130 } 00131 00132 virtual bool isTransacted() const { 00133 return this->kernel->isTransacted(); 00134 } 00135 00136 virtual void unsubscribe(const std::string& name); 00137 00138 public: // ActiveMQSession specific Methods 00139 00147 cms::ExceptionListener* getExceptionListener() { 00148 return this->kernel->getExceptionListener(); 00149 } 00150 00158 virtual void setMessageTransformer(cms::MessageTransformer* transformer) { 00159 this->kernel->setMessageTransformer(transformer); 00160 } 00161 00167 virtual cms::MessageTransformer* getMessageTransformer() const { 00168 return this->kernel->getMessageTransformer(); 00169 } 00170 00176 const commands::SessionInfo& getSessionInfo() const { 00177 return this->kernel->getSessionInfo(); 00178 } 00179 00185 const commands::SessionId& getSessionId() const { 00186 return this->kernel->getSessionId(); 00187 } 00188 00192 ActiveMQConnection* getConnection() const { 00193 return this->kernel->getConnection(); 00194 } 00195 00196 }; 00197 00198 }} 00199 00200 #endif /*_ACTIVEMQ_CORE_ACTIVEMQSESSION_H_*/
1.6.1