2 #include "ace/Arg_Shifter.h"
3 #include "ace/Argv_Type_Converter.h"
4 #include "ace/OS_NS_unistd.h"
5 #include "tao/TAO_Singleton_Manager.h"
8 : failPrePostInit_ (3),
19 DllORB::init (int argc
, ACE_TCHAR
*argv
[])
23 if (failPrePostInit_
< 3)
26 ACE_TEXT ("Pre-ORB initialization ...\n")));
27 // -----------------------------------------------------------------
28 // Pre-ORB initialization steps necessary for proper DLL ORB
30 // -----------------------------------------------------------------
31 // Make sure TAO's singleton manager is initialized, and set to not
32 // register itself with the ACE_Object_Manager since it is under the
33 // control of the Service Configurator. If we register with the
34 // ACE_Object_Manager, then the ACE_Object_Manager will still hold
35 // (dangling) references to instances of objects created by this
36 // module and destroyed by this object when it is dynamically
38 int register_with_object_manager
= 0;
39 TAO_Singleton_Manager
* p_tsm
= TAO_Singleton_Manager::instance ();
40 int result
= p_tsm
->init (register_with_object_manager
);
44 if (failPrePostInit_
== 0)
47 ACE_TEXT ("Pre-ORB initialization failed.\n")));
50 else if (failPrePostInit_
< 2)
52 ACE_DEBUG ((LM_WARNING
,
53 ACE_TEXT ("Pre-ORB initialization failed (ignored due to FailPrePostInit setting).\n")));
58 ACE_TEXT ("Pre-ORB initialization failed (ignored due to FailPrePostInit setting).\n")));
64 ACE_TEXT ("Pre-ORB initialization done.\n")));
69 mv_orb_
= CORBA::ORB_init (argc
, argv
);
70 if (CORBA::is_nil (mv_orb_
.in ()))
72 ACE_DEBUG ((LM_ERROR
, ACE_TEXT ("nil ORB\n")));
76 CORBA::Object_var v_poa
=
77 mv_orb_
->resolve_initial_references ("RootPOA");
79 mv_rootPOA_
= PortableServer::POA::_narrow (v_poa
.in ());
80 if (CORBA::is_nil (mv_rootPOA_
.in ()))
82 ACE_DEBUG ((LM_ERROR
, ACE_TEXT ("nil RootPOA\n")));
86 mv_poaManager_
= mv_rootPOA_
->the_POAManager ();
87 if (CORBA::is_nil (mv_poaManager_
.in ()))
89 ACE_DEBUG ((LM_ERROR
, ACE_TEXT ("nil POAManager\n")));
93 mv_poaManager_
->activate ();
97 ACE_DEBUG ((LM_ERROR
, ACE_TEXT ("ERROR: exception\n")));
110 mv_poaManager_
= PortableServer::POAManager::_nil ();
112 // attempt to protect against sporadic BAD_INV_ORDER exceptions
113 ACE_OS::sleep (ACE_Time_Value (0, 500));
115 mv_orb_
->shutdown (true);
119 ACE_DEBUG ((LM_ERROR
, ACE_TEXT ("ERROR: exception\n")));
126 mv_orb_
= CORBA::ORB::_nil ();
128 catch (const CORBA::Exception
& ex
)
130 ex
._tao_print_exception ("Exception caught:");
134 if (failPrePostInit_
< 3)
136 // -----------------------------------------------------------------
137 // Post-ORB finalization steps necessary for proper DLL ORB
139 // -----------------------------------------------------------------
140 // Explicitly clean up singletons created by TAO before
141 // unloading this module.
142 TAO_Singleton_Manager
* p_tsm
= TAO_Singleton_Manager::instance ();
143 int result
= p_tsm
->fini ();
146 if (failPrePostInit_
== 0)
148 ACE_DEBUG ((LM_ERROR
,
149 ACE_TEXT ("Post-ORB finalization failed.\n")));
152 else if (failPrePostInit_
< 2)
154 ACE_DEBUG ((LM_WARNING
,
155 ACE_TEXT ("Post-ORB finalization failed (ignored due to FailPrePostInit setting).\n")));
160 ACE_TEXT ("Post-ORB finalization failed (ignored due to FailPrePostInit setting).\n")));
166 ACE_TEXT ("Post-ORB finalization done.\n")));
174 ACE_FACTORY_DEFINE (bug_2677_regression
, DllORB
)