Collocated_Object_Proxy_Broker.cpp

Go to the documentation of this file.
00001 //$Id: Collocated_Object_Proxy_Broker.cpp 79610 2007-09-07 18:17:34Z johnnyw $
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            "$Id: Collocated_Object_Proxy_Broker.cpp 79610 2007-09-07 18:17:34Z johnnyw $")
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   {
00026     TAO_Stub *stub = target->_stubobj ();
00027 
00028     // Which collocation strategy should we use?
00029     if (stub != 0 &&
00030         stub->servant_orb_var ()->orb_core ()->get_collocation_strategy ()
00031           == TAO_ORB_Core::THRU_POA)
00032       {
00033         TAO::Portable_Server::Servant_Upcall servant_upcall (
00034           stub->servant_orb_var ()->orb_core ());
00035 
00036       CORBA::Object_var forward_to;
00037       servant_upcall.prepare_for_upcall (
00038           stub->profile_in_use ()->object_key (),
00039           "_is_a",
00040           forward_to.out ());
00041 
00042       servant_upcall.pre_invoke_collocated_request ();
00043 
00044       return servant_upcall.servant ()->_is_a (type_id);
00045     }
00046 
00047     // Direct collocation strategy is used.
00048     if (target->_servant () != 0)
00049       {
00050         return target->_servant ()->_is_a (type_id);
00051       }
00052 
00053     return 0;
00054   }
00055 
00056 #if (TAO_HAS_MINIMUM_CORBA == 0)
00057 
00058   char *
00059   Collocated_Object_Proxy_Broker::_repository_id (CORBA::Object_ptr target)
00060   {
00061     TAO_Stub *stub = target->_stubobj ();
00062     char * _tao_retval = 0;
00063 
00064     try
00065       {
00066         // Which collocation strategy should we use?
00067         if (stub != 0 &&
00068             stub->servant_orb_var ()->orb_core ()
00069               ->get_collocation_strategy () == TAO_ORB_Core::THRU_POA)
00070           {
00071             TAO::Portable_Server::Servant_Upcall servant_upcall (
00072                 stub->servant_orb_var ()->orb_core ());
00073 
00074             CORBA::Object_var forward_to;
00075             servant_upcall.prepare_for_upcall (
00076                 stub->profile_in_use ()->object_key (),
00077                 "_repository_id",
00078                 forward_to.out ());
00079 
00080             _tao_retval =
00081               servant_upcall.servant ()->_repository_id ();
00082           }
00083         // Direct collocation strategy is used.
00084         else if (target->_servant () != 0)
00085           {
00086             _tao_retval = target->_servant ()->_repository_id ();
00087           }
00088       }
00089     catch (const ::CORBA::OBJECT_NOT_EXIST&)
00090       {
00091         // Ignore this exception.
00092       }
00093 
00094     return _tao_retval;
00095   }
00096 
00097   CORBA::Boolean
00098   Collocated_Object_Proxy_Broker::_non_existent (CORBA::Object_ptr target)
00099   {
00100     CORBA::Boolean _tao_retval = true;
00101 
00102     TAO_Stub *stub = target->_stubobj ();
00103 
00104     // Which collocation strategy should we use?
00105     if (stub != 0 &&
00106         stub->servant_orb_var ()->orb_core ()
00107         ->get_collocation_strategy () == TAO_ORB_Core::THRU_POA)
00108       {
00109         TAO::Portable_Server::Servant_Upcall servant_upcall (
00110           target->_stubobj ()->servant_orb_var ()->orb_core ());
00111 
00112         CORBA::Object_var forward_to;
00113 
00114         servant_upcall.prepare_for_upcall (
00115           target->_stubobj ()->object_key (),
00116           "_non_existent",
00117           forward_to.out ());
00118 
00119         servant_upcall.pre_invoke_collocated_request ();
00120 
00121         _tao_retval = servant_upcall.servant ()->_non_existent ();
00122       }
00123     // Direct collocation strategy is used.
00124     else if (target->_servant () != 0)
00125       {
00126         _tao_retval = target->_servant ()->_non_existent ();
00127       }
00128 
00129     return _tao_retval;
00130   }
00131 
00132 #if !defined (CORBA_E_COMPACT) && !defined (CORBA_E_MICRO)
00133   CORBA::Object_ptr
00134   Collocated_Object_Proxy_Broker::_get_component (CORBA::Object_ptr target)
00135   {
00136     CORBA::Object_var _tao_retval (CORBA::Object::_nil ());
00137 
00138     TAO_Stub *stub = target->_stubobj ();
00139 
00140     try
00141       {
00142         // Which collocation strategy should we use?
00143         if (stub != 0 &&
00144             stub->servant_orb_var ()->orb_core ()
00145               ->get_collocation_strategy () == TAO_ORB_Core::THRU_POA)
00146           {
00147             TAO::Portable_Server::Servant_Upcall servant_upcall (
00148                 stub->servant_orb_var ()->orb_core ());
00149 
00150             CORBA::Object_var forward_to;
00151             servant_upcall.prepare_for_upcall (
00152                 stub->profile_in_use ()->object_key (),
00153                 "_component",
00154                 forward_to.out ());
00155 
00156             _tao_retval = servant_upcall.servant ()->_get_component ();
00157           }
00158         // Direct collocation strategy is used.
00159         else if (target->_servant () != 0)
00160           {
00161             _tao_retval = target->_servant ()->_get_component ();
00162           }
00163       }
00164     catch (const ::CORBA::OBJECT_NOT_EXIST&)
00165       {
00166         // Ignore this exception.
00167       }
00168 
00169     return _tao_retval._retn ();
00170   }
00171 
00172   CORBA::InterfaceDef_ptr
00173   Collocated_Object_Proxy_Broker::_get_interface (CORBA::Object_ptr target)
00174   {
00175     CORBA::InterfaceDef_ptr _tao_retval = 0;
00176 
00177     TAO_Stub *stub = target->_stubobj ();
00178 
00179     try
00180       {
00181         // Which collocation strategy should we use?
00182         if (stub != 0 &&
00183             stub->servant_orb_var ()->orb_core ()->get_collocation_strategy ()
00184               == TAO_ORB_Core::THRU_POA)
00185           {
00186             TAO::Portable_Server::Servant_Upcall servant_upcall (
00187                 target->_stubobj ()->servant_orb_var ()->orb_core ());
00188 
00189             CORBA::Object_var forward_to;
00190 
00191             servant_upcall.prepare_for_upcall (
00192                 target->_stubobj ()->object_key (),
00193                 "_interface",
00194                 forward_to.out ());
00195 
00196             servant_upcall.pre_invoke_collocated_request ();
00197 
00198             _tao_retval =
00199               servant_upcall.servant ()->_get_interface ();
00200           }
00201         // Direct collocation strategy is used.
00202         else if (target->_servant () != 0)
00203           {
00204             _tao_retval = target->_servant ()->_get_interface ();
00205           }
00206       }
00207     catch (const ::CORBA::OBJECT_NOT_EXIST&)
00208       {
00209         // Ignore this exception.
00210       }
00211 
00212     return _tao_retval;
00213   }
00214 #endif
00215 
00216 #endif /* TAO_HAS_MINIMUM_CORBA == 0 */
00217 
00218 }
00219 
00220 // -----------------------------------------------------
00221 TAO::Collocated_Object_Proxy_Broker *
00222 the_tao_collocated_object_proxy_broker (void)
00223 {
00224   static TAO::Collocated_Object_Proxy_Broker the_broker;
00225   return &the_broker;
00226 }
00227 
00228 TAO::Object_Proxy_Broker * _TAO_collocation_Object_Proxy_Broker_Factory (void)
00229 {
00230   return the_tao_collocated_object_proxy_broker ();
00231 }
00232 
00233 int
00234 _TAO_collocation_Object_Proxy_Broker_Factory_Initializer (size_t)
00235 {
00236   _TAO_Object_Proxy_Broker_Factory_function_pointer =
00237     _TAO_collocation_Object_Proxy_Broker_Factory;
00238 
00239   return 0;
00240 }
00241 
00242 static int
00243 _TAO_collocation_Object_Proxy_Broker_Factory_Initializer_Scarecrow =
00244 _TAO_collocation_Object_Proxy_Broker_Factory_Initializer (
00245     reinterpret_cast<size_t> (_TAO_collocation_Object_Proxy_Broker_Factory_Initializer
00246       )
00247   );
00248 
00249 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Tue Feb 2 17:40:54 2010 for TAO_PortableServer by  doxygen 1.4.7