00001 /*------------------------------------------------------------------------------ 00002 Name: ConnectQos.h 00003 Project: xmlBlaster.org 00004 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file 00005 Comment: Defines ConnectQos, ReturnConnectQos and ConnectQosData 00006 ------------------------------------------------------------------------------*/ 00007 00008 #ifndef _UTIL_QOS_CONNECTQOS_H 00009 #define _UTIL_QOS_CONNECTQOS_H 00010 00011 #include <util/xmlBlasterDef.h> 00012 #include <string> 00013 #include <util/XmlQoSBase.h> 00014 #include <util/ServerRef.h> 00015 #include <util/qos/SessionQos.h> 00016 #include <authentication/SecurityQos.h> 00017 #include <util/qos/address/AddressFactory.h> 00018 #include <util/qos/address/Address.h> 00019 #include <util/qos/address/CallbackAddress.h> 00020 #include <util/qos/storage/QueuePropertyFactory.h> 00021 #include <util/qos/storage/ClientQueueProperty.h> 00022 #include <util/qos/storage/CbQueueProperty.h> 00023 #include <util/qos/ClientProperty.h> 00024 #include <util/ReferenceCounterBase.h> 00025 #include <util/ReferenceHolder.h> 00026 00027 #include <vector> 00028 #include <map> 00029 00030 namespace org { namespace xmlBlaster { namespace util { namespace qos { 00031 00036 class Dll_Export ConnectQosData : public org::xmlBlaster::util::ReferenceCounterBase 00037 { 00038 00039 public: typedef std::map<std::string, org::xmlBlaster::util::qos::ClientProperty> ClientPropertyMap; 00040 00041 private: 00042 org::xmlBlaster::util::Global& global_; 00043 org::xmlBlaster::util::I_Log& log_; 00044 mutable org::xmlBlaster::authentication::SecurityQos securityQos_; 00045 mutable org::xmlBlaster::util::qos::SessionQosRef sessionQos_; 00046 bool ptp_; 00047 bool clusterNode_; 00048 bool refreshSession_; 00049 bool duplicateUpdates_; 00050 bool reconnected_; 00051 std::string instanceId_; 00052 bool persistent_; 00053 00054 //std::vector<org::xmlBlaster::util::qos::address::Address> addresses_; 00055 //std::vector<org::xmlBlaster::util::qos::address::CallbackAddress> cbAddresses_; 00056 std::vector<org::xmlBlaster::util::qos::storage::ClientQueueProperty> clientQueueProperties_; 00057 org::xmlBlaster::util::qos::storage::CbQueueProperty sessionCbQueueProperty_; 00058 std::vector<ServerRef> serverReferences_; 00059 00060 00061 friend class ConnectQosFactory; 00062 00066 void addServerRef(const org::xmlBlaster::util::ServerRef& serverRef); 00067 00068 void copy(const ConnectQosData& data) 00069 { 00070 securityQos_ = data.securityQos_; 00071 org::xmlBlaster::util::qos::SessionQosData* p = data.sessionQos_.getElement(); 00072 org::xmlBlaster::util::qos::SessionQosData* p2 = new org::xmlBlaster::util::qos::SessionQosData(*p); 00073 org::xmlBlaster::util::qos::SessionQosRef r(p2); 00074 sessionQos_ = r; 00075 ptp_ = data.ptp_; 00076 clusterNode_ = data.clusterNode_; 00077 refreshSession_ = data.refreshSession_; 00078 duplicateUpdates_ = data.duplicateUpdates_; 00079 serverReferences_ = data.serverReferences_; 00080 //addresses_ = data.addresses_; 00081 //cbAddresses_ = data.cbAddresses_; 00082 clientQueueProperties_ = data.clientQueueProperties_; 00083 sessionCbQueueProperty_ = data.sessionCbQueueProperty_; 00084 clientProperties_ = data.clientProperties_; 00085 reconnected_ = data.reconnected_; 00086 instanceId_ = data.instanceId_; 00087 persistent_ = data.persistent_; 00088 } 00089 00090 protected: 00091 ClientPropertyMap clientProperties_; 00092 00093 public: 00094 ConnectQosData(org::xmlBlaster::util::Global& global, const std::string& user="", const std::string& passwd="", long publicSessionId=0); 00095 ConnectQosData(const ConnectQosData& data); 00096 ConnectQosData& operator =(const ConnectQosData& data); 00097 bool getPtp() const; 00098 const std::string& getBoolAsString(bool boolVal) const; 00099 void setPtp(bool ptp); 00100 void setSessionQos(const org::xmlBlaster::util::qos::SessionQos& sessionQos); 00101 org::xmlBlaster::util::qos::SessionQos& getSessionQos() const; 00102 void setSessionQos(org::xmlBlaster::util::qos::SessionQosRef sessionQos); 00103 org::xmlBlaster::util::qos::SessionQosRef getSessionQosRef() const; 00104 std::string getSecretSessionId() const; 00105 std::string getUserId() const; 00106 std::string getCallbackType() const; 00107 void setSecurityQos(const org::xmlBlaster::authentication::SecurityQos& securityQos); 00108 org::xmlBlaster::authentication::SecurityQos& getSecurityQos() const; 00109 void setClusterNode(bool clusterNode); 00110 bool isClusterNode() const; 00116 void setRefreshSession(bool refreshSession); 00117 bool isRefreshSession() const; 00118 void setDuplicateUpdates(bool duplicateUpdates); 00119 bool isDuplicateUpdates() const; 00123 const std::vector<ServerRef> getServerReferences() const; 00124 00129 bool isReconnected() const; 00130 void setReconnected(bool reconnected); 00131 00137 std::string getInstanceId() const; 00138 void setInstanceId(std::string instanceId); 00139 00140 bool isPersistent() const; 00141 void setPersistent(bool persistent); 00142 00147 org::xmlBlaster::util::ServerRef getServerRef(); 00148 00149 std::string toXml(const std::string& extraOffset="") const; 00150 00151 // methods for queues and addresses ... 00152 00157 void setAddress(const org::xmlBlaster::util::qos::address::AddressBaseRef& address); 00158 org::xmlBlaster::util::qos::address::AddressBaseRef getAddress(); 00159 00165 void addCbAddress(const org::xmlBlaster::util::qos::address::AddressBaseRef& cbAddress); 00166 org::xmlBlaster::util::qos::address::AddressBaseRef getCbAddress(); 00167 00173 void addClientQueueProperty(const org::xmlBlaster::util::qos::storage::ClientQueueProperty& prop); 00174 00180 org::xmlBlaster::util::qos::storage::ClientQueueProperty& getClientQueueProperty(); 00181 00187 void setSessionCbQueueProperty(const org::xmlBlaster::util::qos::storage::CbQueueProperty& prop); 00188 00194 org::xmlBlaster::util::qos::storage::CbQueueProperty& getSessionCbQueueProperty(); 00195 00196 std::string dumpClientProperties(const std::string& extraOffset, bool clearText=false) const; 00197 00203 void addClientProperty(const ClientProperty& clientProperty); 00204 00211 template <typename T_VALUE> void addClientProperty( 00212 const std::string& name, 00213 const T_VALUE& value, 00214 const std::string& type="", 00215 const std::string& encoding=""); 00216 00221 template <typename T_VALUE> T_VALUE getClientProperty( 00222 const std::string& name, 00223 const T_VALUE& defaultValue); 00224 00225 const ClientPropertyMap& getClientProperties() const; 00226 }; 00227 00228 template <typename T_VALUE> void ConnectQosData::addClientProperty( 00229 const std::string& name, const T_VALUE& value, 00230 const std::string& type, const std::string& encoding) 00231 { 00232 org::xmlBlaster::util::qos::ClientProperty clientProperty(name, value, type, encoding); 00233 clientProperties_.insert(ClientPropertyMap::value_type(name, clientProperty)); 00234 } 00235 00236 template <typename T_VALUE> T_VALUE ConnectQosData::getClientProperty( 00237 const std::string& name, const T_VALUE& defaultValue) 00238 { 00239 ClientPropertyMap::const_iterator iter = clientProperties_.find(name); 00240 if (iter != clientProperties_.end()) { 00241 T_VALUE tmp; 00242 (*iter).second.getValue(tmp); 00243 return tmp; 00244 } 00245 return defaultValue; 00246 } 00247 00248 typedef org::xmlBlaster::util::ReferenceHolder<ConnectQosData> ConnectQosDataRef; 00249 00250 typedef ConnectQosData ConnectQos; 00251 typedef org::xmlBlaster::util::ReferenceHolder<ConnectQos> ConnectQosRef; 00252 00253 typedef ConnectQosData ConnectReturnQos; 00254 typedef org::xmlBlaster::util::ReferenceHolder<ConnectReturnQos> ConnectReturnQosRef; 00255 00256 }}}} // namespaces 00257 00258 #endif