1 #include "tao/PI/ORBInitInfo.h"
2 #include "tao/ORB_Core.h"
4 #include "tao/Object_Loader.h"
5 #include "tao/PolicyFactory_Registry_Adapter.h"
7 #include "ace/Dynamic_Service.h"
8 #include "ace/Service_Config.h"
9 #include "ace/CORBA_macros.h"
11 #if TAO_HAS_INTERCEPTORS == 1
12 #include "tao/PI/PICurrent.h"
13 #endif /* TAO_HAS_INTERCEPTORS == 1 */
15 #if !defined (__ACE_INLINE__)
16 #include "tao/PI/ORBInitInfo.inl"
17 #endif /* defined INLINE */
21 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
23 // Traits specializations for TAO_ORBInitInfo.
26 TAO::Objref_Traits
<TAO_ORBInitInfo
>::duplicate (TAO_ORBInitInfo_ptr p
)
28 return TAO_ORBInitInfo::_duplicate (p
);
32 TAO::Objref_Traits
<TAO_ORBInitInfo
>::release (TAO_ORBInitInfo_ptr p
)
38 TAO::Objref_Traits
<TAO_ORBInitInfo
>::nil ()
40 return TAO_ORBInitInfo::_nil ();
44 TAO::Objref_Traits
<TAO_ORBInitInfo
>::marshal (
45 TAO_ORBInitInfo_ptr p
,
49 return p
->marshal (cdr
);
52 TAO_ORBInitInfo::TAO_ORBInitInfo (TAO_ORB_Core
*orb_core
,
55 PortableInterceptor::SlotId slotid
)
56 : orb_core_ (orb_core
),
64 TAO_ORBInitInfo::~TAO_ORBInitInfo ()
69 TAO_ORBInitInfo::arguments ()
71 this->check_validity ();
73 // In accordance with the C++ mapping for sequences, it is up to the
74 // caller to deallocate storage for returned sequences.
76 CORBA::StringSeq
*args
= 0;
77 ACE_NEW_THROW_EX (args
,
80 CORBA::SystemException::_tao_minor_code (
83 CORBA::COMPLETED_NO
));
85 CORBA::StringSeq_var
safe_args (args
);
87 // Copy the argument vector to the string sequence.
89 args
->length (this->argc_
); // Not a problem if argc is zero.
90 for (int i
= 0; i
< this->argc_
; ++i
)
91 (*args
)[i
] = CORBA::string_dup (this->argv_
[i
]);
93 return safe_args
._retn ();
97 TAO_ORBInitInfo::orb_id ()
99 this->check_validity ();
101 // In accordance with the C++ mapping for strings, return a copy.
103 return CORBA::string_dup (this->orb_core_
->orbid ());
106 IOP::CodecFactory_ptr
107 TAO_ORBInitInfo::codec_factory ()
109 if (CORBA::is_nil (this->codec_factory_
.in ()))
111 TAO_Object_Loader
*loader
=
112 ACE_Dynamic_Service
<TAO_Object_Loader
>::instance ("CodecFactory_Loader");
116 ACE_Service_Config::process_directive (
117 ACE_DYNAMIC_VERSIONED_SERVICE_DIRECTIVE("CodecFactory",
120 "_make_TAO_CodecFactory_Loader",
123 ACE_Dynamic_Service
<TAO_Object_Loader
>::instance ("CodecFactory_Loader");
128 CORBA::Object_var cf
=
129 loader
->create_object (this->orb_core_
->orb (), 0, 0);
131 this->codec_factory_
= IOP::CodecFactory::_narrow (cf
.in ());
135 return IOP::CodecFactory::_duplicate (this->codec_factory_
.in ());
139 TAO_ORBInitInfo::register_initial_reference (
141 CORBA::Object_ptr obj
)
143 this->check_validity ();
145 if (id
== 0 || std::strlen (id
) == 0)
146 throw PortableInterceptor::ORBInitInfo::InvalidName ();
148 if (CORBA::is_nil (obj
))
149 throw ::CORBA::BAD_PARAM (CORBA::OMGVMCID
| 27, CORBA::COMPLETED_NO
);
151 TAO_Object_Ref_Table
&table
= this->orb_core_
->object_ref_table ();
153 if (table
.register_initial_reference (id
, obj
) == -1)
154 throw PortableInterceptor::ORBInitInfo::InvalidName ();
158 TAO_ORBInitInfo::resolve_initial_references (const char * id
)
160 this->check_validity ();
162 if (id
== 0 || std::strlen (id
) == 0)
163 throw PortableInterceptor::ORBInitInfo::InvalidName ();
165 // The ORB is practically fully initialized by the time this point
166 // is reached so just use the ORB's resolve_initial_references()
168 return this->orb_core_
->orb ()->resolve_initial_references (id
);
172 TAO_ORBInitInfo::add_client_request_interceptor (
173 PortableInterceptor::ClientRequestInterceptor_ptr interceptor
)
175 # if TAO_HAS_INTERCEPTORS == 1
176 this->check_validity ();
178 this->orb_core_
->add_interceptor (interceptor
);
180 ACE_UNUSED_ARG (interceptor
);
181 throw ::CORBA::NO_IMPLEMENT (
182 CORBA::SystemException::_tao_minor_code (
185 CORBA::COMPLETED_NO
);
186 #endif /* TAO_HAS_INTERCEPTORS == 1 */
190 TAO_ORBInitInfo::add_server_request_interceptor (
191 PortableInterceptor::ServerRequestInterceptor_ptr interceptor
)
193 # if TAO_HAS_INTERCEPTORS == 1
194 this->check_validity ();
196 this->orb_core_
->add_interceptor (interceptor
);
199 ACE_UNUSED_ARG (interceptor
);
200 throw ::CORBA::NO_IMPLEMENT (
201 CORBA::SystemException::_tao_minor_code (
204 CORBA::COMPLETED_NO
);
205 #endif /* TAO_HAS_INTERCEPTORS == 1 */
209 TAO_ORBInitInfo::add_ior_interceptor (
210 PortableInterceptor::IORInterceptor_ptr interceptor
)
212 this->check_validity ();
214 this->orb_core_
->add_interceptor (interceptor
);
218 TAO_ORBInitInfo::add_client_request_interceptor_with_policy (
219 PortableInterceptor::ClientRequestInterceptor_ptr interceptor
,
220 const CORBA::PolicyList
& policies
)
222 # if TAO_HAS_INTERCEPTORS == 1
223 this->check_validity ();
225 this->orb_core_
->add_interceptor (interceptor
, policies
);
227 ACE_UNUSED_ARG (interceptor
);
228 ACE_UNUSED_ARG (policies
);
229 throw ::CORBA::NO_IMPLEMENT (
230 CORBA::SystemException::_tao_minor_code (
233 CORBA::COMPLETED_NO
);
234 #endif /* TAO_HAS_INTERCEPTORS == 1 */
238 TAO_ORBInitInfo::add_server_request_interceptor_with_policy (
239 PortableInterceptor::ServerRequestInterceptor_ptr interceptor
,
240 const CORBA::PolicyList
& policies
)
242 # if TAO_HAS_INTERCEPTORS == 1
243 this->check_validity ();
245 this->orb_core_
->add_interceptor (interceptor
, policies
);
248 ACE_UNUSED_ARG (interceptor
);
249 ACE_UNUSED_ARG (policies
);
250 throw ::CORBA::NO_IMPLEMENT (
251 CORBA::SystemException::_tao_minor_code (
254 CORBA::COMPLETED_NO
);
255 #endif /* TAO_HAS_INTERCEPTORS == 1 */
259 TAO_ORBInitInfo::add_ior_interceptor_with_policy (
260 PortableInterceptor::IORInterceptor_ptr interceptor
,
261 const CORBA::PolicyList
& policies
)
263 this->check_validity ();
265 // Since there are currently no PI Policies that pertain to
266 // IOR Interceptors, we will always raise the NO_IMPLEMENT
267 // CORBA System Exception here to indicate that this method
268 // is currently not implemented/supported.
269 ACE_UNUSED_ARG (interceptor
);
270 ACE_UNUSED_ARG (policies
);
271 throw ::CORBA::NO_IMPLEMENT (
272 CORBA::SystemException::_tao_minor_code (
275 CORBA::COMPLETED_NO
);
278 PortableInterceptor::SlotId
279 TAO_ORBInitInfo::allocate_slot_id ()
281 this->check_validity ();
283 #if TAO_HAS_INTERCEPTORS == 1
284 // No need to acquire a lock. This only gets called during ORB
285 // initialization. ORB initialization is already atomic.
286 return this->slot_count_
++;
288 throw ::CORBA::NO_IMPLEMENT (
289 CORBA::SystemException::_tao_minor_code (
292 CORBA::COMPLETED_NO
);
293 #endif /* TAO_HAS_INTERCEPTORS == 1 */
297 TAO_ORBInitInfo::register_policy_factory (
298 CORBA::PolicyType type
,
299 PortableInterceptor::PolicyFactory_ptr policy_factory
)
301 this->check_validity ();
303 TAO::PolicyFactory_Registry_Adapter
*registry
=
304 this->orb_core_
->policy_factory_registry ();
308 throw ::CORBA::INTERNAL ();
311 registry
->register_policy_factory (type
, policy_factory
);
315 TAO_ORBInitInfo::allocate_tss_slot_id (ACE_CLEANUP_FUNC cleanup
)
317 this->check_validity ();
321 const int result
= this->orb_core_
->add_tss_cleanup_func (cleanup
, slot_id
);
324 throw ::CORBA::INTERNAL (
325 CORBA::SystemException::_tao_minor_code (
328 CORBA::COMPLETED_NO
);
334 TAO_ORBInitInfo::check_validity ()
336 if (this->orb_core_
== 0)
338 // As defined by the Portable Interceptor specification, throw a
339 // CORBA::OBJECT_NOT_EXIST exception after CORBA::ORB_init() has
340 // completed. CORBA::ORB_init() sets the ORB core pointer in
341 // this instance to zero when it is done initializing the ORB,
342 // which is why we base "existence" on the validity of the ORB
344 throw ::CORBA::OBJECT_NOT_EXIST (0, CORBA::COMPLETED_NO
);
349 TAO_ORBInitInfo::_get_orb ()
351 this->check_validity ();
353 return CORBA::ORB::_duplicate (this->orb_core_
->orb ());
356 TAO_ORBInitInfo_ptr
TAO_ORBInitInfo::_narrow (CORBA::Object_ptr _tao_objref
)
358 if (CORBA::is_nil (_tao_objref
))
360 return TAO_ORBInitInfo::_nil ();
363 TAO_ORBInitInfo_ptr proxy
=
364 dynamic_cast<TAO_ORBInitInfo_ptr
> (_tao_objref
);
366 return TAO_ORBInitInfo::_duplicate (proxy
);
370 TAO_ORBInitInfo::_duplicate (TAO_ORBInitInfo_ptr obj
)
372 if (!CORBA::is_nil (obj
))
380 const char* TAO_ORBInitInfo::_interface_repository_id () const
382 return "IDL:TAO_ORBInitInfo:1.0";
385 TAO_END_VERSIONED_NAMESPACE_DECL