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_COMMANDS_ACTIVEMQDESTINATION_H_ 00019 #define _ACTIVEMQ_COMMANDS_ACTIVEMQDESTINATION_H_ 00020 00021 #include <activemq/util/Config.h> 00022 #include <activemq/commands/BaseDataStructure.h> 00023 #include <activemq/util/ActiveMQProperties.h> 00024 #include <cms/Destination.h> 00025 #include <decaf/lang/Pointer.h> 00026 #include <decaf/lang/Comparable.h> 00027 #include <decaf/util/ArrayList.h> 00028 00029 #include <vector> 00030 #include <string> 00031 #include <map> 00032 00033 namespace activemq { 00034 namespace commands { 00035 00036 using decaf::lang::Pointer; 00037 00038 class AMQCPP_API ActiveMQDestination : public BaseDataStructure, 00039 public decaf::lang::Comparable<ActiveMQDestination> { 00040 protected: 00041 00042 struct DestinationFilter{ 00043 static const std::string ANY_CHILD; 00044 static const std::string ANY_DESCENDENT; 00045 }; 00046 00050 static const std::string DEFAULT_ORDERED_TARGET; 00051 00052 static const std::string TEMP_PREFIX; 00053 static const std::string TEMP_POSTFIX; 00054 static const std::string COMPOSITE_SEPARATOR; 00055 00056 static const std::string QUEUE_QUALIFIED_PREFIX; 00057 static const std::string TOPIC_QUALIFIED_PREFIX; 00058 static const std::string TEMP_QUEUE_QUALIFED_PREFIX; 00059 static const std::string TEMP_TOPIC_QUALIFED_PREFIX; 00060 00061 // Cached transient data 00062 bool exclusive; 00063 bool ordered; 00064 bool advisory; 00065 mutable decaf::util::ArrayList< Pointer<ActiveMQDestination> > compositeDestinations; 00066 std::string orderedTarget; 00067 00068 std::string physicalName; 00069 util::ActiveMQProperties options; 00070 int hashCode; 00071 00072 public: 00073 00074 const static unsigned char ID_ACTIVEMQDESTINATION = 0; 00075 00076 static const std::string TEMP_DESTINATION_NAME_PREFIX; 00077 00078 typedef decaf::lang::PointerComparator<ActiveMQDestination> COMPARATOR; 00079 00080 private: 00081 00082 ActiveMQDestination(const ActiveMQDestination&); 00083 ActiveMQDestination& operator=(const ActiveMQDestination&); 00084 00085 public: 00086 00087 ActiveMQDestination(); 00088 00089 ActiveMQDestination(const std::string& physicalName); 00090 00091 virtual ~ActiveMQDestination() throw(); 00092 00093 virtual ActiveMQDestination* cloneDataStructure() const { 00094 return NULL; 00095 } 00096 00097 virtual void copyDataStructure(const DataStructure* src); 00098 00099 virtual bool equals(const DataStructure* value) const; 00100 00101 virtual unsigned char getDataStructureType() const; 00102 00103 virtual std::string toString() const; 00104 00105 int getHashCode() const { 00106 return this->hashCode; 00107 } 00108 00109 public: 00110 00115 virtual std::string getPhysicalName() const { 00116 return this->physicalName; 00117 } 00118 00123 virtual void setPhysicalName(const std::string& physicalName); 00124 00128 virtual bool isAdvisory() const { 00129 return advisory; 00130 } 00131 00135 virtual void setAdvisory(bool advisory) { 00136 this->advisory = advisory; 00137 } 00138 00142 virtual bool isExclusive() const { 00143 return exclusive; 00144 } 00145 00149 virtual void setExclusive( bool exclusive ) { 00150 this->exclusive = exclusive; 00151 } 00152 00156 virtual bool isOrdered() const { 00157 return ordered; 00158 } 00159 00163 virtual void setOrdered(bool ordered) { 00164 this->ordered = ordered; 00165 } 00166 00170 virtual std::string getOrderedTarget() const { 00171 return orderedTarget; 00172 } 00173 00177 virtual void setOrderedTarget(const std::string& orderedTarget) { 00178 this->orderedTarget = orderedTarget; 00179 } 00180 00185 virtual cms::Destination::DestinationType getDestinationType() const = 0; 00186 00193 std::string getDestinationTypeAsString() const; 00194 00199 virtual bool isTemporary() const { 00200 return getDestinationType() == cms::Destination::TEMPORARY_TOPIC || 00201 getDestinationType() == cms::Destination::TEMPORARY_QUEUE; 00202 } 00203 00208 virtual bool isTopic() const { 00209 return getDestinationType() == cms::Destination::TOPIC || 00210 getDestinationType() == cms::Destination::TEMPORARY_TOPIC; 00211 } 00212 00217 virtual bool isQueue() const { 00218 return !isTopic(); 00219 } 00220 00229 virtual bool isComposite() const { 00230 return physicalName.find_first_of(COMPOSITE_SEPARATOR) != std::string::npos; 00231 } 00232 00238 decaf::util::ArrayList< Pointer<ActiveMQDestination> > getCompositeDestinations() const; 00239 00243 virtual bool isWildcard() const { 00244 return physicalName.find_first_of(DestinationFilter::ANY_CHILD) != std::string::npos|| 00245 physicalName.find_first_of(DestinationFilter::ANY_DESCENDENT) != std::string::npos; 00246 } 00247 00251 const activemq::util::ActiveMQProperties& getOptions() const { 00252 return options; 00253 } 00254 00259 virtual const cms::Destination* getCMSDestination() const { 00260 return NULL; 00261 } 00262 00272 Pointer<ActiveMQDestination> createDestination(const std::string& name) const { 00273 return ActiveMQDestination::createDestination(getDestinationType(), name); 00274 } 00275 00276 virtual int compareTo(const ActiveMQDestination& value) const; 00277 00278 virtual bool equals(const ActiveMQDestination& value) const; 00279 00280 virtual bool operator==(const ActiveMQDestination& value) const; 00281 00282 virtual bool operator<(const ActiveMQDestination& value) const; 00283 00284 public: // Statics 00285 00292 static std::string createTemporaryName(const std::string& clientId) { 00293 return TEMP_PREFIX + clientId + TEMP_POSTFIX; 00294 } 00295 00302 static std::string getClientId(const ActiveMQDestination* destination); 00303 00312 static Pointer<ActiveMQDestination> createDestination(int type, const std::string& name); 00313 00314 }; 00315 00316 }} 00317 00318 #endif /*_ACTIVEMQ_COMMANDS_ACTIVEMQDESTINATION_H_*/
1.6.1