DII_Invocation_Adapter.cpp

Go to the documentation of this file.
00001 //$Id: DII_Invocation_Adapter.cpp 78128 2007-04-20 08:07:58Z johnnyw $
00002 #include "tao/DynamicInterface/DII_Invocation_Adapter.h"
00003 #include "tao/DynamicInterface/DII_Invocation.h"
00004 #include "tao/DynamicInterface/DII_Reply_Dispatcher.h"
00005 #include "tao/DynamicInterface/DII_Arguments_Converter_Impl.h"
00006 #include "tao/DynamicInterface/Request.h"
00007 
00008 #include "tao/Exception.h"
00009 #include "tao/ORB_Constants.h"
00010 #include "tao/Profile_Transport_Resolver.h"
00011 #include "tao/Transport.h"
00012 #include "tao/Transport.h"
00013 #include "tao/Pluggable_Messaging.h"
00014 #include "tao/SystemException.h"
00015 #include "tao/operation_details.h"
00016 
00017 #include "ace/os_include/os_errno.h"
00018 
00019 ACE_RCSID (tao,
00020            Invocation_Adapter,
00021            "$Id: DII_Invocation_Adapter.cpp 78128 2007-04-20 08:07:58Z johnnyw $")
00022 
00023 
00024 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00025 
00026 namespace TAO
00027 {
00028   DII_Invocation_Adapter::DII_Invocation_Adapter (CORBA::Object *target,
00029                                                   Argument **args,
00030                                                   int arg_number,
00031                                                   const char *operation,
00032                                                   size_t op_len,
00033                                                   CORBA::ExceptionList *excp,
00034                                                   CORBA::Request *r,
00035                                                   Invocation_Mode mode)
00036 
00037     : Invocation_Adapter (target,
00038                           args,
00039                           arg_number,
00040                           operation,
00041                           op_len,
00042                           0, // Collocation Proxy broker pointer
00043                           TAO_TWOWAY_INVOCATION,
00044                           mode)
00045       , exception_list_ (excp)
00046       , request_ (r)
00047   {
00048   }
00049 
00050   DII_Invocation_Adapter::~DII_Invocation_Adapter (void)
00051   {
00052   }
00053 
00054   Invocation_Status
00055   DII_Invocation_Adapter::invoke_collocated_i (
00056     TAO_Stub *stub,
00057     TAO_Operation_Details &details,
00058     CORBA::Object_var &effective_target,
00059     Collocation_Strategy strat)
00060   {
00061     TAO_DII_Arguments_Converter_Impl* dii_arguments_converter
00062       = ACE_Dynamic_Service<TAO_DII_Arguments_Converter_Impl>::instance (
00063         "DII_Arguments_Converter");
00064     details.cac (dii_arguments_converter);
00065 
00066     return Invocation_Adapter::invoke_collocated_i (stub,
00067                                                     details,
00068                                                     effective_target,
00069                                                     strat);
00070   }
00071 
00072   Invocation_Status
00073   DII_Invocation_Adapter::invoke_twoway (
00074         TAO_Operation_Details &op,
00075         CORBA::Object_var &effective_target,
00076         Profile_Transport_Resolver &r,
00077         ACE_Time_Value *&max_wait_time)
00078   {
00079     // Simple sanity check
00080     if (this->mode_ != TAO_DII_INVOCATION ||
00081         this->type_ != TAO_TWOWAY_INVOCATION)
00082       {
00083         throw ::CORBA::INTERNAL (
00084           CORBA::SystemException::_tao_minor_code (
00085             TAO::VMCID,
00086             EINVAL),
00087           CORBA::COMPLETED_NO);
00088       }
00089 
00090     r.transport ()->messaging_object ()->out_stream ().reset_byte_order (
00091         request_->_tao_byte_order ());
00092 
00093     TAO::DII_Invocation synch (this->target_,
00094                                r,
00095                                op,
00096                                this->exception_list_,
00097                                this->request_);
00098 
00099 
00100     Invocation_Status status = synch.remote_invocation (max_wait_time);
00101 
00102     if (status == TAO_INVOKE_RESTART && synch.is_forwarded ())
00103       {
00104         effective_target = synch.steal_forwarded_reference ();
00105 
00106 #if TAO_HAS_INTERCEPTORS == 1
00107         CORBA::Boolean const permanent_forward =
00108             (synch.reply_status() == TAO_PLUGGABLE_MESSAGE_LOCATION_FORWARD_PERM);
00109 #else
00110         CORBA::Boolean const permanent_forward = false;
00111 #endif
00112         this->object_forwarded (effective_target,
00113                                 r.stub (),
00114                                 permanent_forward);
00115       }
00116     return status;
00117   }
00118 
00119   //================================================================
00120   DII_Deferred_Invocation_Adapter::DII_Deferred_Invocation_Adapter (
00121       CORBA::Object *target,
00122       Argument **args,
00123       int arg_number,
00124       const char *operation,
00125       size_t op_len,
00126       Collocation_Proxy_Broker *b,
00127       TAO_ORB_Core *oc,
00128       CORBA::Request *req,
00129       Invocation_Mode mode)
00130     : Invocation_Adapter (target,
00131                           args,
00132                           arg_number,
00133                           operation,
00134                           op_len,
00135                           b,
00136                           TAO_TWOWAY_INVOCATION,
00137                           mode)
00138       , request_ (req)
00139       , rd_ (0)
00140       , orb_core_ (oc)
00141   {
00142   }
00143 
00144   void
00145   DII_Deferred_Invocation_Adapter::invoke (
00146       TAO::Exception_Data *ex,
00147       unsigned long ex_count)
00148   {
00149     // New reply dispatcher on the heap, because we will go out of
00150     // scope and hand over the reply dispatcher to the ORB.
00151     // So this->rd_ is 0, because we do not need to
00152     // hold a pointer to it.
00153     ACE_NEW_THROW_EX (this->rd_,
00154         TAO_DII_Deferred_Reply_Dispatcher (this->request_,
00155                                            this->orb_core_),
00156                       CORBA::NO_MEMORY ());
00157 
00158     Invocation_Adapter::invoke (ex, ex_count);
00159   }
00160 
00161   Invocation_Status
00162   DII_Deferred_Invocation_Adapter::invoke_collocated_i (
00163     TAO_Stub *stub,
00164     TAO_Operation_Details &details,
00165     CORBA::Object_var &effective_target,
00166     Collocation_Strategy strat)
00167   {
00168     TAO_DII_Arguments_Converter_Impl* dii_arguments_converter
00169       = ACE_Dynamic_Service<TAO_DII_Arguments_Converter_Impl>::instance (
00170         "DII_Arguments_Converter");
00171     details.cac (dii_arguments_converter);
00172 
00173     return Invocation_Adapter::invoke_collocated_i (stub,
00174                                                     details,
00175                                                     effective_target,
00176                                                     strat);
00177   }
00178 
00179   Invocation_Status
00180   DII_Deferred_Invocation_Adapter::invoke_twoway (
00181       TAO_Operation_Details &op,
00182       CORBA::Object_var &effective_target,
00183       Profile_Transport_Resolver &r,
00184       ACE_Time_Value *&max_wait_time)
00185   {
00186     // Simple sanity check
00187     if (this->mode_ != TAO_DII_DEFERRED_INVOCATION ||
00188         this->type_ != TAO_TWOWAY_INVOCATION)
00189       {
00190         throw ::CORBA::INTERNAL (
00191           CORBA::SystemException::_tao_minor_code (
00192             TAO::VMCID,
00193             EINVAL),
00194           CORBA::COMPLETED_NO);
00195       }
00196 
00197     r.transport ()->messaging_object ()->out_stream ().reset_byte_order (request_->_tao_byte_order ());
00198     TAO::DII_Deferred_Invocation synch (
00199         this->target_,
00200         r,
00201         op,
00202         this->rd_,
00203         this->request_);
00204 
00205     r.transport ()->messaging_object ()->out_stream ().reset_byte_order (request_->_tao_byte_order ());
00206 
00207     Invocation_Status status = synch.remote_invocation (max_wait_time);
00208 
00209     if (status == TAO_INVOKE_RESTART)
00210       {
00211         effective_target = synch.steal_forwarded_reference ();
00212       }
00213 
00214     return status;
00215   }
00216 
00217   DII_Asynch_Invocation_Adapter::DII_Asynch_Invocation_Adapter (
00218       CORBA::Object *target,
00219       Argument **args,
00220       int arg_count,
00221       const char *operation,
00222       int op_len,
00223       CORBA::Request *req,
00224       TAO::Invocation_Mode mode)
00225     : DII_Invocation_Adapter (target,
00226                               args,
00227                               arg_count,
00228                               operation,
00229                               op_len,
00230                               0,
00231                               req,
00232                               mode)
00233   {
00234   }
00235 
00236   Invocation_Status
00237   DII_Asynch_Invocation_Adapter::invoke_twoway (
00238         TAO_Operation_Details &,
00239         CORBA::Object_var &,
00240         Profile_Transport_Resolver &,
00241         ACE_Time_Value *&)
00242   {
00243     return TAO_INVOKE_FAILURE;
00244   }
00245 
00246   DII_Oneway_Invocation_Adapter::DII_Oneway_Invocation_Adapter (
00247       CORBA::Object *target,
00248       Argument **args,
00249       int arg_count,
00250       const char *operation,
00251       int op_len,
00252       TAO::Invocation_Mode mode)
00253     : Invocation_Adapter (target,
00254                           args,
00255                           arg_count,
00256                           operation,
00257                           op_len,
00258                           0,
00259                           TAO_ONEWAY_INVOCATION,
00260                           mode)
00261   {
00262   }
00263 
00264   Invocation_Status
00265   DII_Oneway_Invocation_Adapter::invoke_collocated_i (
00266     TAO_Stub *stub,
00267     TAO_Operation_Details &details,
00268     CORBA::Object_var &effective_target,
00269     Collocation_Strategy strat)
00270   {
00271     TAO_DII_Arguments_Converter_Impl* dii_arguments_converter
00272       = ACE_Dynamic_Service<TAO_DII_Arguments_Converter_Impl>::instance (
00273         "DII_Arguments_Converter");
00274     details.cac (dii_arguments_converter);
00275 
00276     return Invocation_Adapter::invoke_collocated_i (stub,
00277                                                     details,
00278                                                     effective_target,
00279                                                     strat);
00280   }
00281 
00282 
00283 } // End namespace TAO
00284 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Sun Jan 27 13:37:31 2008 for TAO_DynamicInterface by doxygen 1.3.6