|
activemq-cpp-3.4.0
|
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_DYNAMICDESTINATIONRESOLVER_H_ 00018 #define _ACTIVEMQ_CMSUTIL_DYNAMICDESTINATIONRESOLVER_H_ 00019 00020 #include <activemq/cmsutil/DestinationResolver.h> 00021 #include <cms/Session.h> 00022 #include <decaf/util/StlMap.h> 00023 #include <activemq/util/Config.h> 00024 00025 namespace activemq { 00026 namespace cmsutil { 00027 00031 class AMQCPP_API DynamicDestinationResolver : public DestinationResolver { 00032 private: 00033 00037 class SessionResolver { 00038 private: 00039 00040 ResourceLifecycleManager* resourceLifecycleManager; 00041 cms::Session* session; 00042 decaf::util::StlMap<std::string, cms::Topic*> topicMap; 00043 decaf::util::StlMap<std::string, cms::Queue*> queueMap; 00044 00045 private: 00046 00047 SessionResolver( const SessionResolver& ); 00048 SessionResolver& operator= ( const SessionResolver& ); 00049 00050 public: 00051 00052 SessionResolver( cms::Session* session, 00053 ResourceLifecycleManager* resourceLifecycleManager ) 00054 : resourceLifecycleManager( resourceLifecycleManager ), 00055 session( session ), 00056 topicMap(), 00057 queueMap() { 00058 } 00059 00060 virtual ~SessionResolver() throw() {} 00061 00062 cms::Topic* getTopic(const std::string& topicName ); 00063 00064 cms::Queue* getQueue(const std::string& queueName ); 00065 00066 }; 00067 00071 decaf::util::StlMap< cms::Session*, SessionResolver*> sessionResolverMap; 00072 00076 ResourceLifecycleManager* resourceLifecycleManager; 00077 00078 private: 00079 00080 DynamicDestinationResolver( const DynamicDestinationResolver& ); 00081 DynamicDestinationResolver& operator= ( const DynamicDestinationResolver& ); 00082 00083 public: 00084 00085 DynamicDestinationResolver(); 00086 00087 virtual ~DynamicDestinationResolver() throw(); 00088 00089 virtual void init( ResourceLifecycleManager* mgr ) { 00090 00091 // since we're changing the lifecycle manager, clear out references 00092 // to old resources. 00093 destroy(); 00094 00095 this->resourceLifecycleManager = mgr; 00096 } 00097 00098 virtual void destroy(); 00099 00116 virtual cms::Destination* resolveDestinationName( cms::Session* session, 00117 const std::string& destName, 00118 bool pubSubDomain ); 00119 00120 }; 00121 00122 }} 00123 00124 #endif /* _ACTIVEMQ_CMSUTIL_DYNAMICDESTINATIONRESOLVER_H_ */