Revert "Minor modernization of DynamicAny code"
[ACE_TAO.git] / TAO / tao / DynamicInterface / DII_Invocation.cpp
blob120a81d8b91285b105d6798d882610cec15555f5
1 #include "tao/AnyTypeCode/TypeCode.h"
2 #include "tao/AnyTypeCode/DynamicC.h"
4 #include "tao/DynamicInterface/DII_Invocation.h"
5 #include "tao/DynamicInterface/Unknown_User_Exception.h"
6 #include "tao/DynamicInterface/DII_Arguments.h"
7 #include "tao/DynamicInterface/ExceptionList.h"
8 #include "tao/DynamicInterface/Request.h"
9 #include "tao/DynamicInterface/DII_Reply_Dispatcher.h"
11 #include "tao/operation_details.h"
12 #include "tao/Invocation_Utils.h"
13 #include "tao/debug.h"
14 #include "tao/AnyTypeCode/Any_Unknown_IDL_Type.h"
15 #include "tao/Profile_Transport_Resolver.h"
16 #include "tao/ORB_Constants.h"
17 #include "tao/SystemException.h"
19 #include "ace/OS_NS_string.h"
21 #if TAO_HAS_INTERCEPTORS == 1
22 # include "tao/PI/RequestInfo_Util.h"
23 #endif
25 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
27 namespace TAO
29 DII_Invocation::DII_Invocation (CORBA::Object_ptr otarget,
30 Profile_Transport_Resolver &resolver,
31 TAO_Operation_Details &detail,
32 CORBA::ExceptionList *excp,
33 CORBA::Request_ptr req,
34 bool response_expected)
35 : Synch_Twoway_Invocation (otarget,
36 resolver,
37 detail,
38 response_expected)
39 , excp_list_ (excp)
40 , host_ (req)
44 #if TAO_HAS_INTERCEPTORS == 1
45 Dynamic::ParameterList *
46 DII_Invocation::arguments ()
48 Dynamic::ParameterList_var safe_parameter_list;
50 TAO::Argument ** const args = this->details_.args ();
52 if (this->details_.args_num () > 1)
54 // Take the second argument since the first is a return value.
55 TAO::NVList_Argument * const tmp_arg =
56 dynamic_cast <TAO::NVList_Argument*> (args[1]);
58 if (tmp_arg)
60 // Generate the argument list on demand.
61 Dynamic::ParameterList * const parameter_list =
62 TAO_RequestInfo_Util::make_parameter_list ();
64 safe_parameter_list = parameter_list;
66 tmp_arg->interceptor_paramlist (parameter_list);
70 return safe_parameter_list._retn ();
72 #endif /* TAO_HAS_INTERCEPTORS == 1 */
74 Invocation_Status
75 DII_Invocation::handle_user_exception (TAO_InputCDR &cdr)
77 Reply_Guard mon (this, TAO_INVOKE_FAILURE);
79 if (TAO_debug_level > 3)
81 TAOLIB_DEBUG ((LM_DEBUG,
82 "TAO (%P|%t) - DII_Invocation::"
83 "handle_user_exception\n"));
86 // Match the exception interface repository id with the
87 // exception in the exception list.
88 // This is important to decode the exception.
89 CORBA::String_var buf;
91 TAO_InputCDR tmp_stream (cdr,
92 cdr.start ()->length (),
93 0);
95 // Pull the exception ID out of the marshaling buffer.
96 if (tmp_stream.read_string (buf.inout ()) == 0)
98 throw ::CORBA::MARSHAL (TAO::VMCID, CORBA::COMPLETED_YES);
101 for (CORBA::ULong i = 0;
102 this->excp_list_ != 0 && i < this->excp_list_->count ();
103 i++)
105 CORBA::TypeCode_var tc = this->excp_list_->item (i);
107 const char *xid = tc->id ();
109 if (ACE_OS::strcmp (buf.in (), xid) != 0)
111 continue;
114 CORBA::Any any;
115 TAO::Unknown_IDL_Type *unk = 0;
116 ACE_NEW_RETURN (unk,
117 TAO::Unknown_IDL_Type (
118 tc.in (),
121 TAO_INVOKE_FAILURE);
123 any.replace (unk);
125 mon.set_status (TAO_INVOKE_USER_EXCEPTION);
127 throw ::CORBA::UnknownUserException (any);
130 // If we couldn't find the right exception, report it as
131 // CORBA::UNKNOWN.
133 // But first, save the user exception in case we
134 // are being used in a TAO gateway.
135 this->host_->raw_user_exception (cdr);
137 mon.set_status (TAO_INVOKE_USER_EXCEPTION);
139 // @@ It would seem that if the remote exception is a
140 // UserException we can assume that the request was
141 // completed.
142 throw ::CORBA::UNKNOWN (TAO::VMCID, CORBA::COMPLETED_YES);
146 //***************************************************************************
147 DII_Deferred_Invocation::DII_Deferred_Invocation (
148 CORBA::Object_ptr otarget,
149 Profile_Transport_Resolver &resolver,
150 TAO_Operation_Details &detail,
151 TAO_DII_Deferred_Reply_Dispatcher *rd,
152 bool response_expected)
153 : Asynch_Remote_Invocation (otarget,
154 resolver,
155 detail,
157 response_expected)
159 this->safe_rd_->transport (this->resolver_.transport ());
162 #if TAO_HAS_INTERCEPTORS == 1
163 //@NOTE: Need to figure a way to share this code
164 Dynamic::ParameterList *
165 DII_Deferred_Invocation::arguments ()
167 Dynamic::ParameterList_var safe_parameter_list;
169 TAO::Argument ** const args = this->details_.args ();
171 if (this->details_.args_num () > 1)
173 // Take the second argument since the first is a return value.
174 TAO::NVList_Argument * const tmp_arg =
175 dynamic_cast <TAO::NVList_Argument*> (args[1]);
177 if (tmp_arg)
179 // Generate the argument list on demand.
180 Dynamic::ParameterList * const parameter_list =
181 TAO_RequestInfo_Util::make_parameter_list ();
183 safe_parameter_list = parameter_list;
185 tmp_arg->interceptor_paramlist (parameter_list);
189 return safe_parameter_list._retn ();
191 #endif /* TAO_HAS_INTERCEPTORS == 1*/
194 TAO_END_VERSIONED_NAMESPACE_DECL