Collocated_Object_Proxy_Broker.cpp

Go to the documentation of this file.
00001 //Collocated_Object_Proxy_Broker.cpp,v 1.12 2006/06/19 14:51:14 parsons Exp
00002 // -- PortableServer Include --
00003 #include "tao/PortableServer/Collocated_Object_Proxy_Broker.h"
00004 #include "tao/PortableServer/Object_Adapter.h"
00005 #include "tao/PortableServer/Servant_Upcall.h"
00006 #include "tao/PortableServer/Servant_Base.h"
00007 
00008 
00009 // -- TAO Include --
00010 #include "tao/Stub.h"
00011 #include "tao/ORB_Core.h"
00012 #include "tao/Profile.h"
00013 
00014 ACE_RCSID (PortableServer,
00015            Collocated_Object_Proxy_Broker,
00016            "Collocated_Object_Proxy_Broker.cpp,v 1.12 2006/06/19 14:51:14 parsons Exp")
00017 
00018 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00019 
00020 namespace TAO
00021 {
00022   CORBA::Boolean
00023   Collocated_Object_Proxy_Broker::_is_a (CORBA::Object_ptr target,
00024                                          const char *type_id
00025                                          ACE_ENV_ARG_DECL)
00026   {
00027     TAO_Stub *stub = target->_stubobj ();
00028 
00029     // Which collocation strategy should we use?
00030     if (stub != 0 &&
00031         stub->servant_orb_var ()->orb_core ()->get_collocation_strategy ()
00032           == TAO_ORB_Core::THRU_POA)
00033       {
00034         TAO::Portable_Server::Servant_Upcall servant_upcall (
00035           stub->servant_orb_var ()->orb_core ()
00036         );
00037 
00038       CORBA::Object_var forward_to;
00039       servant_upcall.prepare_for_upcall (
00040           stub->profile_in_use ()->object_key (),
00041           "_is_a",
00042           forward_to.out ()
00043           ACE_ENV_ARG_PARAMETER
00044         );
00045       ACE_CHECK_RETURN (0);
00046 
00047       servant_upcall.pre_invoke_collocated_request (
00048           ACE_ENV_SINGLE_ARG_PARAMETER
00049         );
00050       ACE_CHECK_RETURN (0);
00051 
00052       return servant_upcall.servant ()->_is_a (type_id
00053                                                ACE_ENV_ARG_PARAMETER);
00054     }
00055 
00056     // Direct collocation strategy is used.
00057     if (target->_servant () != 0)
00058       {
00059         return target->_servant ()->_is_a (type_id
00060                                            ACE_ENV_ARG_PARAMETER);
00061       }
00062 
00063     return 0;
00064   }
00065 
00066 #if (TAO_HAS_MINIMUM_CORBA == 0)
00067 
00068   char *
00069   Collocated_Object_Proxy_Broker::_repository_id (CORBA::Object_ptr target
00070                                                   ACE_ENV_ARG_DECL)
00071   {
00072     TAO_Stub *stub = target->_stubobj ();
00073     char * _tao_retval = 0;
00074 
00075     ACE_TRY
00076       {
00077         // Which collocation strategy should we use?
00078         if (stub != 0 &&
00079             stub->servant_orb_var ()->orb_core ()
00080               ->get_collocation_strategy () == TAO_ORB_Core::THRU_POA)
00081           {
00082             TAO::Portable_Server::Servant_Upcall servant_upcall (
00083                 stub->servant_orb_var ()->orb_core ()
00084                 );
00085 
00086             CORBA::Object_var forward_to;
00087             servant_upcall.prepare_for_upcall (
00088                 stub->profile_in_use ()->object_key (),
00089                 "_repository_id",
00090                 forward_to.out ()
00091                 ACE_ENV_ARG_PARAMETER
00092               );
00093             ACE_TRY_CHECK;
00094 
00095             _tao_retval =
00096               servant_upcall.servant ()->_repository_id (
00097                                              ACE_ENV_SINGLE_ARG_PARAMETER
00098                                            );
00099             ACE_TRY_CHECK;
00100           }
00101         // Direct collocation strategy is used.
00102         else if (target->_servant () != 0)
00103           {
00104             _tao_retval =
00105               target->_servant ()->_repository_id (
00106                                        ACE_ENV_SINGLE_ARG_PARAMETER
00107                                      );
00108             ACE_TRY_CHECK;
00109           }
00110       }
00111     ACE_CATCH (CORBA::OBJECT_NOT_EXIST, ex)
00112       {
00113         // Ignore this exception.
00114       }
00115     ACE_CATCHANY
00116       {
00117         ACE_RE_THROW;
00118       }
00119     ACE_ENDTRY;
00120     ACE_CHECK_RETURN (_tao_retval);
00121 
00122     return _tao_retval;
00123   }
00124 
00125   CORBA::Boolean
00126   Collocated_Object_Proxy_Broker::_non_existent (CORBA::Object_ptr target
00127                                                  ACE_ENV_ARG_DECL)
00128   {
00129     CORBA::Boolean _tao_retval = true;
00130 
00131     TAO_Stub *stub = target->_stubobj ();
00132 
00133     // Which collocation strategy should we use?
00134     if (stub != 0 &&
00135         stub->servant_orb_var ()->orb_core ()
00136         ->get_collocation_strategy () == TAO_ORB_Core::THRU_POA)
00137       {
00138         TAO::Portable_Server::Servant_Upcall servant_upcall (
00139           target->_stubobj ()->servant_orb_var ()->orb_core ()
00140           );
00141 
00142         CORBA::Object_var forward_to;
00143 
00144         servant_upcall.prepare_for_upcall (
00145           target->_stubobj ()->object_key (),
00146           "_non_existent",
00147           forward_to.out ()
00148           ACE_ENV_ARG_PARAMETER
00149           );
00150         ACE_CHECK_RETURN (_tao_retval);
00151 
00152         servant_upcall.pre_invoke_collocated_request (
00153             ACE_ENV_SINGLE_ARG_PARAMETER
00154           );
00155         ACE_CHECK_RETURN (_tao_retval);
00156 
00157         _tao_retval =
00158           servant_upcall.servant ()->_non_existent (
00159                                          ACE_ENV_SINGLE_ARG_PARAMETER
00160                                        );
00161         ACE_CHECK_RETURN (_tao_retval);
00162       }
00163     // Direct collocation strategy is used.
00164     else if (target->_servant () != 0)
00165       {
00166         _tao_retval =
00167           target->_servant ()->_non_existent (ACE_ENV_SINGLE_ARG_PARAMETER);
00168         ACE_CHECK_RETURN (_tao_retval);
00169       }
00170 
00171     return _tao_retval;
00172   }
00173 
00174   CORBA::Object_ptr
00175   Collocated_Object_Proxy_Broker::_get_component (CORBA::Object_ptr target
00176                                                   ACE_ENV_ARG_DECL)
00177   {
00178     CORBA::Object_var _tao_retval (CORBA::Object::_nil ());
00179 
00180     TAO_Stub *stub = target->_stubobj ();
00181 
00182     ACE_TRY
00183       {
00184         // Which collocation strategy should we use?
00185         if (stub != 0 &&
00186             stub->servant_orb_var ()->orb_core ()
00187               ->get_collocation_strategy () == TAO_ORB_Core::THRU_POA)
00188           {
00189             TAO::Portable_Server::Servant_Upcall servant_upcall (
00190                 stub->servant_orb_var ()->orb_core ()
00191                 );
00192 
00193             CORBA::Object_var forward_to;
00194             servant_upcall.prepare_for_upcall (
00195                 stub->profile_in_use ()->object_key (),
00196                 "_component",
00197                 forward_to.out ()
00198                 ACE_ENV_ARG_PARAMETER
00199               );
00200             ACE_TRY_CHECK;
00201 
00202             _tao_retval =
00203               servant_upcall.servant ()->_get_component (
00204                                              ACE_ENV_SINGLE_ARG_PARAMETER
00205                                            );
00206             ACE_TRY_CHECK;
00207           }
00208         // Direct collocation strategy is used.
00209         else if (target->_servant () != 0)
00210           {
00211             _tao_retval =
00212               target->_servant ()->_get_component (
00213                                        ACE_ENV_SINGLE_ARG_PARAMETER
00214                                      );
00215             ACE_TRY_CHECK;
00216           }
00217       }
00218     ACE_CATCH (CORBA::OBJECT_NOT_EXIST, ex)
00219       {
00220         // Ignore this exception.
00221       }
00222     ACE_CATCHANY
00223       {
00224         ACE_RE_THROW;
00225       }
00226     ACE_ENDTRY;
00227     ACE_CHECK_RETURN (_tao_retval._retn ());
00228 
00229     return _tao_retval._retn ();
00230   }
00231 
00232   CORBA::InterfaceDef_ptr
00233   Collocated_Object_Proxy_Broker::_get_interface (
00234       CORBA::Object_ptr target
00235       ACE_ENV_ARG_DECL)
00236   {
00237     CORBA::InterfaceDef_ptr _tao_retval = 0;
00238 
00239     TAO_Stub *stub = target->_stubobj ();
00240 
00241     ACE_TRY
00242       {
00243         // Which collocation strategy should we use?
00244         if (stub != 0 &&
00245             stub->servant_orb_var ()->orb_core ()->get_collocation_strategy ()
00246               == TAO_ORB_Core::THRU_POA)
00247           {
00248             TAO::Portable_Server::Servant_Upcall servant_upcall (
00249                 target->_stubobj ()->servant_orb_var ()->orb_core ()
00250                 );
00251 
00252             CORBA::Object_var forward_to;
00253 
00254             servant_upcall.prepare_for_upcall (
00255                 target->_stubobj ()->object_key (),
00256                 "_interface",
00257                 forward_to.out ()
00258                 ACE_ENV_ARG_PARAMETER
00259               );
00260             ACE_TRY_CHECK;
00261 
00262             servant_upcall.pre_invoke_collocated_request (
00263                 ACE_ENV_SINGLE_ARG_PARAMETER
00264               );
00265             ACE_TRY_CHECK;
00266 
00267             _tao_retval =
00268               servant_upcall.servant ()->_get_interface (
00269                   ACE_ENV_SINGLE_ARG_PARAMETER
00270                 );
00271             ACE_TRY_CHECK;
00272           }
00273         // Direct collocation strategy is used.
00274         else if (target->_servant () != 0)
00275           {
00276             _tao_retval =
00277               target->_servant ()->_get_interface (
00278                   ACE_ENV_SINGLE_ARG_PARAMETER
00279                 );
00280             ACE_TRY_CHECK;
00281           }
00282       }
00283     ACE_CATCH (CORBA::OBJECT_NOT_EXIST, ex)
00284       {
00285         // Ignore this exception.
00286       }
00287     ACE_CATCHANY
00288       {
00289         ACE_RE_THROW;
00290       }
00291     ACE_ENDTRY;
00292     ACE_CHECK_RETURN (_tao_retval);
00293 
00294     return _tao_retval;
00295   }
00296 
00297 #endif /* TAO_HAS_MINIMUM_CORBA == 0 */
00298 
00299 }
00300 
00301 // -----------------------------------------------------
00302 TAO::Collocated_Object_Proxy_Broker *
00303 the_tao_collocated_object_proxy_broker (void)
00304 {
00305   static TAO::Collocated_Object_Proxy_Broker the_broker;
00306   return &the_broker;
00307 }
00308 
00309 TAO::Object_Proxy_Broker * _TAO_collocation_Object_Proxy_Broker_Factory (void)
00310 {
00311   return the_tao_collocated_object_proxy_broker ();
00312 }
00313 
00314 int
00315 _TAO_collocation_Object_Proxy_Broker_Factory_Initializer (size_t)
00316 {
00317   _TAO_Object_Proxy_Broker_Factory_function_pointer =
00318     _TAO_collocation_Object_Proxy_Broker_Factory;
00319 
00320   return 0;
00321 }
00322 
00323 static int
00324 _TAO_collocation_Object_Proxy_Broker_Factory_Initializer_Scarecrow =
00325 _TAO_collocation_Object_Proxy_Broker_Factory_Initializer (
00326     reinterpret_cast<size_t> (_TAO_collocation_Object_Proxy_Broker_Factory_Initializer
00327       )
00328   );
00329 
00330 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Thu Nov 9 12:40:37 2006 for TAO_PortableServer by doxygen 1.3.6