Use =default for skeleton copy constructor
[ACE_TAO.git] / TAO / tao / Messaging / Messaging_ORBInitializer.cpp
blob54f0747569a4a6738a1a40bb69e88c4ca8428074
1 // -*- C++ -*-
2 #include "tao/Messaging/Messaging_ORBInitializer.h"
3 #include "tao/Messaging/Messaging_Policy_i.h"
4 #include "tao/Messaging/Connection_Timeout_Policy_i.h"
5 #include "tao/Messaging/Messaging_PolicyFactory.h"
6 #include "tao/Messaging/ExceptionHolder_i.h"
7 #include "tao/Messaging/Messaging_Queueing_Strategies.h"
8 #include "tao/ORB_Core.h"
9 #include "tao/Transport_Queueing_Strategies.h"
10 #include "tao/PI/ORBInitInfo.h"
11 #include "tao/Valuetype/ValueFactory.h"
13 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
15 void
16 TAO_Messaging_ORBInitializer::pre_init (PortableInterceptor::ORBInitInfo_ptr info)
18 #if ((TAO_HAS_RELATIVE_ROUNDTRIP_TIMEOUT_POLICY == 1) || \
19 (TAO_HAS_BUFFERING_CONSTRAINT_POLICY == 1) || \
20 (TAO_HAS_SYNC_SCOPE_POLICY == 1))
21 TAO_ORBInitInfo_var tao_info = TAO_ORBInitInfo::_narrow (info);
23 if (CORBA::is_nil (tao_info.in ()))
25 if (TAO_debug_level > 0)
26 TAOLIB_ERROR ((LM_ERROR,
27 "(%P|%t) TAO_Messaging_ORBInitializer::pre_init:\n"
28 "(%P|%t) Unable to narrow "
29 "\"PortableInterceptor::ORBInitInfo_ptr\" to\n"
30 "(%P|%t) \"TAO_ORBInitInfo *.\"\n"));
32 throw ::CORBA::INTERNAL ();
34 #else
35 ACE_UNUSED_ARG (info);
36 #endif
38 #if (TAO_HAS_BUFFERING_CONSTRAINT_POLICY == 1)
39 TAO::Transport_Queueing_Strategy* queuing_strategy = 0;
40 ACE_NEW (queuing_strategy,
41 TAO::Eager_Transport_Queueing_Strategy);
42 tao_info->orb_core ()->set_eager_transport_queueing_strategy (queuing_strategy);
44 ACE_NEW (queuing_strategy,
45 TAO::Delayed_Transport_Queueing_Strategy);
46 tao_info->orb_core ()->set_delayed_transport_queueing_strategy (queuing_strategy);
47 #endif
49 #if (TAO_HAS_RELATIVE_ROUNDTRIP_TIMEOUT_POLICY == 1)
50 tao_info->orb_core ()->set_timeout_hook (TAO_RelativeRoundtripTimeoutPolicy::hook);
51 #endif /* TAO_HAS_RELATIVE_ROUNDTRIP_TIMEOUT_POLICY == 1 */
53 #if (TAO_HAS_SYNC_SCOPE_POLICY == 1)
54 tao_info->orb_core ()->set_sync_scope_hook (TAO_Sync_Scope_Policy::hook);
55 #endif /* TAO_HAS_SYNC_SCOPE_POLICY == 1 */
57 #if (TAO_HAS_CONNECTION_TIMEOUT_POLICY == 1)
58 TAO_ORB_Core::connection_timeout_hook (TAO_ConnectionTimeoutPolicy::hook);
59 #endif /* TAO_HAS_CONNECTION_TIMEOUT_POLICY == 1 */
63 void
64 TAO_Messaging_ORBInitializer::post_init (
65 PortableInterceptor::ORBInitInfo_ptr info)
67 this->register_policy_factories (info);
69 this->register_value_factory (info);
72 void
73 TAO_Messaging_ORBInitializer::register_value_factory (
74 PortableInterceptor::ORBInitInfo_ptr info)
76 // Narrow to a TAO_ORBInitInfo object to get access to the
77 // orb_core() TAO extension.
78 TAO_ORBInitInfo_var tao_info =
79 TAO_ORBInitInfo::_narrow (info);
81 if (CORBA::is_nil (tao_info.in ()))
83 if (TAO_debug_level > 0)
84 TAOLIB_ERROR ((LM_ERROR,
85 "(%P|%t) TAO_Messaging_ORBInitializer::register_value_factory:\n"
86 "(%P|%t) Unable to narrow "
87 "\"PortableInterceptor::ORBInitInfo_ptr\" to\n"
88 "(%P|%t) \"TAO_ORBInitInfo *.\"\n"));
90 throw ::CORBA::INTERNAL ();
93 TAO::ExceptionHolderFactory *base_factory = 0;
94 ACE_NEW (base_factory,
95 TAO::ExceptionHolderFactory);
96 CORBA::ValueFactory_var factory = base_factory;
98 CORBA::ValueFactory_var old_factory =
99 tao_info->orb_core()->orb ()->register_value_factory (
100 Messaging::ExceptionHolder::_tao_obv_static_repository_id (),
101 base_factory);
103 void
104 TAO_Messaging_ORBInitializer::register_policy_factories (
105 PortableInterceptor::ORBInitInfo_ptr info)
107 // Register the Messaging policy factories.
109 PortableInterceptor::PolicyFactory_ptr policy_factory_ptr;
110 ACE_NEW_THROW_EX (policy_factory_ptr,
111 TAO_Messaging_PolicyFactory,
112 CORBA::NO_MEMORY (
113 CORBA::SystemException::_tao_minor_code (
114 TAO::VMCID,
115 ENOMEM),
116 CORBA::COMPLETED_NO));
119 PortableInterceptor::PolicyFactory_var policy_factory =
120 policy_factory_ptr;
122 // Bind the same policy factory to all Messaging related policy
123 // types since a single policy factory is used to create each of
124 // the different types of Messaging policies.
126 CORBA::PolicyType type[] = {
127 #if (TAO_HAS_RELATIVE_REQUEST_TIMEOUT_POLICY == 1)
128 Messaging::RELATIVE_RT_TIMEOUT_POLICY_TYPE,
129 #endif /* TAO_HAS_RELATIVE_REQUEST_TIMEOUT_POLICY == 1 */
130 #if (TAO_HAS_SYNC_SCOPE_POLICY == 1)
131 Messaging::SYNC_SCOPE_POLICY_TYPE,
132 #endif /* TAO_HAS_SYNC_SCOPE_POLICY == 1 */
133 #if (TAO_HAS_BUFFERING_CONSTRAINT_POLICY == 1)
134 TAO::BUFFERING_CONSTRAINT_POLICY_TYPE,
135 #endif /* TAO_HAS_BUFFERING_CONSTRAINT_POLICY == 1 */
136 #if (TAO_HAS_REBIND_POLICY == 1)
137 Messaging::REBIND_POLICY_TYPE,
138 #endif /* TAO_HAS_REBIND_POLICY == 1 */
139 #if (TAO_HAS_PRIORITY_POLICIES == 1)
140 Messaging::REQUEST_PRIORITY_POLICY_TYPE,
141 Messaging::REPLY_PRIORITY_POLICY_TYPE,
142 #endif /* TAO_HAS_PRIORITY_POLICIES == 1 */
143 #if (TAO_HAS_REQUEST_START_TIME_POLICY == 1)
144 Messaging::REQUEST_START_TIME_POLICY_TYPE,
145 #endif /* TAO_HAS_REQUEST_START_TIME_POLICY == 1 */
146 #if (TAO_HAS_REQUEST_END_TIME_POLICY == 1)
147 Messaging::REQUEST_END_TIME_POLICY_TYPE,
148 #endif /*TAO_HAS_REQUEST_END_TIME_POLICY == 1 */
149 #if (TAO_HAS_REPLY_START_TIME_POLICY == 1)
150 Messaging::REPLY_START_TIME_POLICY_TYPE,
151 #endif /* TAO_HAS_REPLY_START_TIME_POLICY == 1 */
152 #if (TAO_HAS_REPLY_END_TIME_POLICY == 1)
153 Messaging::REPLY_END_TIME_POLICY_TYPE,
154 #endif /* TAO_HAS_REPLY_END_TIME_POLICY == 1 */
155 #if (TAO_HAS_RELATIVE_REQUEST_TIMEOUT_POLICY == 1)
156 Messaging::RELATIVE_REQ_TIMEOUT_POLICY_TYPE,
157 #endif /* TAO_HAS_RELATIVE_REQUEST_TIMEOUT_POLICY == 1 */
158 #if (TAO_HAS_ROUTING_POLICY == 1)
159 Messaging::ROUTING_POLICY_TYPE,
160 #endif /* TAO_HAS_ROUTING_POLICY == 1 */
161 #if (TAO_HAS_MAX_HOPS_POLICY == 1)
162 Messaging::MAX_HOPS_POLICY_TYPE,
163 #endif /* TAO_HAS_MAX_HOPS_POLICY == 1 */
164 Messaging::QUEUE_ORDER_POLICY_TYPE,
165 #if (TAO_HAS_CONNECTION_TIMEOUT_POLICY == 1)
166 TAO::CONNECTION_TIMEOUT_POLICY_TYPE
167 #endif /* TAO_HAS_CONNECTION_TIMEOUT_POLICY == 1 */
170 const CORBA::PolicyType *end = type + sizeof (type) / sizeof (type[0]);
171 for (CORBA::PolicyType *i = type; i != end; ++i)
175 info->register_policy_factory (*i, policy_factory.in ());
177 catch (const ::CORBA::BAD_INV_ORDER& ex)
179 if (ex.minor () == (CORBA::OMGVMCID | 16))
181 // The factory is already there, it happens because the
182 // magic initializer in Messaging.cpp registers with the
183 // ORB multiple times. This is an indication that we
184 // should do no more work in this ORBInitializer.
185 return;
187 throw;
192 TAO_END_VERSIONED_NAMESPACE_DECL