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, ResourceLifecycleManager* resourceLifecycleManager ) 00053 : resourceLifecycleManager( resourceLifecycleManager ), 00054 session( session ), 00055 topicMap(), 00056 queueMap() { 00057 } 00058 00059 virtual ~SessionResolver() {} 00060 00061 cms::Topic* getTopic(const std::string& topicName); 00062 00063 cms::Queue* getQueue(const std::string& queueName); 00064 00065 }; 00066 00070 decaf::util::StlMap< cms::Session*, SessionResolver*> sessionResolverMap; 00071 00075 ResourceLifecycleManager* resourceLifecycleManager; 00076 00077 private: 00078 00079 DynamicDestinationResolver(const DynamicDestinationResolver&); 00080 DynamicDestinationResolver& operator=(const DynamicDestinationResolver&); 00081 00082 public: 00083 00084 DynamicDestinationResolver(); 00085 00086 virtual ~DynamicDestinationResolver(); 00087 00088 virtual void init(ResourceLifecycleManager* mgr) { 00089 00090 // since we're changing the lifecycle manager, clear out references 00091 // to old resources. 00092 destroy(); 00093 00094 this->resourceLifecycleManager = mgr; 00095 } 00096 00097 virtual void destroy(); 00098 00117 virtual cms::Destination* resolveDestinationName(cms::Session* session, 00118 const std::string& destName, 00119 bool pubSubDomain); 00120 00121 }; 00122 00123 }} 00124 00125 #endif /* _ACTIVEMQ_CMSUTIL_DYNAMICDESTINATIONRESOLVER_H_ */
1.6.1