Revert "Minor modernization of DynamicAny code"
[ACE_TAO.git] / TAO / tao / Strategies / OC_Endpoint_Selector_Factory.cpp
blob9254ad45457a228c5b9ddf441769877d502f509e
1 #include "tao/Strategies/OC_Endpoint_Selector_Factory.h"
2 #include "tao/Strategies/Optimized_Connection_Endpoint_Selector.h"
3 #include "tao/Strategies/Strategies_ORBInitializer.h"
4 #include "tao/ORBInitializer_Registry.h"
5 #include "tao/PI/ORBInitInfo.h"
6 #include "ace/Log_Msg.h"
7 #include "tao/ORB_Core.h"
8 #include "ace/OS_NS_strings.h"
10 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
12 TAO_OC_Endpoint_Selector_Factory::~TAO_OC_Endpoint_Selector_Factory ()
14 delete this->oc_endpoint_selector_;
17 int
18 TAO_OC_Endpoint_Selector_Factory::init (int argc, ACE_TCHAR *argv[])
20 ACE_Time_Value connect_timeout(0,0);
22 for (int count = 0; count < argc; count++)
24 if ((ACE_OS::strcasecmp (argv[count],
25 ACE_TEXT ("-connect_timeout")) == 0) &&
26 count < argc-1)
28 ++count;
29 long const ms = ACE_OS::strtol(argv[count],0,10);
30 connect_timeout.msec (ms);
34 if (this->register_orb_initializer () == -1)
35 return -1;
37 ACE_NEW_RETURN (this->oc_endpoint_selector_,
38 TAO_Optimized_Connection_Endpoint_Selector(connect_timeout),
39 -1);
40 return 0;
43 int
44 TAO_OC_Endpoint_Selector_Factory::register_orb_initializer ()
46 // Register the ORB initializer.
47 try
49 PortableInterceptor::ORBInitializer_ptr temp_orb_initializer =
50 PortableInterceptor::ORBInitializer::_nil ();
52 /// Register the RTCORBA ORBInitializer.
53 ACE_NEW_THROW_EX (temp_orb_initializer,
54 TAO_Strategies_ORBInitializer,
55 CORBA::NO_MEMORY (
56 CORBA::SystemException::_tao_minor_code (
57 TAO::VMCID,
58 ENOMEM),
59 CORBA::COMPLETED_NO));
61 PortableInterceptor::ORBInitializer_var orb_initializer;
62 orb_initializer = temp_orb_initializer;
64 PortableInterceptor::register_orb_initializer (orb_initializer.in ());
66 catch (const ::CORBA::Exception& ex)
68 ex._tao_print_exception (
69 "Unexpected exception caught while "
70 "initializing the Strategies library");
71 return -1;
74 return 0;
77 TAO_Invocation_Endpoint_Selector *
78 TAO_OC_Endpoint_Selector_Factory::get_selector ()
80 // Trivial endpoint selector. Just return the default selector.
81 return this->oc_endpoint_selector_;
85 // ****************************************************************
87 ACE_STATIC_SVC_DEFINE (TAO_OC_Endpoint_Selector_Factory,
88 ACE_TEXT ("OC_Endpoint_Selector_Factory"),
89 ACE_SVC_OBJ_T,
90 &ACE_SVC_NAME (TAO_OC_Endpoint_Selector_Factory),
91 ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ,
93 ACE_FACTORY_DEFINE (TAO_Strategies, TAO_OC_Endpoint_Selector_Factory)
95 TAO_END_VERSIONED_NAMESPACE_DECL