Revert "Minor modernization of DynamicAny code"
[ACE_TAO.git] / TAO / tests / ORB_shutdown / server.cpp
bloba58a78a46f161c8d4dc28e20b58df453e202907f
1 #include "Foo_Bar.h"
2 #include "ace/Time_Value.h"
3 #include "ace/Get_Opt.h"
5 int
6 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
8 try
10 CORBA::ORB_var orb =
11 CORBA::ORB_init (argc, argv);
13 CORBA::Object_var poa_object =
14 orb->resolve_initial_references("RootPOA");
16 PortableServer::POA_var root_poa =
17 PortableServer::POA::_narrow (poa_object.in ());
19 if (CORBA::is_nil (root_poa.in ()))
20 ACE_ERROR_RETURN ((LM_ERROR,
21 " (%P|%t) Panic: nil RootPOA\n"),
22 1);
24 PortableServer::POAManager_var poa_manager =
25 root_poa->the_POAManager ();
27 Foo_Bar *foobar_impl;
28 ACE_NEW_RETURN (foobar_impl,
29 Foo_Bar (orb.in ()),
30 1);
32 PortableServer::ObjectId_var id =
33 root_poa->activate_object (foobar_impl);
35 CORBA::Object_var object = root_poa->id_to_reference (id.in ());
37 Test::Foo_var foo =
38 Test::Foo::_narrow (object.in ());
40 poa_manager->activate ();
42 // Dont unscope it or move it elsewhere.. It is here with a
43 // purpose. If you dont understand this, please re-read the
44 // README file.
46 PortableServer::ServantBase_var owner_transfer (foobar_impl);
49 ACE_Time_Value tv (10,
50 0);
52 // Just run the ORB for a minute..
53 orb->run (tv);
55 ACE_DEBUG ((LM_DEBUG,
56 "(%P|%t) server - shutting down the ORB\n"));
58 orb->shutdown (true);
60 ACE_DEBUG ((LM_DEBUG,
61 "(%P|%t) Finished shutting down the ORB\n"));
63 root_poa->destroy (true, true);
65 orb->destroy ();
67 catch (const CORBA::Exception& ex)
69 ex._tao_print_exception ("Exception caught:");
70 return 1;
73 ACE_DEBUG ((LM_DEBUG,
74 "(%P|%t) Test successful..\n"));
75 return 0;