Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / tao / BiDir_GIOP / BiDirGIOP.cpp
blob70c09aa62ae5971c9f2af5919c48f2c04b022db0
1 // -*- C++ -*-
2 #include "tao/BiDir_GIOP/BiDir_ORBInitializer.h"
3 #include "tao/BiDir_GIOP/BiDirGIOP.h"
4 #include "tao/BiDir_GIOP/BiDirPolicy_Validator.h"
5 #include "tao/ORB_Core.h"
6 #include "tao/debug.h"
7 #include "tao/ORBInitializer_Registry.h"
8 #include "ace/CORBA_macros.h"
10 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
12 int
13 TAO_BiDirGIOP_Loader::init (int, ACE_TCHAR* [])
15 if (this->initialized_)
16 return 0;
18 this->initialized_ = true;
20 ACE_Service_Gestalt *gestalt = ACE_Service_Config::current ();
22 ACE_Service_Object * const bidir_loader =
23 ACE_Dynamic_Service<ACE_Service_Object>::instance (
24 gestalt,
25 "BiDirGIOP_Loader",
26 true);
28 if (bidir_loader != 0 && bidir_loader != this)
30 return bidir_loader->init (0, 0);
33 if (TAO_DEF_GIOP_MINOR >= 2)
35 PortableInterceptor::ORBInitializer_ptr tmp_orb_initializer =
36 PortableInterceptor::ORBInitializer::_nil ();
37 PortableInterceptor::ORBInitializer_var bidir_orb_initializer;
39 try
41 /// Register the BiDir ORBInitializer.
42 ACE_NEW_THROW_EX (tmp_orb_initializer,
43 TAO_BiDir_ORBInitializer,
44 CORBA::NO_MEMORY (
45 CORBA::SystemException::_tao_minor_code (
46 TAO::VMCID,
47 ENOMEM),
48 CORBA::COMPLETED_NO));
50 bidir_orb_initializer = tmp_orb_initializer;
52 PortableInterceptor::register_orb_initializer (
53 bidir_orb_initializer.in ());
55 catch (const ::CORBA::Exception& ex)
57 if (TAO_debug_level > 0)
59 ex._tao_print_exception ("Caught exception:");
61 return -1;
65 return 0;
68 void
69 TAO_BiDirGIOP_Loader::load_policy_validators (TAO_Policy_Validator &val)
71 // Is this true? Does the GIOP protocol version matter here?
72 if (TAO_DEF_GIOP_MINOR < 2)
73 return;
75 TAO_BiDirPolicy_Validator *validator = nullptr;
76 ACE_NEW_THROW_EX (validator,
77 TAO_BiDirPolicy_Validator (val.orb_core ()),
78 CORBA::NO_MEMORY (
79 CORBA::SystemException::_tao_minor_code (
80 TAO::VMCID,
81 ENOMEM),
82 CORBA::COMPLETED_NO));
84 // We may be adding another TAO_BiDirPolicy_Validator instance for
85 // the same ORB (different POA). In cases where huge numbers of
86 // bi-directional POA instances are created, having a validator
87 // instance per POA may introduce additional delays in policy
88 // validation and hence, the overall policy creation time. Since this
89 // is out of the critical invocation processing path, I plan to keep
90 // the design simple and not try to avoid an inefficiency of such
91 // small proportions.
92 val.add_validator (validator);
95 int
96 TAO_BiDirGIOP_Loader::Initializer ()
98 return ACE_Service_Config::process_directive (ace_svc_desc_TAO_BiDirGIOP_Loader);
101 ACE_STATIC_SVC_DEFINE (TAO_BiDirGIOP_Loader,
102 ACE_TEXT ("BiDirGIOP_Loader"),
103 ACE_SVC_OBJ_T,
104 &ACE_SVC_NAME (TAO_BiDirGIOP_Loader),
105 ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ,
108 ACE_FACTORY_DEFINE (TAO_BIDIRGIOP, TAO_BiDirGIOP_Loader)
110 TAO_END_VERSIONED_NAMESPACE_DECL