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"
6 #include "tao/ORB_Core.h"
7 #include "tao/Profile.h"
9 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
14 Collocated_Object_Proxy_Broker::_is_a (CORBA::Object_ptr target
,
17 TAO_Stub
*stub
= target
->_stubobj ();
19 // Which collocation strategy should we use?
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 (),
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
);
47 #if (TAO_HAS_MINIMUM_CORBA == 0)
50 Collocated_Object_Proxy_Broker::_repository_id (CORBA::Object_ptr target
)
52 TAO_Stub
*stub
= target
->_stubobj ();
53 char * _tao_retval
= 0;
57 // Which collocation strategy should we use?
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 (),
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.
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?
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 (),
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 ();
123 #if !defined (CORBA_E_COMPACT) && !defined (CORBA_E_MICRO)
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?
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 (),
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?
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 (),
187 servant_upcall
.pre_invoke_collocated_request ();
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.
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
;
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
;
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