00001
00002
00003 #include "tao/Strategies/OC_Endpoint_Selector_Factory.h"
00004 #include "tao/Strategies/Optimized_Connection_Endpoint_Selector.h"
00005 #include "ace/Log_Msg.h"
00006 #include "tao/ORB_Core.h"
00007 #include "ace/OS.h"
00008
00009 ACE_RCSID (tao,
00010 OC_Endpoint_Selector_Factory,
00011 "OC_Endpoint_Selector_Factory.cpp,v 1.3 2006/03/10 07:19:18 jtc Exp")
00012
00013 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00014
00015 TAO_OC_Endpoint_Selector_Factory::TAO_OC_Endpoint_Selector_Factory (void)
00016 : oc_endpoint_selector_(0)
00017 {
00018 }
00019
00020 TAO_OC_Endpoint_Selector_Factory::~TAO_OC_Endpoint_Selector_Factory (void)
00021 {
00022 delete this->oc_endpoint_selector_;
00023 }
00024
00025 int
00026 TAO_OC_Endpoint_Selector_Factory::init (int argc, ACE_TCHAR *argv[])
00027 {
00028 ACE_Time_Value timeout(0,0);
00029
00030 TAO_ORB_Core::set_endpoint_selector_factory ("OC_Endpoint_Selector_Factory");
00031 for (int count = 0; count < argc; count++)
00032 {
00033 if ((ACE_OS::strcasecmp (argv[count],
00034 ACE_TEXT ("-connect_timeout")) == 0) &&
00035 count < argc-1)
00036 {
00037 count++;
00038 long ms = ACE_OS::strtol(argv[count],0,10);
00039 timeout.msec (ms);
00040 }
00041 }
00042
00043 ACE_NEW_RETURN (this->oc_endpoint_selector_,
00044 TAO_Optimized_Connection_Endpoint_Selector(timeout),
00045 -1);
00046 return 0;
00047 }
00048
00049
00050 TAO_Invocation_Endpoint_Selector *
00051 TAO_OC_Endpoint_Selector_Factory::get_selector ( ACE_ENV_SINGLE_ARG_DECL_NOT_USED )
00052 {
00053
00054 return this->oc_endpoint_selector_;
00055 }
00056
00057 TAO_END_VERSIONED_NAMESPACE_DECL
00058
00059
00060
00061 ACE_STATIC_SVC_DEFINE (TAO_OC_Endpoint_Selector_Factory,
00062 ACE_TEXT ("OC_Endpoint_Selector_Factory"),
00063 ACE_SVC_OBJ_T,
00064 &ACE_SVC_NAME (TAO_OC_Endpoint_Selector_Factory),
00065 ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ,
00066 0)
00067 ACE_FACTORY_DEFINE (TAO_Strategies, TAO_OC_Endpoint_Selector_Factory)