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"
11 Echo_Client_Request_Interceptor::Echo_Client_Request_Interceptor (int& result
)
17 Echo_Client_Request_Interceptor::name ()
19 return CORBA::string_dup ("Echo_Client_Interceptor");
23 Echo_Client_Request_Interceptor::destroy ()
28 Echo_Client_Request_Interceptor::send_poll (PortableInterceptor::ClientRequestInfo_ptr
)
34 Echo_Client_Request_Interceptor::send_request (PortableInterceptor::ClientRequestInfo_ptr ri
)
36 bool catched_exception
= false;
39 PortableInterceptor::ReplyStatus rstatus
= ri
->reply_status ();
40 ACE_UNUSED_ARG (rstatus
);
42 catch (const ::CORBA::BAD_INV_ORDER
& ex
)
44 // BAD_INV_ORDER should be thrown with minor code 14
45 catched_exception
= (ex
.minor () == (CORBA::OMGVMCID
| 14));
48 if (!catched_exception
)
52 "(%P|%t) ERROR, no exception when getting reply status\n"));
55 CORBA::String_var op
= ri
->operation ();
58 "Echo_Client_Request_Interceptor::send_request from "
62 // For the "normal" operation, get the argument list.
63 if (std::strcmp (op
.in (), "normal") == 0)
65 Dynamic::ParameterList_var paramlist
= ri
->arguments ();
67 if (paramlist
->length () != 2)
71 "(%P|%t) All parameters not available\n"));
74 CORBA::ULong first
= 0, second
= 1; // If you dont understand
75 // why this is done, then
77 if (paramlist
[first
].mode
!= CORBA::PARAM_IN
||
78 paramlist
[second
].mode
!= CORBA::PARAM_OUT
)
81 "(%P|%t) ERROR in the extracted argument list\n"));
84 CORBA::Long param
= 0;
85 paramlist
[first
].argument
>>= param
;
91 "(%P|%t) ERROR in send_request while checking "
92 "the value of the extracted "
96 CORBA::TypeCode_var second_typecode
= paramlist
[second
].argument
.type ();
97 if (second_typecode
->kind () != CORBA::tk_null
)
100 ACE_ERROR ((LM_ERROR
,
101 "(%P|%t) ERROR in send_request while checking "
102 "the type of the extracted out"
109 Echo_Client_Request_Interceptor::receive_other (PortableInterceptor::ClientRequestInfo_ptr ri
)
111 CORBA::String_var op
= ri
->operation ();
113 ACE_DEBUG ((LM_DEBUG
,
114 "Echo_Client_Request_Interceptor::receive_other "
120 Echo_Client_Request_Interceptor::receive_reply (PortableInterceptor::ClientRequestInfo_ptr ri
)
122 CORBA::String_var op
= ri
->operation ();
124 ACE_DEBUG ((LM_DEBUG
,
125 "Echo_Client_Request_Interceptor::receive_reply "
129 // For the "normal" operation, get the argument list.
130 if (std::strcmp (op
.in (), "normal") == 0)
132 Dynamic::ParameterList_var paramlist
= ri
->arguments ();
134 if (paramlist
->length () != 2)
136 ACE_ERROR ((LM_ERROR
,
137 "(%P|%t) All parameters not available\n"));
140 CORBA::ULong first
= 0, second
= 1; // If you dont understand
141 // why this is done, then
143 if (paramlist
[first
].mode
!= CORBA::PARAM_IN
||
144 paramlist
[second
].mode
!= CORBA::PARAM_OUT
)
147 ACE_ERROR ((LM_ERROR
,
148 "(%P|%t) ERROR in the extracted argument list\n"));
151 CORBA::Long param
= 0;
152 paramlist
[first
].argument
>>= param
;
157 ACE_ERROR ((LM_ERROR
,
158 "(%P|%t) ERROR in send_request while checking "
159 "the value of the extracted "
165 paramlist
[second
].argument
>>= str
;
167 CORBA::String_var
transfer (str
);
169 if (std::strcmp (str
, "DO_NOT_INSULT_MY_INTELLIGENCE") != 0)
172 ACE_ERROR ((LM_ERROR
,
173 "(%P|%t) ERROR in send_request while checking "
174 "the value of the extracted "
179 if (std::strcmp (op
.in (), "calculate") == 0)
181 Dynamic::ParameterList_var paramlist
= ri
->arguments ();
183 CORBA::Long param1
, param2
, result
;
184 CORBA::ULong i
= 0; // index -- explicitly used to avoid
185 // overloaded operator ambiguity.
186 paramlist
[i
++].argument
>>= param1
;
187 paramlist
[i
].argument
>>= param2
;
189 CORBA::Any_var result_any
= ri
->result ();
191 (result_any
.in ()) >>= result
;
193 ACE_DEBUG ((LM_DEBUG
,
194 "The result of calculate() is %d + %d = %d\n",
200 if (std::strcmp (op
.in (), "_get_the_structure") == 0)
202 CORBA::Any_var a
= ri
->result ();
204 const Test_Interceptors::Visual::VarLenStruct
* v
= nullptr;
208 ACE_DEBUG ((LM_DEBUG
,
209 "The result of the_structure() is:\n"
218 Echo_Client_Request_Interceptor::receive_exception (
219 PortableInterceptor::ClientRequestInfo_ptr ri
)
221 CORBA::String_var op
= ri
->operation ();
223 ACE_DEBUG ((LM_DEBUG
,
224 "Echo_Client_Request_Interceptor::received_exception "
228 CORBA::String_var exception_id
= ri
->received_exception_id ();
230 ACE_DEBUG ((LM_DEBUG
,
231 "Exception ID = %C\n",
232 exception_id
.in ()));