00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef _TWEEK_CORBA_MANAGER_H_
00038 #define _TWEEK_CORBA_MANAGER_H_
00039
00040 #include <tweek/tweekConfig.h>
00041
00042 #include <stdlib.h>
00043 #include <string>
00044 #include TWEEK_INCLUDE_CORBA_H
00045 #include <vpr/Thread/Thread.h>
00046 #include <vpr/Util/ReturnStatus.h>
00047
00048 #include <tweek/CORBA/SubjectManagerImpl.h>
00049
00050
00051 namespace tweek
00052 {
00053
00054 class BeanDeliverySubjectImpl;
00055
00056 class TWEEK_CLASS_API CorbaManager
00057 {
00058 public:
00062 CorbaManager();
00063
00074 ~CorbaManager()
00075 {
00076 shutdown();
00077
00078 if ( mOrbThread != NULL )
00079 {
00080 delete mOrbThread;
00081 mOrbThread = NULL;
00082 delete mOrbFunctor;
00083 mOrbFunctor = NULL;
00084 }
00085 }
00086
00115 vpr::ReturnStatus init(const std::string& localId, int& argc, char** argv,
00116 const std::string& nsHost = std::string(""),
00117 const vpr::Uint16& nsPort = vpr::Uint16(2809),
00118 const std::string& iiopVersion = std::string("1.0"));
00119
00130 void shutdown(bool wait_for_completion = true);
00131
00139 bool isValid() const
00140 {
00141 return ! (CORBA::is_nil(mORB) || CORBA::is_nil(mRootPOA));
00142 }
00143
00147 vpr::ReturnStatus createSubjectManager();
00148
00159 vpr::ReturnStatus destroySubjectManager();
00160
00165 tweek::SubjectManagerImpl* getSubjectManager() const
00166 {
00167 return mSubjectManager;
00168 }
00169
00170 const PortableServer::POA_var& getRootPOA() const
00171 {
00172 return mRootPOA;
00173 }
00174
00175 const PortableServer::POA_var& getChildPOA() const
00176 {
00177 return mChildPOA;
00178 }
00179
00180 BeanDeliverySubjectImpl* getBeanDeliverySubject() const
00181 {
00182 return mBeanDeliverySubject;
00183 }
00184
00189 void run();
00190
00191 private:
00192 vpr::ReturnStatus createChildPOA(const std::string& local_id);
00193
00194 std::string mAppName;
00195
00196 vpr::ThreadRunFunctor<tweek::CorbaManager>* mOrbFunctor;
00197 vpr::Thread* mOrbThread;
00198
00199 CORBA::ORB_var mORB;
00200 PortableServer::POA_var mRootPOA;
00201 PortableServer::POA_var mChildPOA;
00202 CosNaming::NamingContext_var mRootContext;
00203 CosNaming::NamingContext_var mLocalContext;
00204
00205 tweek::SubjectManagerImpl* mSubjectManager;
00206 PortableServer::ObjectId_var mSubjectManagerId;
00207 CosNaming::Name mSubjectManagerName;
00208
00209 BeanDeliverySubjectImpl* mBeanDeliverySubject;
00210
00212 static const std::string DELIVERY_SUBJECT_NAME;
00213 };
00214
00215 }
00216
00217 #endif