KAssistantServer.cpp
Upload User: dzyhzl
Upload Date: 2019-04-29
Package Size: 56270k
Code Size: 3k
Development Platform:

C/C++

  1. #include "KAssistantServer.h"
  2. #include "iostream.h"
  3. #include "Stdio.h"
  4. /*
  5. CORBA::Long KAssistantServer::ExecuteSeq(const MessageSeq& MsgSeq, const char* DataServerName)
  6. {
  7. long len = MsgSeq.length();
  8.  
  9. for(long i = 0; i < len; i ++)
  10. {
  11.  Execute( MsgSeq[i] ,DataServerName);
  12. }
  13. return 1;
  14. }
  15. */
  16. extern CORBA::Boolean BindObjectToName(CORBA::ORB_ptr orb, CORBA::Object_ptr objref, char * ObjName, char * ObjType);
  17. BOOL KAssistantServer::ServerInit(int argc = 0, char **argv = NULL)
  18. {
  19. try
  20. {
  21.  m_OrbVar  = CORBA::ORB_init(argc, argv, "omniORB3");
  22.      m_ObjVar = m_OrbVar->resolve_initial_references("RootPOA");
  23.      m_PoaVar = PortableServer::POA::_narrow(m_ObjVar);
  24. }
  25.   
  26. catch(CORBA::SystemException&) {
  27.     cerr << "Caught CORBA::SystemException6." << endl;
  28. return FALSE;
  29.   }
  30.   catch(CORBA::Exception&) {
  31.     cerr << "Caught CORBA::Exception." << endl;
  32. return FALSE;
  33.   }
  34.   catch(omniORB::fatalException& fe) {
  35.     cerr << "Caught omniORB::fatalException:" << endl;
  36.     cerr << "  file: " << fe.file() << endl;
  37.     cerr << "  line: " << fe.line() << endl;
  38.     cerr << "  mesg: " << fe.errmsg() << endl;
  39. return FALSE;
  40.   }
  41.   catch(...) {
  42.     cerr << "Caught unknown exception." << endl;
  43. return FALSE;
  44.   }
  45. return TRUE;
  46. }
  47. BOOL KAssistantServer::CreateServer(char * ServerName ,char * ServerType)
  48. {
  49. try
  50. {
  51. strcpy(m_ServerName, ServerName);
  52. strcpy(m_ServerType, ServerType);
  53. PortableServer::ObjectId_var ObjId = m_PoaVar->activate_object(this);
  54.     // Obtain a reference to the object, and register it in
  55.     // the naming service.
  56.     m_ObjVar = this->_this();
  57.   if (!BindObjectToName(m_OrbVar,m_ObjVar,m_ServerName,m_ServerType))
  58.       return FALSE;
  59.     this->_remove_ref();
  60. m_Sior=(m_OrbVar->object_to_string(m_ObjVar));
  61.     
  62.     m_PoaManager = m_PoaVar->the_POAManager();
  63.     m_PoaManager->activate();
  64. printf("KAssistantServer[%s.%s] Have Started!.........nsior is:%sn",m_ServerName,m_ServerType,(char*)m_Sior);
  65. m_OrbVar->run();
  66.     m_OrbVar->destroy();
  67. }
  68. catch(CORBA::SystemException&)  
  69. {
  70. cerr << "Caught CORBA::SystemException6." << endl;
  71. }
  72. catch(CORBA::Exception&) {
  73. cerr << "Caught CORBA::Exception." << endl;
  74. }
  75. catch(omniORB::fatalException& fe) {
  76. cerr << "Caught omniORB::fatalException:" << endl;
  77. cerr << "  file: " << fe.file() << endl;
  78. cerr << "  line: " << fe.line() << endl;
  79. cerr << "  mesg: " << fe.errmsg() << endl;
  80. }
  81. catch(...) {
  82. cerr << "Caught unknown exception." << endl;
  83. }
  84. }
  85. BOOL KAssistantServer::ShutDownServer()
  86. {
  87. return TRUE;
  88. }