activemq-cpp-3.6.0
PooledSession.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef _ACTIVEMQ_CMSUTIL_POOLEDSESSION_H_
19 #define _ACTIVEMQ_CMSUTIL_POOLEDSESSION_H_
20 
21 #include <cms/Session.h>
22 #include <decaf/util/StlMap.h>
25 #include <activemq/util/Config.h>
26 
27 namespace activemq {
28 namespace cmsutil {
29 
30  // Forward declarations.
31  class SessionPool;
32 
38  private:
39 
40  SessionPool* pool;
41 
42  cms::Session* session;
43 
45 
47 
48  private:
49 
51  PooledSession& operator=(const PooledSession&);
52 
53  public:
54 
55  PooledSession(SessionPool* pool, cms::Session* session);
56 
60  virtual ~PooledSession();
61 
67  virtual cms::Session* getSession() {
68  return session;
69  }
70 
76  virtual const cms::Session* getSession() const {
77  return session;
78  }
79 
86  virtual void close();
87 
88  virtual void start() {
89  session->start();
90  }
91 
92  virtual void stop() {
93  session->stop();
94  }
95 
96  virtual void commit() {
97  session->commit();
98  }
99 
100  virtual void rollback() {
101  session->rollback();
102  }
103 
104  virtual void recover() {
105  session->recover();
106  }
107 
108  virtual cms::MessageConsumer* createConsumer(const cms::Destination* destination) {
109  return session->createConsumer(destination);
110  }
111 
112  virtual cms::MessageConsumer* createConsumer(const cms::Destination* destination,
113  const std::string& selector) {
114  return session->createConsumer(destination, selector);
115  }
116 
117  virtual cms::MessageConsumer* createConsumer(const cms::Destination* destination,
118  const std::string& selector,
119  bool noLocal) {
120  return session->createConsumer(destination, selector, noLocal);
121  }
122 
123  virtual cms::MessageConsumer* createDurableConsumer(const cms::Topic* destination,
124  const std::string& name,
125  const std::string& selector,
126  bool noLocal = false) {
127  return session->createDurableConsumer(destination, name, selector, noLocal);
128  }
129 
146  virtual cms::MessageConsumer* createCachedConsumer(const cms::Destination* destination,
147  const std::string& selector, bool noLocal);
148 
149  virtual cms::MessageProducer* createProducer(const cms::Destination* destination) {
150  return session->createProducer(destination);
151  }
152 
165  virtual cms::MessageProducer* createCachedProducer(const cms::Destination* destination);
166 
167  virtual cms::QueueBrowser* createBrowser(const cms::Queue* queue);
168 
169  virtual cms::QueueBrowser* createBrowser(const cms::Queue* queue, const std::string& selector);
170 
171  virtual cms::Queue* createQueue(const std::string& queueName) {
172  return session->createQueue(queueName);
173  }
174 
175  virtual cms::Topic* createTopic(const std::string& topicName) {
176  return session->createTopic(topicName);
177  }
178 
180  return session->createTemporaryQueue();
181  }
182 
184  return session->createTemporaryTopic();
185  }
186 
188  return session->createMessage();
189  }
190 
192  return session->createBytesMessage();
193  }
194 
195  virtual cms::BytesMessage* createBytesMessage(const unsigned char* bytes, int bytesSize) {
196  return session->createBytesMessage(bytes, bytesSize);
197  }
198 
200  return session->createStreamMessage();
201  }
202 
204  return session->createTextMessage();
205  }
206 
207  virtual cms::TextMessage* createTextMessage(const std::string& text) {
208  return session->createTextMessage(text);
209  }
210 
212  return session->createMapMessage();
213  }
214 
216  return session->getAcknowledgeMode();
217  }
218 
219  virtual bool isTransacted() const {
220  return session->isTransacted();
221  }
222 
223  virtual void unsubscribe(const std::string& name) {
224  session->unsubscribe(name);
225  }
226 
227  virtual void setMessageTransformer(cms::MessageTransformer* transformer) {
228  session->setMessageTransformer(transformer);
229  }
230 
232  return session->getMessageTransformer();
233  }
234 
235  private:
236 
237  std::string getUniqueDestName(const cms::Destination* dest);
238 
239  };
240 
241 }}
242 
243 #endif /*_ACTIVEMQ_CMSUTIL_POOLEDSESSION_H_*/