00001 /*------------------------------------------------------------------------------ 00002 Name: CorbaDriver.h 00003 Project: xmlBlaster.org 00004 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file 00005 Comment: The client driver for the corba protocol 00006 ------------------------------------------------------------------------------*/ 00007 00008 #ifndef _CLIENT_PROTOCOL_CORBA_CORBA_DRIVER 00009 #define _CLIENT_PROTOCOL_CORBA_CORBA_DRIVER 00010 00011 #include <util/xmlBlasterDef.h> 00012 #include <util/plugin/I_Plugin.h> 00013 #include <client/protocol/corba/CorbaConnection.h> 00014 #include <client/protocol/corba/DefaultCallback.h> 00015 #include <string> 00016 #include <vector> 00017 #include <util/MessageUnit.h> 00018 #include <client/I_Callback.h> 00019 #include <client/protocol/I_CallbackServer.h> 00020 #include <client/protocol/I_XmlBlasterConnection.h> 00021 #include <util/XmlBlasterException.h> 00022 00023 #include <util/qos/StatusQosFactory.h> 00024 #include <util/qos/MsgQosFactory.h> 00025 #include <util/thread/ThreadImpl.h> 00026 #include <map> 00027 00028 namespace org { 00029 namespace xmlBlaster { 00030 namespace client { 00031 namespace protocol { 00032 namespace corba { 00033 00034 class Dll_Export CorbaDriver 00035 : public virtual org::xmlBlaster::client::protocol::I_CallbackServer, 00036 public virtual org::xmlBlaster::client::protocol::I_XmlBlasterConnection, 00037 public virtual org::xmlBlaster::util::plugin::I_Plugin 00038 { 00039 friend class CorbaDriverFactory; // To be able to create a CorbaDriver instance 00040 00041 private: 00042 org::xmlBlaster::util::thread::Mutex& mutex_; 00043 std::string instanceName_; 00044 CorbaConnection* connection_; 00045 DefaultCallback* defaultCallback_; 00046 const std::string ME; 00047 org::xmlBlaster::util::Global& global_; 00048 org::xmlBlaster::util::I_Log& log_; 00049 org::xmlBlaster::util::qos::StatusQosFactory statusQosFactory_; 00050 bool orbIsThreadSafe_; 00051 00056 void freeResources(bool deleteConnection=true, bool deleteCallback=true); 00057 00068 CorbaDriver(org::xmlBlaster::util::Global& global, org::xmlBlaster::util::thread::Mutex& mutex, const std::string instanceName, CORBA::ORB_ptr orb=NULL); 00069 00070 CorbaDriver(const CorbaDriver& corbaDriver); 00071 00072 CorbaDriver& operator =(const CorbaDriver& corbaDriver); 00073 00074 virtual ~CorbaDriver(); 00075 00083 // void run(); 00084 00085 public: 00086 00087 bool orbIsThreadSafe() const { 00088 return this->orbIsThreadSafe_; 00089 } 00090 00091 // methods inherited from org::xmlBlaster::client::protocol::I_CallbackServer 00092 void initialize(const std::string& name, org::xmlBlaster::client::I_Callback &client); 00093 std::string getCbProtocol(); 00094 std::string getCbAddress(); 00095 bool shutdownCb(); 00096 00097 // methods inherited from org::xmlBlaster::client::protocol::I_XmlBlasterConnection 00098 org::xmlBlaster::util::qos::ConnectReturnQosRef connect(const org::xmlBlaster::util::qos::ConnectQosRef& qos); 00099 bool disconnect(const org::xmlBlaster::util::qos::DisconnectQos& qos); 00100 std::string getProtocol(); 00101 // std::string loginRaw(); 00102 bool shutdown(); 00103 std::string getLoginName(); 00104 bool isLoggedIn(); 00105 00106 std::string ping(const std::string& qos); 00107 00108 org::xmlBlaster::client::qos::SubscribeReturnQos subscribe(const org::xmlBlaster::client::key::SubscribeKey& key, const org::xmlBlaster::client::qos::SubscribeQos& qos); 00109 00110 std::vector<org::xmlBlaster::util::MessageUnit> get(const org::xmlBlaster::client::key::GetKey& key, const org::xmlBlaster::client::qos::GetQos& qos); 00111 00112 std::vector<org::xmlBlaster::client::qos::UnSubscribeReturnQos> unSubscribe(const org::xmlBlaster::client::key::UnSubscribeKey& key, const org::xmlBlaster::client::qos::UnSubscribeQos& qos); 00113 00114 org::xmlBlaster::client::qos::PublishReturnQos publish(const org::xmlBlaster::util::MessageUnit& msgUnit); 00115 00116 void publishOneway(const std::vector<org::xmlBlaster::util::MessageUnit> &msgUnitArr); 00117 00118 std::vector<org::xmlBlaster::client::qos::PublishReturnQos> publishArr(const std::vector<org::xmlBlaster::util::MessageUnit> &msgUnitArr); 00119 00120 std::vector<org::xmlBlaster::client::qos::EraseReturnQos> erase(const org::xmlBlaster::client::key::EraseKey& key, const org::xmlBlaster::client::qos::EraseQos& qos); 00121 00125 org::xmlBlaster::client::protocol::I_ProgressListener* registerProgressListener(org::xmlBlaster::client::protocol::I_ProgressListener *listener); 00126 00127 00128 // following methods are not defined in any parent class 00129 static std::string usage(); 00130 // Exception conversion .... 00131 static org::xmlBlaster::util::XmlBlasterException 00132 convertFromCorbaException(const serverIdl::XmlBlasterException& ex); 00133 static serverIdl::XmlBlasterException 00134 convertToCorbaException(org::xmlBlaster::util::XmlBlasterException& ex); 00135 00141 std::string getType() { static std::string type = org::xmlBlaster::util::Constants::IOR; return type; } 00142 00148 std::string getVersion() { static std::string version = "1.0"; return version; } 00149 }; 00150 00151 }}}}} // namespaces 00152 00153 #endif