server.cpp
Go to the documentation of this file.
00001 #include <iostream>
00002 #include "Hello.hh"
00003 
00004 class World_impl: public POA_Hello::World,
00005                   public PortableServer::RefCountServantBase
00006 {
00007   virtual char * hello ()
00008   {
00009     return CORBA::string_dup ("Greetings from C++ World server!!");
00010   }
00011 };
00012 
00013 int main (int argc, char **argv)
00014 {
00015   try {
00016     // Initialize the ORB
00017     CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
00018 
00019     // Get the Root POA
00020     CORBA::Object_var obj = orb->resolve_initial_references ("RootPOA");
00021     PortableServer::POA_var poa = PortableServer::POA::_narrow (obj);
00022 
00023     // Activate POA manager
00024     PortableServer::POAManager_var mgr = poa->the_POAManager ();
00025     mgr->activate ();
00026 
00027     // Create the servant(s)
00028     //World_impl world_servant;
00029     World_impl world_servant;
00030 
00031     // Activate object implicitly by calling _this()
00032     Hello::World_var world = world_servant._this ();
00033 
00034     // Write stringified reference to stdout
00035     CORBA::String_var str = orb->object_to_string (world);
00036     std::cout << str << std::endl;
00037 
00038     // Accept requests
00039     orb->run ();
00040   }
00041   catch (const CORBA::Exception & e)
00042   {
00043     std::cerr << "Server caught CORBA exception: " << std::endl;
00044     return 100;
00045   }
00046   return 0;
00047 }
00048 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Friends


agentsystem_examples
Author(s): k-okada
autogenerated on Thu Jun 27 2013 14:58:26