Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / tao / PI / PI_ORBInitializer.cpp
blob123d4f54ea8db64610da9a31b0b49bbb0f0e603f
1 // -*- C++ -*-
2 #include "tao/PI/PI_ORBInitializer.h"
4 #if TAO_HAS_INTERCEPTORS == 1
6 #include "tao/PI/PI_PolicyFactory.h"
7 #include "tao/PI/ProcessingModePolicyC.h"
8 #include "tao/ORB_Core.h"
9 #include "tao/PI/ORBInitInfoC.h"
10 #include "ace/CORBA_macros.h"
12 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
14 void
15 TAO_PI_ORBInitializer::pre_init (PortableInterceptor::ORBInitInfo_ptr)
19 void
20 TAO_PI_ORBInitializer::post_init (PortableInterceptor::ORBInitInfo_ptr info)
22 // The PI policy factory is stateless and reentrant, so share a
23 // single instance between all ORBs.
24 if (CORBA::is_nil (this->policy_factory_.in ()))
26 PortableInterceptor::PolicyFactory_ptr policy_factory;
27 ACE_NEW_THROW_EX (policy_factory,
28 TAO_PI_PolicyFactory,
29 CORBA::NO_MEMORY (
30 CORBA::SystemException::_tao_minor_code (
31 TAO::VMCID,
32 ENOMEM),
33 CORBA::COMPLETED_NO));
35 this->policy_factory_ = policy_factory;
38 this->register_policy_factories (info);
41 void
42 TAO_PI_ORBInitializer::register_policy_factories (
43 PortableInterceptor::ORBInitInfo_ptr info)
45 // Register the PI policy factory.
47 // Bind the same policy factory to all PortableInterceptor related policy
48 // types since a single policy factory is used to create each of the
49 // different types of PortableInterceptor policies.
50 CORBA::PolicyType type[] = {
51 PortableInterceptor::PROCESSING_MODE_POLICY_TYPE
54 const CORBA::PolicyType *end = type + sizeof (type) / sizeof (type[0]);
56 for (CORBA::PolicyType *i = type; i != end; ++i)
58 try
60 info->register_policy_factory (*i, this->policy_factory_.in ());
62 catch (const ::CORBA::BAD_INV_ORDER& ex)
64 if (ex.minor () == (CORBA::OMGVMCID | 16))
66 // The factory is already there, it happens because the
67 // magic initializer in PI_Initializer.cpp registers
68 // with the ORB multiple times. This is an indication
69 // that we should do no more work in this
70 // ORBInitializer.
71 return;
73 throw;
78 TAO_END_VERSIONED_NAMESPACE_DECL
80 #endif /* TAO_HAS_INTERCEPTORS == 1 */