00001 /*------------------------------------------------------------------------------ 00002 Name: org::xmlBlaster::util::qos::address::AddressBase.h 00003 Project: xmlBlaster.org 00004 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file 00005 Comment: Holding connect address and callback address std::string including protocol 00006 Version: $Id: AddressBase.h 14269 2005-12-06 12:25:08Z ruff $ 00007 ------------------------------------------------------------------------------*/ 00008 00018 #ifndef _UTIL_CFG_ADDRESSBASE_H 00019 #define _UTIL_CFG_ADDRESSBASE_H 00020 00021 #include <util/xmlBlasterDef.h> 00022 #include <util/Constants.h> 00023 #include <util/I_Log.h> 00024 #include <util/qos/ClientProperty.h> 00025 #include <string> 00026 #include <map> 00027 #include <util/ReferenceCounterBase.h> 00028 #include <util/ReferenceHolder.h> 00029 00030 namespace org { namespace xmlBlaster { namespace util { namespace qos { namespace address { 00031 00032 extern Dll_Export const int DEFAULT_port; 00033 extern Dll_Export const std::string DEFAULT_type; 00034 extern Dll_Export const std::string DEFAULT_version; 00035 extern Dll_Export const long DEFAULT_collectTime; 00036 extern Dll_Export const int DEFAULT_burstModeMaxEntries; 00037 extern Dll_Export const long DEFAULT_burstModeMaxBytes; 00038 extern Dll_Export const bool DEFAULT_oneway; 00039 extern Dll_Export const bool DEFAULT_dispatcherActive; 00040 extern Dll_Export const std::string DEFAULT_compressType; 00041 extern Dll_Export const long DEFAULT_minSize; 00042 extern Dll_Export const bool DEFAULT_ptpAllowed; 00043 extern Dll_Export const std::string DEFAULT_sessionId; 00044 extern Dll_Export const bool DEFAULT_useForSubjectQueue; 00045 extern Dll_Export std::string DEFAULT_dispatchPlugin; 00046 extern Dll_Export std::string ATTRIBUTE_TAG; 00047 00048 00049 00050 class Dll_Export AddressBase : public org::xmlBlaster::util::ReferenceCounterBase 00051 { 00052 friend class AddressFactory; 00053 00054 public: typedef std::map<std::string, org::xmlBlaster::util::qos::ClientProperty> ClientPropertyMap; 00055 00056 private: 00057 int port_; 00058 00062 void setRootTag(const std::string& rootTag) 00063 { 00064 rootTag_ = rootTag; 00065 } 00066 00067 protected: 00068 std::string ME; 00069 org::xmlBlaster::util::Global& global_; 00070 org::xmlBlaster::util::I_Log& log_; 00071 00072 std::string rootTag_; 00073 00075 std::string nodeId_; 00076 00078 long maxEntries_; // only used in org::xmlBlaster::util::qos::address::Address 00079 00081 mutable std::string address_; 00082 00083 mutable std::string hostname_; 00084 bool isHardcodedHostname_; // = false; // set to true if setHostname() was explicitly called by user 00085 00087 std::string type_; // = DEFAULT_type; 00088 00090 std::string version_; // = DEFAULT_version; 00091 00093 long collectTime_; // = DEFAULT_collectTime; 00094 00100 int burstModeMaxEntries_; // = 1 00101 00106 long burstModeMaxBytes_; // = -1L 00107 00109 long pingInterval_; // = getDefaultPingInterval(); 00110 00112 int retries_; // = getDefaultRetries(); 00113 00115 long delay_; // = getDefaultDelay(); 00116 00123 bool oneway_; // = DEFAULT_oneway; 00124 00130 bool dispatcherActive_; // = DEFAULT_dispatcherActive; 00131 00133 std::string compressType_; // = DEFAULT_compressType; 00134 00136 long minSize_; // = DEFAULT_minSize; 00137 00139 bool ptpAllowed_; // = DEFAULT_ptpAllowed; 00140 00142 std::string sessionId_; // = DEFAULT_sessionId; 00143 00145 bool useForSubjectQueue_; // = DEFAULT_useForSubjectQueue; 00146 00157 std::string dispatchPlugin_; // = DEFAULT_dispatchPlugin; 00158 00159 ClientPropertyMap attributes_; 00160 00161 void initHostname(const std::string& hostname) 00162 { 00163 hostname_ = hostname; 00164 address_ = ""; // reset cache 00165 } 00166 00167 void copy(const AddressBase& addr); 00168 00169 long defaultPingInterval_; 00170 int defaultRetries_; 00171 long defaultDelay_; 00172 00173 public: 00174 00178 AddressBase(org::xmlBlaster::util::Global& global, const std::string& rootTag=""); 00179 00183 AddressBase(const AddressBase& addr); 00184 00188 AddressBase& operator =(const AddressBase& addr); 00189 00190 virtual ~AddressBase(); 00191 00195 std::string getName(); 00196 00200 bool isSameAddress(AddressBase& other); 00201 00205 std::string getSettings() const; 00206 00207 void addAttribute(const ClientProperty& attribute); 00208 00209 const ClientPropertyMap& getAttributes() const; 00210 00215 std::string dumpAttributes(const std::string& extraOffset, bool clearText=false) const; 00216 00220 void setType(const std::string& type); 00221 00225 void setVersion(const std::string& version); 00226 00231 void setHostname(const std::string& host); 00232 00237 bool isHardcodedHostname(); 00238 00242 bool hasHostname(); 00243 00247 std::string getHostname() const; 00248 00253 void setPort(int port); 00254 00255 int getPort() const; 00256 00262 void setAddress(const std::string& address); 00263 00268 std::string getRawAddress() const; 00269 00274 std::string getType() const; 00275 00280 std::string getVersion() const; 00281 00289 std::string getOnExhaust() const; 00290 00294 bool getOnExhaustKillSession() const; 00295 00300 long getCollectTime() const; 00301 00306 void setCollectTime(long collectTime); 00307 00313 int getBurstModeMaxEntries() const; 00314 00321 void setBurstModeMaxEntries(int burstModeMaxEntries); 00322 00327 long getBurstModeMaxBytes() const; 00328 00335 void setBurstModeMaxBytes(long BurstModeMaxBytes); 00336 00341 long getPingInterval() const; 00342 00347 void setPingInterval(long pingInterval); 00348 00353 int getRetries() const; 00354 00359 void setRetries(int retries); 00360 00365 long getDelay() const; 00366 00370 void setDelay(long delay); 00371 00377 bool oneway() const; 00378 00384 void setOneway(bool oneway); 00385 00390 void setDispatcherActive(bool dispatcherActive); 00391 00396 bool isDispatcherActive() const; 00397 00401 void setPtpAllowed(bool ptpAllowed); 00402 00406 bool isPtpAllowed(); 00407 00408 void setCompressType(const std::string& compressType); 00409 00414 std::string getSecretSessionId() const; 00415 00417 void setSecretSessionId(const std::string& sessionId); 00418 00423 std::string getCompressType() const; 00424 00431 long getMinSize() const; 00432 00439 void setMinSize(long minSize); 00440 00456 void setDispatchPlugin(const std::string& dispatchPlugin); 00457 00461 std::string getDispatchPlugin() const; 00462 00463 const ClientPropertyMap& getClientProperties() const; 00464 00472 std::string toXml(const std::string& extraOffset = "") const; 00473 }; 00474 00475 typedef org::xmlBlaster::util::ReferenceHolder<AddressBase> AddressBaseRef; 00476 00477 }}}}} 00478 00479 #endif 00480 00481 00482