00001
00002 #include "tao/AnyTypeCode/TypeCode.h"
00003 #include "tao/AnyTypeCode/AnyTypeCode_methods.h"
00004 #include "tao/DynamicInterface/DII_Invocation_Adapter.h"
00005 #include "tao/DynamicInterface/DII_Invocation.h"
00006 #include "tao/DynamicInterface/DII_Reply_Dispatcher.h"
00007 #include "tao/DynamicInterface/DII_Arguments_Converter_Impl.h"
00008 #include "tao/DynamicInterface/Request.h"
00009
00010 #include "tao/Exception.h"
00011 #include "tao/Exception_Data.h"
00012 #include "tao/ORB_Constants.h"
00013 #include "tao/Profile_Transport_Resolver.h"
00014 #include "tao/Transport.h"
00015 #include "tao/GIOP_Message_Base.h"
00016 #include "tao/SystemException.h"
00017 #include "tao/operation_details.h"
00018
00019 #include "ace/os_include/os_errno.h"
00020
00021 ACE_RCSID (DynamicInterface,
00022 DII_Invocation_Adapter,
00023 "$Id: DII_Invocation_Adapter.cpp 84739 2009-03-06 17:30:13Z mitza $")
00024
00025
00026 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00027
00028 namespace TAO
00029 {
00030 DII_Invocation_Adapter::DII_Invocation_Adapter (CORBA::Object *target,
00031 Argument **args,
00032 int arg_number,
00033 const char *operation,
00034 size_t op_len,
00035 CORBA::ExceptionList *excp,
00036 CORBA::Request *r,
00037 Invocation_Mode mode)
00038
00039 : Invocation_Adapter (target,
00040 args,
00041 arg_number,
00042 operation,
00043 op_len,
00044 0,
00045 TAO_TWOWAY_INVOCATION,
00046 mode)
00047 , exception_list_ (excp)
00048 , request_ (r)
00049 , ex_data_ (0)
00050 {
00051 }
00052
00053 DII_Invocation_Adapter::~DII_Invocation_Adapter (void)
00054 {
00055 delete[] ex_data_;
00056 }
00057
00058 void
00059 DII_Invocation_Adapter::invoke (TAO::Exception_Data * ,
00060 unsigned long ex_count)
00061 {
00062
00063
00064 ex_count = this->exception_list_->count ();
00065 ACE_NEW_THROW_EX (this->ex_data_,
00066 TAO::Exception_Data[ex_count],
00067 CORBA::NO_MEMORY ());
00068 for (unsigned long l=0; l<ex_count ;++l)
00069 {
00070 CORBA::TypeCode_var xtc = this->exception_list_->item (l);
00071 this->ex_data_[l].id = xtc->id ();
00072 this->ex_data_[l].alloc = 0;
00073 #if TAO_HAS_INTERCEPTORS == 1
00074 this->ex_data_[l].tc_ptr = xtc.in ();
00075 #endif
00076 }
00077
00078 Invocation_Adapter::invoke (this->ex_data_, ex_count);
00079 }
00080
00081 Invocation_Status
00082 DII_Invocation_Adapter::invoke_collocated_i (
00083 TAO_Stub *stub,
00084 TAO_Operation_Details &details,
00085 CORBA::Object_var &effective_target,
00086 Collocation_Strategy strat)
00087 {
00088 TAO_DII_Arguments_Converter_Impl* dii_arguments_converter
00089 = ACE_Dynamic_Service<TAO_DII_Arguments_Converter_Impl>::instance (
00090 "DII_Arguments_Converter");
00091 details.cac (dii_arguments_converter);
00092
00093 return Invocation_Adapter::invoke_collocated_i (stub,
00094 details,
00095 effective_target,
00096 strat);
00097 }
00098
00099 Invocation_Status
00100 DII_Invocation_Adapter::invoke_twoway (
00101 TAO_Operation_Details &op,
00102 CORBA::Object_var &effective_target,
00103 Profile_Transport_Resolver &r,
00104 ACE_Time_Value *&max_wait_time)
00105 {
00106
00107 if (this->mode_ != TAO_DII_INVOCATION ||
00108 this->type_ != TAO_TWOWAY_INVOCATION)
00109 {
00110 throw ::CORBA::INTERNAL (
00111 CORBA::SystemException::_tao_minor_code (
00112 TAO::VMCID,
00113 EINVAL),
00114 CORBA::COMPLETED_NO);
00115 }
00116
00117 TAO_Transport* const transport = r.transport ();
00118
00119 if (!transport)
00120 {
00121
00122
00123
00124 throw CORBA::TRANSIENT (CORBA::OMGVMCID | 2, CORBA::COMPLETED_NO);
00125 }
00126
00127 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, transport->output_cdr_lock (),
00128 TAO_INVOKE_FAILURE);
00129
00130 transport->messaging_object ()->out_stream ().reset_byte_order (
00131 request_->_tao_byte_order ());
00132
00133 TAO::DII_Invocation synch (this->target_,
00134 r,
00135 op,
00136 this->exception_list_,
00137 this->request_);
00138
00139 ace_mon.release();
00140
00141 Invocation_Status status = synch.remote_invocation (max_wait_time);
00142
00143 if (status == TAO_INVOKE_RESTART &&
00144 (synch.reply_status () == GIOP::LOCATION_FORWARD ||
00145 synch.reply_status () == GIOP::LOCATION_FORWARD_PERM))
00146 {
00147 CORBA::Boolean const permanent_forward =
00148 (synch.reply_status () == GIOP::LOCATION_FORWARD_PERM);
00149
00150 effective_target = synch.steal_forwarded_reference ();
00151
00152 this->object_forwarded (effective_target,
00153 r.stub (),
00154 permanent_forward);
00155 }
00156 return status;
00157 }
00158
00159
00160 DII_Deferred_Invocation_Adapter::DII_Deferred_Invocation_Adapter (
00161 CORBA::Object *target,
00162 Argument **args,
00163 int arg_number,
00164 const char *operation,
00165 size_t op_len,
00166 Collocation_Proxy_Broker *b,
00167 TAO_ORB_Core *oc,
00168 CORBA::Request *req,
00169 Invocation_Mode mode)
00170 : Invocation_Adapter (target,
00171 args,
00172 arg_number,
00173 operation,
00174 op_len,
00175 b,
00176 TAO_TWOWAY_INVOCATION,
00177 mode)
00178 , request_ (req)
00179 , rd_ (0)
00180 , orb_core_ (oc)
00181 {
00182 }
00183
00184 void
00185 DII_Deferred_Invocation_Adapter::invoke (
00186 TAO::Exception_Data *ex,
00187 unsigned long ex_count)
00188 {
00189
00190
00191
00192
00193 ACE_NEW_THROW_EX (this->rd_,
00194 TAO_DII_Deferred_Reply_Dispatcher (this->request_,
00195 this->orb_core_),
00196 CORBA::NO_MEMORY ());
00197
00198 Invocation_Adapter::invoke (ex, ex_count);
00199 }
00200
00201 Invocation_Status
00202 DII_Deferred_Invocation_Adapter::invoke_collocated_i (
00203 TAO_Stub *stub,
00204 TAO_Operation_Details &details,
00205 CORBA::Object_var &effective_target,
00206 Collocation_Strategy strat)
00207 {
00208 TAO_DII_Arguments_Converter_Impl* dii_arguments_converter
00209 = ACE_Dynamic_Service<TAO_DII_Arguments_Converter_Impl>::instance (
00210 "DII_Arguments_Converter");
00211 details.cac (dii_arguments_converter);
00212
00213 return Invocation_Adapter::invoke_collocated_i (stub,
00214 details,
00215 effective_target,
00216 strat);
00217 }
00218
00219 Invocation_Status
00220 DII_Deferred_Invocation_Adapter::invoke_twoway (
00221 TAO_Operation_Details &op,
00222 CORBA::Object_var &effective_target,
00223 Profile_Transport_Resolver &r,
00224 ACE_Time_Value *&max_wait_time)
00225 {
00226
00227 if (this->mode_ != TAO_DII_DEFERRED_INVOCATION ||
00228 this->type_ != TAO_TWOWAY_INVOCATION)
00229 {
00230 throw ::CORBA::INTERNAL (
00231 CORBA::SystemException::_tao_minor_code (
00232 TAO::VMCID,
00233 EINVAL),
00234 CORBA::COMPLETED_NO);
00235 }
00236
00237 TAO_Transport* const transport = r.transport ();
00238
00239 if (!transport)
00240 {
00241
00242
00243
00244 throw CORBA::TRANSIENT (CORBA::OMGVMCID | 2, CORBA::COMPLETED_NO);
00245 }
00246
00247 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, transport->output_cdr_lock (),
00248 TAO_INVOKE_FAILURE);
00249
00250 transport->messaging_object ()->out_stream ().reset_byte_order (
00251 request_->_tao_byte_order ());
00252
00253 TAO::DII_Deferred_Invocation synch (
00254 this->target_,
00255 r,
00256 op,
00257 this->rd_,
00258 this->request_);
00259
00260 ace_mon.release ();
00261
00262 Invocation_Status status = synch.remote_invocation (max_wait_time);
00263
00264 if (status == TAO_INVOKE_RESTART)
00265 {
00266 effective_target = synch.steal_forwarded_reference ();
00267 }
00268
00269 return status;
00270 }
00271
00272 DII_Asynch_Invocation_Adapter::DII_Asynch_Invocation_Adapter (
00273 CORBA::Object *target,
00274 Argument **args,
00275 int arg_count,
00276 const char *operation,
00277 int op_len,
00278 CORBA::Request *req,
00279 TAO::Invocation_Mode mode)
00280 : DII_Invocation_Adapter (target,
00281 args,
00282 arg_count,
00283 operation,
00284 op_len,
00285 0,
00286 req,
00287 mode)
00288 {
00289 }
00290
00291 Invocation_Status
00292 DII_Asynch_Invocation_Adapter::invoke_twoway (
00293 TAO_Operation_Details &,
00294 CORBA::Object_var &,
00295 Profile_Transport_Resolver &,
00296 ACE_Time_Value *&)
00297 {
00298 return TAO_INVOKE_FAILURE;
00299 }
00300
00301 DII_Oneway_Invocation_Adapter::DII_Oneway_Invocation_Adapter (
00302 CORBA::Object *target,
00303 Argument **args,
00304 int arg_count,
00305 const char *operation,
00306 int op_len,
00307 TAO::Invocation_Mode mode)
00308 : Invocation_Adapter (target,
00309 args,
00310 arg_count,
00311 operation,
00312 op_len,
00313 0,
00314 TAO_ONEWAY_INVOCATION,
00315 mode)
00316 {
00317 }
00318
00319 Invocation_Status
00320 DII_Oneway_Invocation_Adapter::invoke_collocated_i (
00321 TAO_Stub *stub,
00322 TAO_Operation_Details &details,
00323 CORBA::Object_var &effective_target,
00324 Collocation_Strategy strat)
00325 {
00326 TAO_DII_Arguments_Converter_Impl* dii_arguments_converter
00327 = ACE_Dynamic_Service<TAO_DII_Arguments_Converter_Impl>::instance (
00328 "DII_Arguments_Converter");
00329 details.cac (dii_arguments_converter);
00330
00331 return Invocation_Adapter::invoke_collocated_i (stub,
00332 details,
00333 effective_target,
00334 strat);
00335 }
00336
00337
00338 }
00339 TAO_END_VERSIONED_NAMESPACE_DECL