Merge pull request #2303 from jwillemsen/jwi-803
[ACE_TAO.git] / TAO / tests / Client_Leaks / child.cpp
blob7e97d72bacdfbbe1e529e865fb5e68f733b58a79
1 #include "Process.h"
2 #include "ace/Get_Opt.h"
4 int
5 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
7 try
9 CORBA::ORB_var orb =
10 CORBA::ORB_init (argc, argv);
12 if (argc < 2)
14 // Paranoia, we should have an auto_ptr-like gadget for
15 // this.
16 orb->destroy ();
18 ACE_ERROR_RETURN ((LM_ERROR,
19 "Usage: %s <ior>\n",
20 argv[0]), 1);
23 CORBA::Object_var object =
24 orb->string_to_object (argv[1]);
25 Test::Startup_Callback_var startup_callback =
26 Test::Startup_Callback::_narrow (object.in ());
27 if (CORBA::is_nil (startup_callback.in ()))
29 ACE_ERROR_RETURN ((LM_ERROR,
30 "ERROR: nil startup callback\n"),
31 1);
34 CORBA::Object_var poa_object =
35 orb->resolve_initial_references("RootPOA");
37 PortableServer::POA_var root_poa =
38 PortableServer::POA::_narrow (poa_object.in ());
40 if (CORBA::is_nil (root_poa.in ()))
41 ACE_ERROR_RETURN ((LM_ERROR,
42 " (%P|%t) Panic: nil RootPOA\n"),
43 1);
45 PortableServer::POAManager_var poa_manager =
46 root_poa->the_POAManager ();
48 Process *process_impl = 0;
49 ACE_NEW_RETURN (process_impl,
50 Process (orb.in ()),
51 1);
52 PortableServer::ServantBase_var owner_transfer(process_impl);
54 PortableServer::ObjectId_var id =
55 root_poa->activate_object (process_impl);
57 CORBA::Object_var object_act = root_poa->id_to_reference (id.in ());
59 Test::Process_var process =
60 Test::Process::_narrow (object_act.in ());
62 poa_manager->activate ();
64 startup_callback->started (process.in ());
66 ACE_Time_Value tv (50, 0);
67 orb->run (tv);
69 root_poa->destroy (true, true);
71 orb->destroy ();
73 catch (const CORBA::Exception&)
75 // Do not print error messages, they only make the test output
76 // confusing.
77 return 1;
80 return 0;