Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / tao / PortableServer / Collocated_Object_Proxy_Broker.cpp
blobc93cae20dc605a7c32837994aa67450b41ef3eb2
1 #include "tao/PortableServer/Collocated_Object_Proxy_Broker.h"
2 #include "tao/PortableServer/Object_Adapter.h"
3 #include "tao/PortableServer/Servant_Upcall.h"
4 #include "tao/PortableServer/Servant_Base.h"
5 #include "tao/Stub.h"
6 #include "tao/ORB_Core.h"
7 #include "tao/Profile.h"
9 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
11 namespace TAO
13 CORBA::Boolean
14 Collocated_Object_Proxy_Broker::_is_a (CORBA::Object_ptr target,
15 const char *type_id)
17 TAO_Stub *stub = target->_stubobj ();
19 // Which collocation strategy should we use?
20 if (stub != 0 &&
21 stub->servant_orb_var ()->orb_core ()->get_collocation_strategy ()
22 == TAO_ORB_Core::TAO_COLLOCATION_THRU_POA)
24 TAO::Portable_Server::Servant_Upcall servant_upcall (
25 stub->servant_orb_var ()->orb_core ());
27 CORBA::Object_var forward_to;
28 servant_upcall.prepare_for_upcall (
29 stub->profile_in_use ()->object_key (),
30 "_is_a",
31 forward_to.out ());
33 servant_upcall.pre_invoke_collocated_request ();
35 return servant_upcall.servant ()->_is_a (type_id);
38 // Direct collocation strategy is used.
39 if (target->_servant () != 0)
41 return target->_servant ()->_is_a (type_id);
44 return false;
47 #if (TAO_HAS_MINIMUM_CORBA == 0)
49 char *
50 Collocated_Object_Proxy_Broker::_repository_id (CORBA::Object_ptr target)
52 TAO_Stub *stub = target->_stubobj ();
53 char * _tao_retval = 0;
55 try
57 // Which collocation strategy should we use?
58 if (stub != 0 &&
59 stub->servant_orb_var ()->orb_core ()
60 ->get_collocation_strategy () == TAO_ORB_Core::TAO_COLLOCATION_THRU_POA)
62 TAO::Portable_Server::Servant_Upcall servant_upcall (
63 stub->servant_orb_var ()->orb_core ());
65 CORBA::Object_var forward_to;
66 servant_upcall.prepare_for_upcall (
67 stub->profile_in_use ()->object_key (),
68 "_repository_id",
69 forward_to.out ());
71 _tao_retval =
72 servant_upcall.servant ()->_repository_id ();
74 // Direct collocation strategy is used.
75 else if (target->_servant () != 0)
77 _tao_retval = target->_servant ()->_repository_id ();
80 catch (const ::CORBA::OBJECT_NOT_EXIST&)
82 // Ignore this exception.
85 return _tao_retval;
88 CORBA::Boolean
89 Collocated_Object_Proxy_Broker::_non_existent (CORBA::Object_ptr target)
91 CORBA::Boolean _tao_retval = true;
93 TAO_Stub *stub = target->_stubobj ();
95 // Which collocation strategy should we use?
96 if (stub != 0 &&
97 stub->servant_orb_var ()->orb_core ()
98 ->get_collocation_strategy () == TAO_ORB_Core::TAO_COLLOCATION_THRU_POA)
100 TAO::Portable_Server::Servant_Upcall servant_upcall (
101 target->_stubobj ()->servant_orb_var ()->orb_core ());
103 CORBA::Object_var forward_to;
105 servant_upcall.prepare_for_upcall (
106 target->_stubobj ()->object_key (),
107 "_non_existent",
108 forward_to.out ());
110 servant_upcall.pre_invoke_collocated_request ();
112 _tao_retval = servant_upcall.servant ()->_non_existent ();
114 // Direct collocation strategy is used.
115 else if (target->_servant () != 0)
117 _tao_retval = target->_servant ()->_non_existent ();
120 return _tao_retval;
123 #if !defined (CORBA_E_COMPACT) && !defined (CORBA_E_MICRO)
124 CORBA::Object_ptr
125 Collocated_Object_Proxy_Broker::_get_component (CORBA::Object_ptr target)
127 CORBA::Object_var _tao_retval (CORBA::Object::_nil ());
129 TAO_Stub *stub = target->_stubobj ();
133 // Which collocation strategy should we use?
134 if (stub != 0 &&
135 stub->servant_orb_var ()->orb_core ()
136 ->get_collocation_strategy () == TAO_ORB_Core::TAO_COLLOCATION_THRU_POA)
138 TAO::Portable_Server::Servant_Upcall servant_upcall (
139 stub->servant_orb_var ()->orb_core ());
141 CORBA::Object_var forward_to;
142 servant_upcall.prepare_for_upcall (
143 stub->profile_in_use ()->object_key (),
144 "_component",
145 forward_to.out ());
147 _tao_retval = servant_upcall.servant ()->_get_component ();
149 // Direct collocation strategy is used.
150 else if (target->_servant () != 0)
152 _tao_retval = target->_servant ()->_get_component ();
155 catch (const ::CORBA::OBJECT_NOT_EXIST&)
157 // Ignore this exception.
160 return _tao_retval._retn ();
163 CORBA::InterfaceDef_ptr
164 Collocated_Object_Proxy_Broker::_get_interface (CORBA::Object_ptr target)
166 CORBA::InterfaceDef_ptr _tao_retval = 0;
168 TAO_Stub *stub = target->_stubobj ();
172 // Which collocation strategy should we use?
173 if (stub != 0 &&
174 stub->servant_orb_var ()->orb_core ()->get_collocation_strategy ()
175 == TAO_ORB_Core::TAO_COLLOCATION_THRU_POA)
177 TAO::Portable_Server::Servant_Upcall servant_upcall (
178 target->_stubobj ()->servant_orb_var ()->orb_core ());
180 CORBA::Object_var forward_to;
182 servant_upcall.prepare_for_upcall (
183 target->_stubobj ()->object_key (),
184 "_interface",
185 forward_to.out ());
187 servant_upcall.pre_invoke_collocated_request ();
189 _tao_retval =
190 servant_upcall.servant ()->_get_interface ();
192 // Direct collocation strategy is used.
193 else if (target->_servant () != 0)
195 _tao_retval = target->_servant ()->_get_interface ();
198 catch (const ::CORBA::OBJECT_NOT_EXIST&)
200 // Ignore this exception.
203 return _tao_retval;
205 #endif
207 #endif /* TAO_HAS_MINIMUM_CORBA == 0 */
211 // -----------------------------------------------------
212 TAO::Collocated_Object_Proxy_Broker *
213 the_tao_collocated_object_proxy_broker ()
215 static TAO::Collocated_Object_Proxy_Broker the_broker;
216 return &the_broker;
219 TAO::Object_Proxy_Broker * _TAO_collocation_Object_Proxy_Broker_Factory ()
221 return the_tao_collocated_object_proxy_broker ();
225 _TAO_collocation_Object_Proxy_Broker_Factory_Initializer (size_t)
227 _TAO_Object_Proxy_Broker_Factory_function_pointer =
228 _TAO_collocation_Object_Proxy_Broker_Factory;
230 return 0;
233 static int
234 _TAO_collocation_Object_Proxy_Broker_Factory_Initializer_Scarecrow =
235 _TAO_collocation_Object_Proxy_Broker_Factory_Initializer (
236 reinterpret_cast<size_t> (_TAO_collocation_Object_Proxy_Broker_Factory_Initializer));
238 TAO_END_VERSIONED_NAMESPACE_DECL