activemq-cpp-3.4.0

src/main/activemq/cmsutil/SessionPool.h

Go to the documentation of this file.
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_CMSUTIL_SESSIONPOOL_H_
00019 #define ACTIVEMQ_CMSUTIL_SESSIONPOOL_H_
00020 
00021 #include <activemq/cmsutil/PooledSession.h>
00022 #include <decaf/util/concurrent/Mutex.h>
00023 #include <cms/Connection.h>
00024 #include <list>
00025 #include <activemq/util/Config.h>
00026 
00027 namespace activemq {
00028 namespace cmsutil {
00029 
00030     // Forward declarations.
00031     class ResourceLifecycleManager;
00032 
00039     class AMQCPP_API SessionPool {
00040     private:
00041 
00042         cms::Connection* connection;
00043 
00044         ResourceLifecycleManager* resourceLifecycleManager;
00045 
00046         decaf::util::concurrent::Mutex mutex;
00047 
00048         std::list<PooledSession*> available;
00049 
00050         std::list<PooledSession*> sessions;
00051 
00052         cms::Session::AcknowledgeMode acknowledgeMode;
00053 
00054     private:
00055 
00056         SessionPool( const SessionPool& );
00057         SessionPool& operator= ( const SessionPool& );
00058 
00059     public:
00060 
00071         SessionPool( cms::Connection* connection,
00072                      cms::Session::AcknowledgeMode ackMode,
00073                      ResourceLifecycleManager* resourceLifecycleManager );
00074 
00079         virtual ~SessionPool();
00080 
00088         virtual PooledSession* takeSession();
00089 
00095         virtual void returnSession( PooledSession* session );
00096 
00097         ResourceLifecycleManager* getResourceLifecycleManager() {
00098             return resourceLifecycleManager;
00099         }
00100 
00101     };
00102 
00103 }}
00104 
00105 #endif /*ACTIVEMQ_CMSUTIL_SESSIONPOOL_H_*/