Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / tests / OBV / Indirection / MessengerServer.cpp
blob21a4c088e53ea40b88dad85e026e2dd2a6a7dc19
1 #include "Messenger_i.h"
2 #include "Factory.h"
4 #include <iostream>
5 #include <fstream>
6 #include <fstream>
8 const char* server_ior_file = "server.ior";
11 void write_ior(const char* ior) {
12 std::ofstream out(server_ior_file);
13 out << ior;
16 int ACE_TMAIN (int ac, ACE_TCHAR* av[])
18 try
20 CORBA::ORB_var orb = CORBA::ORB_init(ac, av);
22 NodeFactory::register_new_factory(* orb.in());
23 BoxedValueFactory::register_new_factory(* orb.in());
24 BaseValueFactory::register_new_factory(* orb.in());
25 TValueFactory::register_new_factory(* orb.in());
26 ConfigValueFactory::register_new_factory(* orb.in());
28 CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
29 PortableServer::POA_var poa = PortableServer::POA::_narrow(obj.in());
31 PortableServer::POAManager_var poaman = poa->the_POAManager();
33 PortableServer::Servant_var<Messenger_i> svt = new Messenger_i;
35 PortableServer::ObjectId_var id = poa->activate_object(svt.in());
36 obj = poa->id_to_reference(id.in());
37 CORBA::String_var ior = orb->object_to_string(obj.in());
38 write_ior(ior.in());
40 std::cout << "Starting server." << std::endl;
42 poaman->activate();
44 orb->run();
46 poa->destroy(true, true);
47 orb->destroy();
49 catch (const CORBA::Exception& ex)
51 ex._tao_print_exception ("Exception caught:");
52 return 1;
55 return 0;