Collocated_Invocation.cpp

Go to the documentation of this file.
00001 #include "tao/Collocated_Invocation.h"
00002 #include "tao/Collocation_Proxy_Broker.h"
00003 #include "tao/ORB_Core.h"
00004 #include "tao/Request_Dispatcher.h"
00005 #include "tao/TAO_Server_Request.h"
00006 #include "tao/Stub.h"
00007 #include "tao/operation_details.h"
00008 
00009 #if TAO_HAS_INTERCEPTORS == 1
00010 # include "tao/PortableInterceptorC.h"
00011 #endif /*TAO_HAS_INTERCEPTORS */
00012 
00013 ACE_RCSID (tao,
00014            Collocated_Invocation,
00015            "Collocated_Invocation.cpp,v 1.14 2006/04/19 08:35:03 jwillemsen Exp")
00016 
00017 
00018 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00019 
00020 namespace TAO
00021 {
00022   Collocated_Invocation::Collocated_Invocation (CORBA::Object_ptr t,
00023                                                 CORBA::Object_ptr et,
00024                                                 TAO_Stub *stub,
00025                                                 TAO_Operation_Details &detail,
00026                                                 bool response_expected)
00027     : Invocation_Base (t,
00028                        et,
00029                        stub,
00030                        detail,
00031                        response_expected,
00032                        false /* request_is_remote */ )
00033   {
00034   }
00035 
00036   Invocation_Status
00037   Collocated_Invocation::invoke (Collocation_Proxy_Broker *cpb,
00038                                  Collocation_Strategy strat
00039                                  ACE_ENV_ARG_DECL)
00040   {
00041     Invocation_Status s = TAO_INVOKE_FAILURE;
00042 
00043     /// Start the interception point
00044 #if TAO_HAS_INTERCEPTORS == 1
00045     s =
00046       this->send_request_interception (ACE_ENV_SINGLE_ARG_PARAMETER);
00047     ACE_CHECK_RETURN (TAO_INVOKE_FAILURE);
00048 
00049     if (s != TAO_INVOKE_SUCCESS)
00050       return s;
00051 #endif /*TAO_HAS_INTERCEPTORS */
00052 
00053     ACE_TRY
00054       {
00055         if (strat == TAO_CS_THRU_POA_STRATEGY)
00056           {
00057             // Perform invocations on the servant through the servant's ORB.
00058             CORBA::ORB_var servant_orb =
00059               this->effective_target ()->_stubobj ()->servant_orb_ptr ();
00060             TAO_ORB_Core * const orb_core = servant_orb->orb_core ();
00061 
00062             TAO_ServerRequest request (orb_core,
00063                                        this->details_,
00064                                        this->effective_target ());
00065 
00066             TAO_Request_Dispatcher * const dispatcher =
00067               orb_core->request_dispatcher ();
00068 
00069             // Retain ownership of the servant's ORB_Core in case
00070             // another thread attempts to destroy it (e.g. via
00071             // CORBA::ORB::destroy()) before this thread complete the
00072             // invocation.
00073             orb_core->_incr_refcnt ();
00074             TAO_ORB_Core_Auto_Ptr my_orb_core (orb_core);
00075 
00076             dispatcher->dispatch (orb_core,
00077                                   request,
00078                                   this->forwarded_to_.out ()
00079                                   ACE_ENV_ARG_PARAMETER);
00080             ACE_TRY_CHECK;
00081           }
00082         else
00083           {
00084             cpb->dispatch (this->effective_target (),
00085                            this->forwarded_to_.out (),
00086                            this->details_.args (),
00087                            this->details_.args_num (),
00088                            this->details_.opname (),
00089                            this->details_.opname_len (),
00090                            strat
00091                            ACE_ENV_ARG_PARAMETER);
00092             ACE_TRY_CHECK;
00093           }
00094 
00095         // Invocation completed succesfully
00096         s = TAO_INVOKE_SUCCESS;
00097 
00098 #if TAO_HAS_INTERCEPTORS == 1
00099         if (this->forwarded_to_.in () ||
00100             this->response_expected_ == false)
00101           {
00102             if (this->forwarded_to_.in ())
00103               this->reply_received (TAO_INVOKE_RESTART);
00104 
00105             s =
00106               this->receive_other_interception (ACE_ENV_SINGLE_ARG_PARAMETER);
00107             ACE_TRY_CHECK;
00108           }
00109         // NOTE: Any other condition that needs handling?
00110         else if (this->response_expected ())
00111           {
00112             this->reply_received (TAO_INVOKE_SUCCESS);
00113 
00114             s =
00115               this->receive_reply_interception (ACE_ENV_SINGLE_ARG_PARAMETER);
00116             ACE_TRY_CHECK;
00117           }
00118         if (s != TAO_INVOKE_SUCCESS)
00119           return s;
00120 #endif /*TAO_HAS_INTERCEPTORS */
00121       }
00122     ACE_CATCHANY
00123       {
00124         // Ignore exceptions for oneways
00125         if (this->response_expected_ == false)
00126           return TAO_INVOKE_SUCCESS;
00127 
00128 #if TAO_HAS_INTERCEPTORS == 1
00129         PortableInterceptor::ReplyStatus const status =
00130           this->handle_any_exception (&ACE_ANY_EXCEPTION
00131                                       ACE_ENV_ARG_PARAMETER);
00132         ACE_TRY_CHECK;
00133 
00134         if (status == PortableInterceptor::LOCATION_FORWARD ||
00135             status == PortableInterceptor::TRANSPORT_RETRY)
00136           s = TAO_INVOKE_RESTART;
00137         else
00138 #endif /*TAO_HAS_INTERCEPTORS*/
00139           ACE_RE_THROW;
00140       }
00141 # if defined (ACE_HAS_EXCEPTIONS) \
00142      && defined (ACE_HAS_BROKEN_UNEXPECTED_EXCEPTIONS)
00143     ACE_CATCHALL
00144       {
00145         if (this->response_expected () == false)
00146           return TAO_INVOKE_SUCCESS;
00147 #if TAO_HAS_INTERCEPTORS == 1
00148         PortableInterceptor::ReplyStatus const st =
00149           this->handle_all_exception (ACE_ENV_SINGLE_ARG_PARAMETER);
00150         ACE_TRY_CHECK;
00151 
00152         if (st == PortableInterceptor::LOCATION_FORWARD ||
00153             st == PortableInterceptor::TRANSPORT_RETRY)
00154           s = TAO_INVOKE_RESTART;
00155         else
00156 #endif /*TAO_HAS_INTERCEPTORS == 1*/
00157           ACE_RE_THROW;
00158       }
00159 # endif  /* ACE_HAS_EXCEPTIONS &&
00160             ACE_HAS_BROKEN_UNEXPECTED_EXCEPTIONS */
00161     ACE_ENDTRY;
00162     ACE_CHECK_RETURN (TAO_INVOKE_FAILURE);
00163 
00164     if (this->forwarded_to_.in () != 0)
00165       s =  TAO_INVOKE_RESTART;
00166 
00167     return s;
00168   }
00169 
00170 }
00171 
00172 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Thu Nov 9 11:54:09 2006 for TAO by doxygen 1.3.6