Go to the documentation of this file.00001
00002
00003 #include "tao/Messaging/Messaging_ORBInitializer.h"
00004
00005 #include "tao/Messaging/Messaging_Policy_i.h"
00006 #include "tao/Messaging/Connection_Timeout_Policy_i.h"
00007 #include "tao/Messaging/Messaging_PolicyFactory.h"
00008 #include "tao/Messaging/ExceptionHolder_i.h"
00009 #include "tao/Messaging/Messaging_Queueing_Strategies.h"
00010 #include "tao/ORB_Core.h"
00011 #include "tao/Transport_Queueing_Strategies.h"
00012 #include "tao/PI/ORBInitInfo.h"
00013 #include "tao/Valuetype/ValueFactory.h"
00014
00015 ACE_RCSID (Messaging,
00016 Messaging_ORBInitializer,
00017 "$Id: Messaging_ORBInitializer.cpp 80370 2008-01-04 09:47:58Z vzykov $")
00018
00019 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00020
00021 void
00022 TAO_Messaging_ORBInitializer::pre_init (PortableInterceptor::ORBInitInfo_ptr info)
00023 {
00024 #if ((TAO_HAS_RELATIVE_ROUNDTRIP_TIMEOUT_POLICY == 1) || \
00025 (TAO_HAS_BUFFERING_CONSTRAINT_POLICY == 1) || \
00026 (TAO_HAS_SYNC_SCOPE_POLICY == 1))
00027 TAO_ORBInitInfo_var tao_info = TAO_ORBInitInfo::_narrow (info);
00028
00029 if (CORBA::is_nil (tao_info.in ()))
00030 {
00031 if (TAO_debug_level > 0)
00032 ACE_ERROR ((LM_ERROR,
00033 "(%P|%t) TAO_Messaging_ORBInitializer::pre_init:\n"
00034 "(%P|%t) Unable to narrow "
00035 "\"PortableInterceptor::ORBInitInfo_ptr\" to\n"
00036 "(%P|%t) \"TAO_ORBInitInfo *.\"\n"));
00037
00038 throw ::CORBA::INTERNAL ();
00039 }
00040 #else
00041 ACE_UNUSED_ARG (info);
00042 #endif
00043
00044 #if (TAO_HAS_BUFFERING_CONSTRAINT_POLICY == 1)
00045 TAO::Transport_Queueing_Strategy* queuing_strategy = 0;
00046 ACE_NEW (queuing_strategy,
00047 TAO::Eager_Transport_Queueing_Strategy);
00048 tao_info->orb_core ()->set_eager_transport_queueing_strategy (queuing_strategy);
00049
00050 ACE_NEW (queuing_strategy,
00051 TAO::Delayed_Transport_Queueing_Strategy);
00052 tao_info->orb_core ()->set_delayed_transport_queueing_strategy (queuing_strategy);
00053 #endif
00054
00055 #if (TAO_HAS_RELATIVE_ROUNDTRIP_TIMEOUT_POLICY == 1)
00056 tao_info->orb_core ()->set_timeout_hook (TAO_RelativeRoundtripTimeoutPolicy::hook);
00057 #endif
00058
00059 #if (TAO_HAS_SYNC_SCOPE_POLICY == 1)
00060 tao_info->orb_core ()->set_sync_scope_hook (TAO_Sync_Scope_Policy::hook);
00061 #endif
00062
00063 #if (TAO_HAS_CONNECTION_TIMEOUT_POLICY == 1)
00064 TAO_ORB_Core::connection_timeout_hook (TAO_ConnectionTimeoutPolicy::hook);
00065 #endif
00066
00067 }
00068
00069 void
00070 TAO_Messaging_ORBInitializer::post_init (
00071 PortableInterceptor::ORBInitInfo_ptr info)
00072 {
00073 this->register_policy_factories (info);
00074
00075 this->register_value_factory (info);
00076 }
00077
00078 void
00079 TAO_Messaging_ORBInitializer::register_value_factory (
00080 PortableInterceptor::ORBInitInfo_ptr info)
00081 {
00082
00083
00084 TAO_ORBInitInfo_var tao_info =
00085 TAO_ORBInitInfo::_narrow (info);
00086
00087 if (CORBA::is_nil (tao_info.in ()))
00088 {
00089 if (TAO_debug_level > 0)
00090 ACE_ERROR ((LM_ERROR,
00091 "(%P|%t) TAO_Messaging_ORBInitializer::register_value_factory:\n"
00092 "(%P|%t) Unable to narrow "
00093 "\"PortableInterceptor::ORBInitInfo_ptr\" to\n"
00094 "(%P|%t) \"TAO_ORBInitInfo *.\"\n"));
00095
00096 throw ::CORBA::INTERNAL ();
00097 }
00098
00099 TAO::ExceptionHolderFactory *base_factory = 0;
00100 ACE_NEW (base_factory,
00101 TAO::ExceptionHolderFactory);
00102 CORBA::ValueFactory_var factory = base_factory;
00103
00104 CORBA::ValueFactory_var old_factory =
00105 tao_info->orb_core()->orb ()->register_value_factory (
00106 Messaging::ExceptionHolder::_tao_obv_static_repository_id (),
00107 base_factory);
00108 }
00109 void
00110 TAO_Messaging_ORBInitializer::register_policy_factories (
00111 PortableInterceptor::ORBInitInfo_ptr info)
00112 {
00113
00114
00115 PortableInterceptor::PolicyFactory_ptr policy_factory_ptr;
00116 ACE_NEW_THROW_EX (policy_factory_ptr,
00117 TAO_Messaging_PolicyFactory,
00118 CORBA::NO_MEMORY (
00119 CORBA::SystemException::_tao_minor_code (
00120 TAO::VMCID,
00121 ENOMEM),
00122 CORBA::COMPLETED_NO));
00123
00124
00125 PortableInterceptor::PolicyFactory_var policy_factory =
00126 policy_factory_ptr;
00127
00128
00129
00130
00131
00132 CORBA::PolicyType type[] = {
00133 #if (TAO_HAS_RELATIVE_REQUEST_TIMEOUT_POLICY == 1)
00134 Messaging::RELATIVE_RT_TIMEOUT_POLICY_TYPE,
00135 #endif
00136 #if (TAO_HAS_SYNC_SCOPE_POLICY == 1)
00137 Messaging::SYNC_SCOPE_POLICY_TYPE,
00138 #endif
00139 #if (TAO_HAS_BUFFERING_CONSTRAINT_POLICY == 1)
00140 TAO::BUFFERING_CONSTRAINT_POLICY_TYPE,
00141 #endif
00142 #if (TAO_HAS_REBIND_POLICY == 1)
00143 Messaging::REBIND_POLICY_TYPE,
00144 #endif
00145 #if (TAO_HAS_PRIORITY_POLICIES == 1)
00146 Messaging::REQUEST_PRIORITY_POLICY_TYPE,
00147 Messaging::REPLY_PRIORITY_POLICY_TYPE,
00148 #endif
00149 #if (TAO_HAS_REQUEST_START_TIME_POLICY == 1)
00150 Messaging::REQUEST_START_TIME_POLICY_TYPE,
00151 #endif
00152 #if (TAO_HAS_REQUEST_END_TIME_POLICY == 1)
00153 Messaging::REQUEST_END_TIME_POLICY_TYPE,
00154 #endif
00155 #if (TAO_HAS_REPLY_START_TIME_POLICY == 1)
00156 Messaging::REPLY_START_TIME_POLICY_TYPE,
00157 #endif
00158 #if (TAO_HAS_REPLY_END_TIME_POLICY == 1)
00159 Messaging::REPLY_END_TIME_POLICY_TYPE,
00160 #endif
00161 #if (TAO_HAS_RELATIVE_REQUEST_TIMEOUT_POLICY == 1)
00162 Messaging::RELATIVE_REQ_TIMEOUT_POLICY_TYPE,
00163 #endif
00164 #if (TAO_HAS_ROUTING_POLICY == 1)
00165 Messaging::ROUTING_POLICY_TYPE,
00166 #endif
00167 #if (TAO_HAS_MAX_HOPS_POLICY == 1)
00168 Messaging::MAX_HOPS_POLICY_TYPE,
00169 #endif
00170 Messaging::QUEUE_ORDER_POLICY_TYPE,
00171 #if (TAO_HAS_CONNECTION_TIMEOUT_POLICY == 1)
00172 TAO::CONNECTION_TIMEOUT_POLICY_TYPE
00173 #endif
00174 };
00175
00176 const CORBA::PolicyType *end = type + sizeof (type) / sizeof (type[0]);
00177 for (CORBA::PolicyType *i = type; i != end; ++i)
00178 {
00179 try
00180 {
00181 info->register_policy_factory (*i, policy_factory.in ());
00182 }
00183 catch (const ::CORBA::BAD_INV_ORDER& ex)
00184 {
00185 if (ex.minor () == (CORBA::OMGVMCID | 16))
00186 {
00187
00188
00189
00190
00191 return;
00192 }
00193 throw;
00194 }
00195 }
00196 }
00197
00198 TAO_END_VERSIONED_NAMESPACE_DECL