activemq-cpp-3.4.0

src/main/activemq/cmsutil/CmsAccessor.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 #ifndef _ACTIVEMQ_CMSUTIL_CMSACCESSOR_H_
00018 #define _ACTIVEMQ_CMSUTIL_CMSACCESSOR_H_
00019 
00020 #include <cms/ConnectionFactory.h>
00021 #include <activemq/cmsutil/ResourceLifecycleManager.h>
00022 #include <activemq/util/Config.h>
00023 
00024 namespace activemq {
00025 namespace cmsutil {
00026 
00039     class AMQCPP_API CmsAccessor {
00040     private:
00041 
00042         ResourceLifecycleManager resourceLifecycleManager;
00043 
00044         cms::ConnectionFactory* connectionFactory;
00045 
00046         cms::Session::AcknowledgeMode sessionAcknowledgeMode;
00047 
00048     protected:
00049 
00050         CmsAccessor( const CmsAccessor& );
00051         CmsAccessor& operator= ( const CmsAccessor& );
00052 
00053     public:
00054 
00055         CmsAccessor();
00056 
00057         virtual ~CmsAccessor();
00058 
00059         virtual ResourceLifecycleManager* getResourceLifecycleManager() {
00060             return &resourceLifecycleManager;
00061         }
00062 
00063         virtual const ResourceLifecycleManager* getResourceLifecycleManager() const {
00064             return &resourceLifecycleManager;
00065         }
00066 
00070         virtual void setConnectionFactory( cms::ConnectionFactory* connectionFactory ) {
00071             this->connectionFactory = connectionFactory;
00072         }
00073 
00078         virtual const cms::ConnectionFactory* getConnectionFactory() const {
00079             return this->connectionFactory;
00080         }
00081 
00086         virtual cms::ConnectionFactory* getConnectionFactory() {
00087             return this->connectionFactory;
00088         }
00089 
00098         virtual void setSessionAcknowledgeMode(
00099                 cms::Session::AcknowledgeMode sessionAcknowledgeMode ) {
00100             this->sessionAcknowledgeMode = sessionAcknowledgeMode;
00101         }
00102 
00108         virtual cms::Session::AcknowledgeMode getSessionAcknowledgeMode() const {
00109             return this->sessionAcknowledgeMode;
00110         }
00111 
00112     protected:
00113 
00121         virtual void init();
00122 
00129         virtual void destroy() {
00130             resourceLifecycleManager.destroy();
00131         }
00132 
00141         virtual cms::Connection* createConnection();
00142 
00154         virtual cms::Session* createSession( cms::Connection* con );
00155 
00161         virtual void checkConnectionFactory();
00162 
00163     };
00164 
00165 }}
00166 
00167 #endif /* _ACTIVEMQ_CMSUTIL_CMSACCESSOR_H_ */