Go to the documentation of this file.00001
00002
00003 #include "tao/Strategies/OC_Endpoint_Selector_Factory.h"
00004 #include "tao/Strategies/Optimized_Connection_Endpoint_Selector.h"
00005 #include "tao/Strategies/Strategies_ORBInitializer.h"
00006 #include "tao/ORBInitializer_Registry.h"
00007 #include "tao/PI/ORBInitInfo.h"
00008 #include "ace/Log_Msg.h"
00009 #include "tao/ORB_Core.h"
00010 #include "ace/OS.h"
00011
00012 ACE_RCSID (tao,
00013 OC_Endpoint_Selector_Factory,
00014 "$Id: OC_Endpoint_Selector_Factory.cpp 84281 2009-01-30 15:01:17Z wotte $")
00015
00016 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00017
00018 TAO_OC_Endpoint_Selector_Factory::TAO_OC_Endpoint_Selector_Factory (void)
00019 : oc_endpoint_selector_(0)
00020 {
00021 }
00022
00023 TAO_OC_Endpoint_Selector_Factory::~TAO_OC_Endpoint_Selector_Factory (void)
00024 {
00025 delete this->oc_endpoint_selector_;
00026 }
00027
00028 int
00029 TAO_OC_Endpoint_Selector_Factory::init (int argc, ACE_TCHAR *argv[])
00030 {
00031 ACE_Time_Value connect_timeout(0,0);
00032
00033 for (int count = 0; count < argc; count++)
00034 {
00035 if ((ACE_OS::strcasecmp (argv[count],
00036 ACE_TEXT ("-connect_timeout")) == 0) &&
00037 count < argc-1)
00038 {
00039 ++count;
00040 long const ms = ACE_OS::strtol(argv[count],0,10);
00041 connect_timeout.msec (ms);
00042 }
00043 }
00044
00045 if (this->register_orb_initializer () == -1)
00046 return -1;
00047
00048 ACE_NEW_RETURN (this->oc_endpoint_selector_,
00049 TAO_Optimized_Connection_Endpoint_Selector(connect_timeout),
00050 -1);
00051 return 0;
00052 }
00053
00054 int
00055 TAO_OC_Endpoint_Selector_Factory::register_orb_initializer (void)
00056 {
00057
00058 try
00059 {
00060 PortableInterceptor::ORBInitializer_ptr temp_orb_initializer =
00061 PortableInterceptor::ORBInitializer::_nil ();
00062
00063
00064 ACE_NEW_THROW_EX (temp_orb_initializer,
00065 TAO_Strategies_ORBInitializer,
00066 CORBA::NO_MEMORY (
00067 CORBA::SystemException::_tao_minor_code (
00068 TAO::VMCID,
00069 ENOMEM),
00070 CORBA::COMPLETED_NO));
00071
00072 PortableInterceptor::ORBInitializer_var orb_initializer;
00073 orb_initializer = temp_orb_initializer;
00074
00075 PortableInterceptor::register_orb_initializer (orb_initializer.in ());
00076 }
00077 catch (const ::CORBA::Exception& ex)
00078 {
00079 ex._tao_print_exception (
00080 "Unexpected exception caught while "
00081 "initializing the Strategies library");
00082 return -1;
00083 }
00084
00085 return 0;
00086 }
00087
00088 TAO_Invocation_Endpoint_Selector *
00089 TAO_OC_Endpoint_Selector_Factory::get_selector (void)
00090 {
00091
00092 return this->oc_endpoint_selector_;
00093 }
00094
00095
00096
00097
00098 ACE_STATIC_SVC_DEFINE (TAO_OC_Endpoint_Selector_Factory,
00099 ACE_TEXT ("OC_Endpoint_Selector_Factory"),
00100 ACE_SVC_OBJ_T,
00101 &ACE_SVC_NAME (TAO_OC_Endpoint_Selector_Factory),
00102 ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ,
00103 0)
00104 ACE_FACTORY_DEFINE (TAO_Strategies, TAO_OC_Endpoint_Selector_Factory)
00105
00106 TAO_END_VERSIONED_NAMESPACE_DECL