00001
00002 #include "tao/DynamicInterface/DII_Invocation_Adapter.h"
00003 #include "tao/DynamicInterface/DII_Invocation.h"
00004 #include "tao/DynamicInterface/DII_Reply_Dispatcher.h"
00005
00006 #include "tao/Exception.h"
00007 #include "tao/ORB_Constants.h"
00008 #include "tao/Profile_Transport_Resolver.h"
00009 #include "tao/Transport.h"
00010 #include "tao/Transport.h"
00011 #include "tao/Pluggable_Messaging.h"
00012 #include "tao/DynamicInterface/Request.h"
00013
00014 #include "ace/os_include/os_errno.h"
00015
00016 ACE_RCSID (tao,
00017 Invocation_Adapter,
00018 "DII_Invocation_Adapter.cpp,v 1.14 2006/03/29 16:32:14 frehberger Exp")
00019
00020
00021 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00022
00023 namespace TAO
00024 {
00025 DII_Invocation_Adapter::DII_Invocation_Adapter (CORBA::Object *target,
00026 Argument **args,
00027 int arg_number,
00028 const char *operation,
00029 size_t op_len,
00030 CORBA::ExceptionList *excp,
00031 CORBA::Request *r,
00032 Invocation_Mode m)
00033
00034 : Invocation_Adapter (target,
00035 args,
00036 arg_number,
00037 operation,
00038 op_len,
00039 0,
00040 TAO_TWOWAY_INVOCATION,
00041 m)
00042 , exception_list_ (excp)
00043 , request_ (r)
00044 {
00045 }
00046
00047 Invocation_Status
00048 DII_Invocation_Adapter::invoke_twoway (
00049 TAO_Operation_Details &op,
00050 CORBA::Object_var &effective_target,
00051 Profile_Transport_Resolver &r,
00052 ACE_Time_Value *&max_wait_time
00053 ACE_ENV_ARG_DECL)
00054 {
00055
00056 if (this->mode_ != TAO_DII_INVOCATION ||
00057 this->type_ != TAO_TWOWAY_INVOCATION)
00058 {
00059 ACE_THROW_RETURN (CORBA::INTERNAL (
00060 CORBA::SystemException::_tao_minor_code (
00061 TAO::VMCID,
00062 EINVAL),
00063 CORBA::COMPLETED_NO),
00064 TAO_INVOKE_FAILURE);
00065 }
00066
00067 r.transport ()->messaging_object ()->out_stream ().reset_byte_order (request_->_tao_byte_order ());
00068
00069 TAO::DII_Invocation synch (this->target_,
00070 r,
00071 op,
00072 this->exception_list_,
00073 this->request_);
00074
00075
00076 Invocation_Status status =
00077 synch.remote_invocation (max_wait_time
00078 ACE_ENV_ARG_PARAMETER);
00079 ACE_CHECK_RETURN (TAO_INVOKE_FAILURE);
00080
00081
00082 if (status == TAO_INVOKE_RESTART &&
00083 synch.is_forwarded ())
00084 {
00085 effective_target =
00086 synch.steal_forwarded_reference ();
00087
00088 #if TAO_HAS_INTERCEPTORS == 1
00089 const CORBA::Boolean permanent_forward =
00090 (synch.reply_status() == TAO_PLUGGABLE_MESSAGE_LOCATION_FORWARD_PERM);
00091 #else
00092 const CORBA::Boolean permanent_forward = false;
00093 #endif
00094 this->object_forwarded (effective_target,
00095 r.stub (),
00096 permanent_forward
00097 ACE_ENV_ARG_PARAMETER);
00098 ACE_CHECK_RETURN (TAO_INVOKE_FAILURE);
00099 }
00100 return status;
00101 }
00102
00103
00104 DII_Deferred_Invocation_Adapter::DII_Deferred_Invocation_Adapter (
00105 CORBA::Object *target,
00106 Argument **args,
00107 int arg_number,
00108 const char *operation,
00109 size_t op_len,
00110 Collocation_Proxy_Broker *b,
00111 TAO_ORB_Core *oc,
00112 CORBA::Request *req,
00113 Invocation_Mode mode)
00114 : Invocation_Adapter (target,
00115 args,
00116 arg_number,
00117 operation,
00118 op_len,
00119 b,
00120 TAO_TWOWAY_INVOCATION,
00121 mode)
00122 , request_ (req)
00123 , rd_ (0)
00124 , orb_core_ (oc)
00125 {
00126 }
00127
00128 void
00129 DII_Deferred_Invocation_Adapter::invoke (
00130 TAO::Exception_Data *ex,
00131 unsigned long ex_count
00132 ACE_ENV_ARG_DECL)
00133 {
00134
00135
00136
00137
00138 ACE_NEW_THROW_EX (this->rd_,
00139 TAO_DII_Deferred_Reply_Dispatcher (this->request_,
00140 this->orb_core_),
00141 CORBA::NO_MEMORY ());
00142
00143 Invocation_Adapter::invoke (ex,
00144 ex_count
00145 ACE_ENV_ARG_PARAMETER);
00146 ACE_CHECK;
00147 }
00148
00149 Invocation_Status
00150 DII_Deferred_Invocation_Adapter::invoke_twoway (
00151 TAO_Operation_Details &op,
00152 CORBA::Object_var &effective_target,
00153 Profile_Transport_Resolver &r,
00154 ACE_Time_Value *&max_wait_time
00155 ACE_ENV_ARG_DECL)
00156 {
00157
00158 if (this->mode_ != TAO_DII_DEFERRED_INVOCATION ||
00159 this->type_ != TAO_TWOWAY_INVOCATION)
00160 {
00161 ACE_THROW_RETURN (CORBA::INTERNAL (
00162 CORBA::SystemException::_tao_minor_code (
00163 TAO::VMCID,
00164 EINVAL),
00165 CORBA::COMPLETED_NO),
00166 TAO_INVOKE_FAILURE);
00167 }
00168
00169 r.transport ()->messaging_object ()->out_stream ().reset_byte_order (request_->_tao_byte_order ());
00170 TAO::DII_Deferred_Invocation synch (
00171 this->target_,
00172 r,
00173 op,
00174 this->rd_,
00175 this->request_);
00176
00177 r.transport ()->messaging_object ()->out_stream ().reset_byte_order (request_->_tao_byte_order ());
00178
00179 Invocation_Status status =
00180 synch.remote_invocation (max_wait_time
00181 ACE_ENV_ARG_PARAMETER);
00182 ACE_CHECK_RETURN (TAO_INVOKE_FAILURE);
00183
00184 if (status == TAO_INVOKE_RESTART)
00185 {
00186 effective_target =
00187 synch.steal_forwarded_reference ();
00188 }
00189
00190 return status;
00191 }
00192 }
00193
00194 TAO_END_VERSIONED_NAMESPACE_DECL