Go to the documentation of this file.00001
00002
00003 #include "tao/Remote_Invocation.h"
00004 #include "tao/Profile.h"
00005 #include "tao/Profile_Transport_Resolver.h"
00006 #include "tao/Stub.h"
00007 #include "tao/Connection_Handler.h"
00008 #include "tao/operation_details.h"
00009 #include "tao/ORB_Core.h"
00010 #include "tao/Protocols_Hooks.h"
00011 #include "tao/Network_Priority_Protocols_Hooks.h"
00012 #include "tao/debug.h"
00013 #include "tao/SystemException.h"
00014
00015 ACE_RCSID (tao,
00016 Remote_Invocation,
00017 "$Id: Remote_Invocation.cpp 90435 2010-06-07 01:55:16Z dai_y $")
00018
00019 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00020
00021 namespace TAO
00022 {
00023 Remote_Invocation::Remote_Invocation (
00024 CORBA::Object_ptr otarget,
00025 Profile_Transport_Resolver &resolver,
00026 TAO_Operation_Details &detail,
00027 bool response_expected)
00028 : Invocation_Base (otarget,
00029 resolver.object (),
00030 resolver.stub (),
00031 detail,
00032 response_expected,
00033 true )
00034 , resolver_ (resolver)
00035 {
00036 }
00037
00038 void
00039 Remote_Invocation::init_target_spec (TAO_Target_Specification &target_spec,
00040 TAO_OutputCDR &output)
00041 {
00042
00043 this->resolver_.stub ()->orb_core ()->service_context_registry ().
00044 generate_service_context (
00045 this->resolver_.stub (),
00046 *this->resolver_.transport (),
00047 this->details_,
00048 target_spec,
00049 output);
00050
00051 TAO_Profile *pfile = this->resolver_.profile ();
00052
00053
00054 switch (pfile->addressing_mode ())
00055 {
00056 case TAO_Target_Specification::Key_Addr:
00057 target_spec.target_specifier (pfile->object_key ());
00058 break;
00059 case TAO_Target_Specification::Profile_Addr:
00060 {
00061 IOP::TaggedProfile *tp = pfile->create_tagged_profile ();
00062
00063 if (tp)
00064 {
00065 target_spec.target_specifier (*tp);
00066 }
00067 }
00068 break;
00069
00070 case TAO_Target_Specification::Reference_Addr:
00071
00072
00073
00074 CORBA::ULong index = 0;
00075 IOP::IOR *ior_info = 0;
00076
00077 if (this->resolver_.stub ()->create_ior_info (ior_info, index) == -1)
00078 {
00079 if (TAO_debug_level > 0)
00080 {
00081 ACE_ERROR ((LM_ERROR,
00082 ACE_TEXT ("TAO (%P|%t) - ")
00083 ACE_TEXT ("Remote_Invocation::init_target_spec, ")
00084 ACE_TEXT ("Error in finding index for ")
00085 ACE_TEXT ("IOP::IOR\n")));
00086 }
00087
00088 return;
00089 }
00090
00091 target_spec.target_specifier (*ior_info, index);
00092 break;
00093 }
00094 }
00095
00096 void
00097 Remote_Invocation::write_header (TAO_OutputCDR &out_stream)
00098 {
00099 this->resolver_.transport ()->clear_translators (0, &out_stream);
00100
00101 TAO_Target_Specification spec;
00102 this->init_target_spec (spec, out_stream);
00103
00104
00105 if (this->resolver_.transport ()->generate_request_header (this->details_,
00106 spec,
00107 out_stream) == -1)
00108 {
00109 throw ::CORBA::MARSHAL ();
00110 }
00111
00112 this->resolver_.transport ()->assign_translators (0, &out_stream);
00113 }
00114
00115 void
00116 Remote_Invocation::marshal_data (TAO_OutputCDR &out_stream)
00117 {
00118
00119 if (this->details_.marshal_args (out_stream) == false)
00120 {
00121 throw ::CORBA::MARSHAL ();
00122 }
00123 }
00124
00125 Invocation_Status
00126 Remote_Invocation::send_message (TAO_OutputCDR &cdr,
00127 TAO_Message_Semantics message_semantics,
00128 ACE_Time_Value *max_wait_time)
00129 {
00130 TAO_Protocols_Hooks *tph =
00131 this->resolver_.stub ()->orb_core ()->get_protocols_hooks ();
00132
00133 TAO_Network_Priority_Protocols_Hooks *nph =
00134 this->resolver_.stub ()->orb_core ()->
00135 get_network_priority_protocols_hooks ();
00136
00137 TAO_Connection_Handler *connection_handler =
00138 this->resolver_.transport ()->connection_handler ();
00139
00140 if (nph != 0)
00141 {
00142
00143
00144
00145
00146
00147
00148
00149 CORBA::Long const dscp = nph->get_dscp_codepoint (this->resolver_.stub (),
00150 this->resolver_.object ());
00151 connection_handler->set_dscp_codepoint (dscp);
00152 }
00153 else if (tph != 0)
00154 {
00155
00156
00157
00158
00159
00160
00161 CORBA::Boolean const set_client_network_priority =
00162 tph->set_client_network_priority (
00163 this->resolver_.transport ()->tag (),
00164 this->resolver_.stub ());
00165 connection_handler->set_dscp_codepoint (set_client_network_priority);
00166 }
00167
00168
00169
00170
00171
00172 if (! this->resolver_.transport ()->is_connected()) {
00173 throw ::CORBA::TRANSIENT (CORBA::OMGVMCID | 2, CORBA::COMPLETED_NO);
00174 }
00175
00176 int const retval =
00177 this->resolver_.transport ()->send_request (
00178 this->resolver_.stub (),
00179 this->resolver_.stub ()->orb_core (),
00180 cdr,
00181 message_semantics,
00182 max_wait_time);
00183
00184 if (retval == -1)
00185 {
00186 if (errno == ETIME)
00187 {
00188
00189
00190 throw ::CORBA::TIMEOUT (
00191 CORBA::SystemException::_tao_minor_code (
00192 TAO_TIMEOUT_SEND_MINOR_CODE,
00193 errno),
00194 CORBA::COMPLETED_MAYBE);
00195 }
00196
00197 if (TAO_debug_level > 2)
00198 {
00199 ACE_DEBUG ((LM_DEBUG,
00200 ACE_TEXT ("TAO (%P|%t) - ")
00201 ACE_TEXT ("Remote_Invocation::send_message, ")
00202 ACE_TEXT ("failure while sending message\n")));
00203 }
00204
00205
00206
00207 this->resolver_.transport ()->close_connection ();
00208 this->resolver_.stub ()->reset_profiles ();
00209 return TAO_INVOKE_RESTART;
00210 }
00211
00212 this->resolver_.stub ()->set_valid_profile ();
00213 return TAO_INVOKE_SUCCESS;
00214 }
00215 }
00216
00217 TAO_END_VERSIONED_NAMESPACE_DECL