Merge pull request #2303 from jwillemsen/jwi-803
[ACE_TAO.git] / TAO / tao / PI_Server / PortableServer_ORBInitializer.cpp
blob8addc7d9365c05ff9331aac8cd8d14b393ad61fa
1 // -*- C++ -*-
2 #include "tao/PI_Server/PortableServer_ORBInitializer.h"
3 #include "tao/PI_Server/PortableServer_PolicyFactory.h"
4 #include "tao/debug.h"
5 #include "tao/ORB_Constants.h"
6 #include "tao/PortableServer/PortableServer.h"
7 #include "tao/PI/ORBInitInfo.h"
8 #include "tao/ORB_Core.h"
10 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
12 void
13 TAO_PortableServer_ORBInitializer::pre_init (
14 PortableInterceptor::ORBInitInfo_ptr)
18 void
19 TAO_PortableServer_ORBInitializer::post_init (
20 PortableInterceptor::ORBInitInfo_ptr info)
22 this->register_policy_factories (info);
25 void
26 TAO_PortableServer_ORBInitializer::register_policy_factories (
27 PortableInterceptor::ORBInitInfo_ptr info)
29 #if !defined (CORBA_E_MICRO)
30 // Register the PortableServer policy factories.
31 PortableInterceptor::PolicyFactory_ptr tmp;
32 ACE_NEW_THROW_EX (tmp,
33 TAO_PortableServer_PolicyFactory,
34 CORBA::NO_MEMORY (
35 CORBA::SystemException::_tao_minor_code (
36 TAO::VMCID,
37 ENOMEM),
38 CORBA::COMPLETED_NO));
40 PortableInterceptor::PolicyFactory_var policy_factory = tmp;
42 // Bind the same policy factory to all PortableServer related policy
43 // types since a single policy factory is used to create each of the
44 // different types of PortableServer policies.
45 static CORBA::PolicyType const type[] = {
46 #if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_COMPACT)
47 PortableServer::THREAD_POLICY_ID,
48 PortableServer::IMPLICIT_ACTIVATION_POLICY_ID,
49 PortableServer::SERVANT_RETENTION_POLICY_ID,
50 PortableServer::REQUEST_PROCESSING_POLICY_ID,
51 #endif /* TAO_HAS_MINIMUM_POA == 0 */
52 PortableServer::LIFESPAN_POLICY_ID,
53 PortableServer::ID_UNIQUENESS_POLICY_ID,
54 PortableServer::ID_ASSIGNMENT_POLICY_ID
57 CORBA::PolicyType const * end =
58 type + sizeof (type) / sizeof (type[0]);
60 for (CORBA::PolicyType const *i = type;
61 i != end;
62 ++i)
64 try
66 info->register_policy_factory (*i, policy_factory.in ());
68 catch (const ::CORBA::BAD_INV_ORDER& ex)
70 if (ex.minor () == (CORBA::OMGVMCID | 16))
72 // The factory is already there, it happens because the
73 // magic initializer in PortableServer.cpp registers
74 // with the ORB multiple times. This is an indication
75 // that we should do no more work in this
76 // ORBInitializer.
77 return;
79 throw;
82 #else
83 ACE_UNUSED_ARG (info);
84 #endif
87 TAO_END_VERSIONED_NAMESPACE_DECL