Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / tao / Dynamic_TP / DTP_ORB_Loader.cpp
blobe6d46069100330e63d728f678942747747e25f2c
1 #include "tao/Dynamic_TP/DTP_ORB_Loader.h"
3 #if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0
5 #include "tao/Dynamic_TP/DTP_ORBInitializer.h"
7 #include "tao/debug.h"
8 #include "tao/ORB_Constants.h"
9 #include "tao/ORBInitializer_Registry.h"
10 #include "tao/SystemException.h"
11 #include "ace/Dynamic_Service.h"
12 #include "ace/OS_NS_strings.h"
13 #include "ace/Arg_Shifter.h"
15 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
17 TAO_DTP_ORB_Loader::TAO_DTP_ORB_Loader ()
18 : initialized_ (false)
22 TAO_DTP_ORB_Loader::~TAO_DTP_ORB_Loader ()
26 int
27 TAO_DTP_ORB_Loader::init (int argc, ACE_TCHAR* argv[])
29 ACE_TRACE ("TAO_DTP_ORB_Loader::init");
31 // Only allow initialization once.
32 if (this->initialized_)
33 return 0;
34 this->initialized_ = true;
36 int curarg = 0;
37 for (curarg = 0; curarg < argc; ++curarg)
39 if (ACE_OS::strcasecmp (argv[curarg], ACE_TEXT ("-DTPORB")) == 0)
41 ++curarg;
42 if (curarg >= argc)
44 if (TAO_debug_level > 0)
46 TAOLIB_DEBUG ((LM_DEBUG,
47 ACE_TEXT ("TAO (%P|%t) - DTP_ORB_Loader - ")
48 ACE_TEXT ("DTPORB argument missing value\n")));
50 return -1;
53 else
55 if (TAO_debug_level > 0)
57 TAOLIB_DEBUG ((LM_DEBUG,
58 ACE_TEXT ("TAO (%P|%t) - DTP_ORB_Loader -")
59 ACE_TEXT (" Unrecognized argv[%d], %C\n"),
60 curarg, argv[curarg]));
62 return -1;
66 // Register the ORB initializer.
67 try
69 PortableInterceptor::ORBInitializer_ptr temp_orb_initializer =
70 PortableInterceptor::ORBInitializer::_nil ();
72 /// Register the DynamicTP ORBInitializer.
73 ACE_NEW_THROW_EX (temp_orb_initializer,
74 TAO_DTP_ORBInitializer (),
75 CORBA::NO_MEMORY (
76 CORBA::SystemException::_tao_minor_code (
77 TAO::VMCID,
78 ENOMEM),
79 CORBA::COMPLETED_NO));
81 PortableInterceptor::ORBInitializer_var orb_initializer;
82 orb_initializer = temp_orb_initializer;
84 PortableInterceptor::register_orb_initializer (orb_initializer.in ());
86 catch (const ::CORBA::Exception& ex)
88 ex._tao_print_exception (
89 "Unexpected exception caught while "
90 "initializing the RTORB");
91 return 1;
94 return 0;
98 /////////////////////////////////////////////////////////////////////
100 ACE_FACTORY_DEFINE (TAO_Dynamic_TP, TAO_DTP_ORB_Loader)
101 ACE_STATIC_SVC_DEFINE (TAO_DTP_ORB_Loader,
102 ACE_TEXT ("DTP_ORB_Loader"),
103 ACE_SVC_OBJ_T,
104 &ACE_SVC_NAME (TAO_DTP_ORB_Loader),
105 ACE_Service_Type::DELETE_THIS
106 | ACE_Service_Type::DELETE_OBJ,
108 TAO_END_VERSIONED_NAMESPACE_DECL
110 #endif /* (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0 */