1 #include "tao/ORBInitializer_Registry.h"
2 #include "tao/ORBInitializer_Registry_Adapter.h"
3 #include "tao/PortableInterceptorC.h"
5 #include "tao/ORB_Constants.h"
6 #include "tao/TAO_Singleton_Manager.h"
7 #include "tao/SystemException.h"
9 #include "ace/Service_Config.h"
10 #include "ace/Dynamic_Service.h"
11 #include "ace/Static_Object_Lock.h"
12 #include "ace/Recursive_Thread_Mutex.h"
13 #include "ace/Log_Msg.h"
15 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
17 namespace PortableInterceptor
20 register_orb_initializer (ORBInitializer_ptr init
)
23 // Using ACE_Static_Object_Lock::instance() precludes
24 // register_orb_initializer() from being called within a static
26 ACE_MT (ACE_GUARD (TAO_SYNCH_RECURSIVE_MUTEX
,
28 *ACE_Static_Object_Lock::instance ()));
30 // Make sure TAO's singleton manager is initialized.
31 if (TAO_Singleton_Manager::instance ()->init () == -1)
33 TAOLIB_ERROR ((LM_ERROR
,
34 ACE_TEXT ("TAO (%P|%t) - register_orb_initializer: ")
35 ACE_TEXT ("Unable to pre-initialize TAO\n")));
39 // If not, look it up.
40 TAO::ORBInitializer_Registry_Adapter
*orbinitializer_registry_
=
41 ACE_Dynamic_Service
<TAO::ORBInitializer_Registry_Adapter
>::instance
42 ("ORBInitializer_Registry", true); // only look in the local repo
44 #if !defined (TAO_AS_STATIC_LIBS)
45 if (orbinitializer_registry_
== nullptr)
47 ACE_Service_Config::process_directive (
48 ACE_DYNAMIC_VERSIONED_SERVICE_DIRECTIVE("ORBInitializer_Registry",
51 "_make_ORBInitializer_Registry",
53 orbinitializer_registry_
=
54 ACE_Dynamic_Service
<TAO::ORBInitializer_Registry_Adapter
>::instance
55 ("ORBInitializer_Registry");
57 #endif /* !TAO_AS_STATIC_LIBS */
59 if (orbinitializer_registry_
!= nullptr)
61 orbinitializer_registry_
->register_orb_initializer (init
);
65 TAOLIB_ERROR ((LM_ERROR
,
66 ACE_TEXT ("TAO (%P|%t) %p\n"),
67 ACE_TEXT ("ERROR: ORBInitializer Registry unable to find the ")
68 ACE_TEXT ("ORBInitializer Registry instance")));
70 throw ::CORBA::INTERNAL ();
75 TAO_END_VERSIONED_NAMESPACE_DECL