1 #include "client_interceptor.h"
4 #include "tao/AnyTypeCode/DynamicC.h"
5 #include "tao/AnyTypeCode/TypeCode.h"
6 #include "tao/AnyTypeCode/AnyTypeCode_Adapter_Impl.h"
8 #include "ace/Log_Msg.h"
9 #include "ace/OS_NS_string.h"
11 Echo_Client_Request_Interceptor::Echo_Client_Request_Interceptor (void)
12 : myname_ ("Echo_Client_Interceptor")
16 Echo_Client_Request_Interceptor::~Echo_Client_Request_Interceptor ()
21 Echo_Client_Request_Interceptor::name (void)
23 return CORBA::string_dup (this->myname_
);
27 Echo_Client_Request_Interceptor::destroy (void)
32 Echo_Client_Request_Interceptor::send_poll (
33 PortableInterceptor::ClientRequestInfo_ptr
)
39 Echo_Client_Request_Interceptor::send_request (
40 PortableInterceptor::ClientRequestInfo_ptr ri
)
42 bool catched_exception
= false;
45 PortableInterceptor::ReplyStatus rstatus
= ri
->reply_status ();
46 ACE_UNUSED_ARG (rstatus
);
48 catch (const ::CORBA::BAD_INV_ORDER
&)
50 catched_exception
= true;
53 if (!catched_exception
)
56 "(%P|%t) ERROR, no exception when getting reply status\n"));
59 CORBA::String_var op
= ri
->operation ();
62 "Echo_Client_Request_Interceptor::send_request from "
66 // For the "normal" operation, get the argument list.
67 if (ACE_OS::strcmp (op
.in (),
70 Dynamic::ParameterList_var paramlist
=
73 if (paramlist
->length () != 2)
76 "(%P|%t) All parameters not available\n"));
80 CORBA::ULong first
= 0, second
= 1; // If you dont understand
81 // why this is done, then
83 if (paramlist
[first
].mode
!= CORBA::PARAM_IN
||
84 paramlist
[second
].mode
!= CORBA::PARAM_OUT
)
87 "(%P|%t) ERROR in the extracted argument list\n"));
90 CORBA::Long param
= 0;
91 paramlist
[first
].argument
>>= param
;
96 "(%P|%t) ERROR in send_request while checking "
97 "the value of the extracted "
101 CORBA::TypeCode_var second_typecode
= paramlist
[second
].argument
.type ();
102 if (second_typecode
->kind () != CORBA::tk_null
)
104 ACE_ERROR ((LM_ERROR
,
105 "(%P|%t) ERROR in send_request while checking "
106 "the type of the extracted out"
113 Echo_Client_Request_Interceptor::receive_other (
114 PortableInterceptor::ClientRequestInfo_ptr ri
)
117 CORBA::String_var op
= ri
->operation ();
119 ACE_DEBUG ((LM_DEBUG
,
120 "Echo_Client_Request_Interceptor::receive_other "
126 Echo_Client_Request_Interceptor::receive_reply (
127 PortableInterceptor::ClientRequestInfo_ptr ri
)
129 CORBA::String_var op
= ri
->operation ();
131 ACE_DEBUG ((LM_DEBUG
,
132 "Echo_Client_Request_Interceptor::receive_reply "
136 // For the "normal" operation, get the argument list.
137 if (ACE_OS::strcmp (op
.in (),
140 Dynamic::ParameterList_var paramlist
=
143 if (paramlist
->length () != 2)
145 ACE_ERROR ((LM_ERROR
,
146 "(%P|%t) All parameters not available\n"));
150 CORBA::ULong first
= 0, second
= 1; // If you dont understand
151 // why this is done, then
153 if (paramlist
[first
].mode
!= CORBA::PARAM_IN
||
154 paramlist
[second
].mode
!= CORBA::PARAM_OUT
)
156 ACE_ERROR ((LM_ERROR
,
157 "(%P|%t) ERROR in the extracted argument list\n"));
160 CORBA::Long param
= 0;
161 paramlist
[first
].argument
>>= param
;
165 ACE_ERROR ((LM_ERROR
,
166 "(%P|%t) ERROR in send_request while checking "
167 "the value of the extracted "
173 paramlist
[second
].argument
>>= str
;
175 CORBA::String_var
transfer (str
);
177 if (ACE_OS::strcmp (str
,
178 "DO_NOT_INSULT_MY_INTELLIGENCE") != 0)
180 ACE_ERROR ((LM_ERROR
,
181 "(%P|%t) ERROR in send_request while checking "
182 "the value of the extracted "
187 if (ACE_OS::strcmp (op
.in (), "calculate") == 0)
189 Dynamic::ParameterList_var paramlist
=
192 CORBA::Long param1
, param2
, result
;
193 CORBA::ULong i
= 0; // index -- explicitly used to avoid
194 // overloaded operator ambiguity.
195 paramlist
[i
++].argument
>>= param1
;
196 paramlist
[i
].argument
>>= param2
;
198 CORBA::Any_var result_any
= ri
->result ();
200 (result_any
.in ()) >>= result
;
202 ACE_DEBUG ((LM_DEBUG
,
203 "The result of calculate() is %d + %d = %d\n",
209 if (ACE_OS::strcmp (op
.in (), "_get_the_structure") == 0)
211 CORBA::Any_var a
= ri
->result ();
213 const Test_Interceptors::Visual::VarLenStruct
* v
= 0;
217 ACE_DEBUG ((LM_DEBUG
,
218 "The result of the_structure() is:\n"
227 Echo_Client_Request_Interceptor::receive_exception (
228 PortableInterceptor::ClientRequestInfo_ptr ri
)
231 CORBA::String_var op
= ri
->operation ();
233 ACE_DEBUG ((LM_DEBUG
,
234 "Echo_Client_Request_Interceptor::received_exception "
239 CORBA::String_var exception_id
=
240 ri
->received_exception_id ();
242 ACE_DEBUG ((LM_DEBUG
,
243 "Exception ID = %C\n",
244 exception_id
.in ()));