Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / tao / ZIOP / ZIOP_ORBInitializer.cpp
blobfce6718fe14d0881bf3f4df9a1fb340e32bb97dd
1 #include "tao/ZIOP/ZIOP_ORBInitializer.h"
3 #if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0
5 #include "tao/ZIOP/ZIOP.h"
6 #include "tao/ZIOP/ZIOP_Stub_Factory.h"
7 #include "tao/ZIOP/ZIOP_PolicyFactory.h"
8 #include "tao/ZIOP/ZIOP_Service_Context_Handler.h"
9 #include "tao/ORB_Core.h"
10 #include "tao/PI/ORBInitInfo.h"
12 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
14 TAO_ZIOP_ORBInitializer::TAO_ZIOP_ORBInitializer (TAO_ZIOP_Loader* loader) : loader_ (loader)
18 void
19 TAO_ZIOP_ORBInitializer::pre_init (PortableInterceptor::ORBInitInfo_ptr info)
21 // Narrow to a TAO_ORBInitInfo object to get access to the
22 // orb_core() TAO extension.
23 TAO_ORBInitInfo_var tao_info = TAO_ORBInitInfo::_narrow (info);
25 if (CORBA::is_nil (tao_info.in ()))
27 if (TAO_debug_level > 0)
28 TAOLIB_ERROR ((LM_ERROR,
29 "ZIOP (%P|%t) TAO_ZIOP_ORBInitializer::pre_init:\n"
30 "ZIOP (%P|%t) Unable to narrow "
31 "\"PortableInterceptor::ORBInitInfo_ptr\" to\n"
32 "ZIOP (%P|%t) \"TAO_ORBInitInfo *.\"\n"));
34 throw ::CORBA::INTERNAL ();
37 tao_info->orb_core ()->ziop_adapter (this->loader_);
38 // Set the name of the stub factory to be ZIOP_Stub_Factory.
39 tao_info->orb_core ()->orb_params ()->stub_factory_name ("ZIOP_Stub_Factory");
40 ACE_Service_Config::process_directive (ace_svc_desc_TAO_ZIOP_Stub_Factory);
42 #if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0
43 // Bind the service context handler for ZIOP
44 TAO_ZIOP_Service_Context_Handler* h = 0;
45 ACE_NEW (h,
46 TAO_ZIOP_Service_Context_Handler());
47 tao_info->orb_core ()->service_context_registry ().bind (IOP::INVOCATION_POLICIES, h);
48 #endif
51 void
52 TAO_ZIOP_ORBInitializer::post_init (PortableInterceptor::ORBInitInfo_ptr info)
54 this->register_policy_factories (info);
57 void
58 TAO_ZIOP_ORBInitializer::register_policy_factories (
59 PortableInterceptor::ORBInitInfo_ptr info)
61 // Register the ZIOP policy factories.
62 PortableInterceptor::PolicyFactory_ptr policy_factory_ptr;
63 ACE_NEW_THROW_EX (policy_factory_ptr,
64 TAO_ZIOP_PolicyFactory,
65 CORBA::NO_MEMORY (
66 CORBA::SystemException::_tao_minor_code (
67 TAO::VMCID,
68 ENOMEM),
69 CORBA::COMPLETED_NO));
72 PortableInterceptor::PolicyFactory_var policy_factory =
73 policy_factory_ptr;
75 try
77 info->register_policy_factory (ZIOP::COMPRESSION_ENABLING_POLICY_ID,
78 policy_factory.in ());
80 info->register_policy_factory (ZIOP::COMPRESSOR_ID_LEVEL_LIST_POLICY_ID,
81 policy_factory.in ());
83 info->register_policy_factory (ZIOP::COMPRESSION_LOW_VALUE_POLICY_ID,
84 policy_factory.in ());
86 info->register_policy_factory (ZIOP::COMPRESSION_MIN_RATIO_POLICY_ID,
87 policy_factory.in ());
89 catch (const CORBA::BAD_INV_ORDER& ex)
91 if (ex.minor () == (CORBA::OMGVMCID | 16))
93 // The factory is already there, it happens because the
94 // magic initializer in Messaging.cpp registers with the
95 // ORB multiple times. This is an indication that we
96 // should do no more work in this ORBInitializer.
97 return;
99 throw;
101 catch (...)
103 // Rethrow any other exceptions...
104 throw;
108 TAO_END_VERSIONED_NAMESPACE_DECL
110 #endif