Go to the documentation of this file.00001
00002
00003 #include "tao/PortableServer/Upcall_Wrapper.h"
00004 #include "tao/PortableServer/Upcall_Command.h"
00005 #include "tao/PortableServer/Collocated_Arguments_Converter.h"
00006 #include "tao/SystemException.h"
00007
00008 #if TAO_HAS_INTERCEPTORS == 1
00009 # include "tao/ServerRequestInterceptor_Adapter.h"
00010 # include "tao/ORB_Core.h"
00011 #endif
00012
00013 #include "tao/PortableInterceptorC.h"
00014 #include "tao/PortableInterceptor.h"
00015
00016 #include "tao/TAO_Server_Request.h"
00017 #include "tao/CDR.h"
00018 #include "tao/Argument.h"
00019 #include "tao/operation_details.h"
00020 #include "ace/Log_Msg.h"
00021 #include "tao/debug.h"
00022
00023 ACE_RCSID (PortableServer,
00024 Upcall_Wrapper,
00025 "$Id: Upcall_Wrapper.cpp 87951 2009-12-07 07:13:31Z dai_y $")
00026
00027 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00028
00029 void
00030 TAO::Upcall_Wrapper::upcall (TAO_ServerRequest & server_request,
00031 TAO::Argument * const args[],
00032 size_t nargs,
00033 TAO::Upcall_Command & command
00034 #if TAO_HAS_INTERCEPTORS == 1
00035 , void * servant_upcall
00036 , CORBA::TypeCode_ptr const * exceptions
00037 , CORBA::ULong nexceptions
00038 #endif
00039 )
00040 {
00041 if (server_request.collocated ()
00042 && server_request.operation_details ()->cac () != 0)
00043 {
00044 server_request.operation_details ()->cac ()->convert_request (
00045 server_request, args, nargs);
00046 }
00047
00048 if (server_request.incoming ())
00049 {
00050 this->pre_upcall (*server_request.incoming (), args, nargs);
00051 }
00052
00053 #if TAO_HAS_INTERCEPTORS == 1
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070 TAO::Argument * const * the_args = args;
00071 size_t the_nargs = nargs;
00072
00073 if (server_request.collocated())
00074 {
00075
00076
00077 the_args = server_request.operation_details()->args();
00078 the_nargs = server_request.operation_details()->args_num();
00079 }
00080
00081 TAO::ServerRequestInterceptor_Adapter *interceptor_adapter =
00082 server_request.orb_core ()->serverrequestinterceptor_adapter ();
00083 #endif
00084
00085 try
00086 {
00087 {
00088 #if TAO_HAS_INTERCEPTORS == 1
00089 if (interceptor_adapter != 0)
00090 {
00091
00092 interceptor_adapter->receive_request (server_request,
00093 the_args,
00094 the_nargs,
00095 servant_upcall,
00096 exceptions,
00097 nexceptions);
00098 }
00099
00100
00101
00102 CORBA::Object_var forward_to = server_request.forward_location ();
00103 if (!server_request.is_forwarded ())
00104 {
00105 if (interceptor_adapter != 0)
00106 {
00107 interceptor_adapter->execute_command (server_request, command);
00108 }
00109 else
00110 #endif
00111 {
00112
00113 command.execute ();
00114 }
00115 #if TAO_HAS_INTERCEPTORS == 1
00116 }
00117 #endif
00118 }
00119 #if TAO_HAS_INTERCEPTORS == 1
00120 if (interceptor_adapter == 0)
00121 {
00122 server_request.pi_reply_status (PortableInterceptor::SUCCESSFUL);
00123 }
00124 else
00125 {
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136 CORBA::Object_var forward_to_after = server_request.forward_location ();
00137 if (!server_request.is_forwarded ())
00138 {
00139
00140 server_request.pi_reply_status (PortableInterceptor::SUCCESSFUL);
00141 interceptor_adapter->send_reply (server_request,
00142 the_args,
00143 the_nargs,
00144 servant_upcall,
00145 exceptions,
00146 nexceptions);
00147 }
00148 }
00149 #endif
00150 }
00151 catch ( ::CORBA::Exception& ex)
00152 {
00153
00154
00155
00156
00157 PortableInterceptor::ReplyStatus status =
00158 PortableInterceptor::SYSTEM_EXCEPTION;
00159
00160 #if TAO_HAS_INTERCEPTORS == 1
00161 server_request.caught_exception (&ex);
00162
00163 if (interceptor_adapter != 0)
00164 {
00165 interceptor_adapter->send_exception (server_request,
00166 the_args,
00167 the_nargs,
00168 servant_upcall,
00169 exceptions,
00170 nexceptions);
00171
00172 status = server_request.pi_reply_status ();
00173 }
00174 #endif
00175
00176 if (status == PortableInterceptor::SYSTEM_EXCEPTION
00177 || status == PortableInterceptor::USER_EXCEPTION)
00178 {
00179 if (server_request.collocated ()
00180 && server_request.operation_details ()->cac () != 0)
00181 {
00182
00183
00184 server_request.operation_details ()->cac ()->handle_corba_exception (
00185 server_request, &ex);
00186 return;
00187 }
00188 else
00189 {
00190 throw;
00191 }
00192 }
00193 }
00194
00195 if (server_request.response_expected ()
00196 && !server_request.sync_with_server ())
00197 {
00198 server_request.init_reply ();
00199 }
00200
00201 #if TAO_HAS_INTERCEPTORS == 1
00202
00203
00204 if (!server_request.is_forwarded ())
00205 #endif
00206 {
00207 if (server_request.outgoing ())
00208 {
00209 this->post_upcall (server_request, args, nargs);
00210 }
00211 }
00212
00213 if (server_request.collocated ()
00214 && server_request.operation_details ()->cac () != 0)
00215 {
00216 server_request.operation_details ()->cac ()->convert_reply (
00217 server_request, args, nargs);
00218 }
00219 }
00220
00221 void
00222 TAO::Upcall_Wrapper::pre_upcall (TAO_InputCDR & cdr,
00223 TAO::Argument * const * args,
00224 size_t nargs)
00225 {
00226
00227
00228
00229
00230
00231
00232 try {
00233 TAO::Argument * const * const begin = args + 1;
00234 TAO::Argument * const * const end = args + nargs;
00235
00236 for (TAO::Argument * const * i = begin; i != end; ++i)
00237 {
00238 if (!(*i)->demarshal (cdr))
00239 {
00240 TAO_InputCDR::throw_skel_exception (errno);
00241 }
00242 }
00243
00244 cdr.reset_vt_indirect_maps ();
00245 }
00246 catch (...) {
00247 cdr.reset_vt_indirect_maps ();
00248 throw;
00249 }
00250 }
00251
00252 void
00253 TAO::Upcall_Wrapper::post_upcall (TAO_ServerRequest& server_request,
00254 TAO::Argument * const * args,
00255 size_t nargs)
00256 {
00257 TAO_OutputCDR & cdr = (*server_request.outgoing ());
00258 TAO::Argument * const * const begin = args;
00259 TAO::Argument * const * const end = args + nargs;
00260
00261 try {
00262 for (TAO::Argument * const * i = begin; i != end; ++i)
00263 {
00264 if (!(*i)->marshal (cdr))
00265 {
00266 TAO_OutputCDR::throw_skel_exception (errno);
00267 }
00268 }
00269
00270
00271 cdr.more_fragments (false);
00272
00273 #ifdef TAO_HAS_VALUETYPE_OUT_INDIRECTION
00274 cdr.reset_vt_indirect_maps ();
00275 #endif
00276 }
00277 catch (...) {
00278 #ifdef TAO_HAS_VALUETYPE_OUT_INDIRECTION
00279 cdr.reset_vt_indirect_maps ();
00280 #endif
00281 throw;
00282 }
00283 }
00284
00285 TAO_END_VERSIONED_NAMESPACE_DECL
00286