1 #include "interceptors.h"
2 #include "tao/AnyTypeCode/AnyTypeCode_Adapter_Impl.h"
3 #include "tao/AnyTypeCode/DynamicC.h"
4 #include "tao/AnyTypeCode/TypeCode.h"
5 #include "ace/Log_Msg.h"
6 #include "ace/OS_NS_string.h"
8 const char *request_msg
= "The Echo_Request_Interceptor request message";
9 const char *reply_msg
= "The Echo_Request_Interceptor reply message";
10 CORBA::ULong
Echo_Client_Request_Interceptor::client_interceptor_check_
= 0;
11 CORBA::ULong
Echo_Server_Request_Interceptor::server_interceptor_check_
= 0;
13 Echo_Client_Request_Interceptor::Echo_Client_Request_Interceptor ()
14 : myname_ ("Echo_Client_Interceptor")
18 Echo_Client_Request_Interceptor::~Echo_Client_Request_Interceptor ()
23 Echo_Client_Request_Interceptor::name ()
25 return CORBA::string_dup (this->myname_
);
29 Echo_Client_Request_Interceptor::destroy ()
34 Echo_Client_Request_Interceptor::send_poll (
35 PortableInterceptor::ClientRequestInfo_ptr
42 Echo_Client_Request_Interceptor::send_request (
43 PortableInterceptor::ClientRequestInfo_ptr ri
)
45 client_interceptor_check_
++;
47 CORBA::String_var op
=
52 "Echo_Client_Request_Interceptor::send_request\n"));
55 "Echo_Client_Request_Interceptor::send_request from "
61 if (ACE_OS::strcmp (op
.in (), "normal") == 0)
63 Dynamic::ParameterList_var paramlist
=
67 CORBA::ULong i
= 0; // index -- explicitly used to avoid
68 // overloaded operator ambiguity.
69 paramlist
[i
].argument
>>= param
;
80 Echo_Client_Request_Interceptor::receive_other (
81 PortableInterceptor::ClientRequestInfo_ptr ri
)
83 client_interceptor_check_
++;
85 CORBA::String_var op
= ri
->operation ();
89 "Echo_Client_Request_Interceptor::receive_other "
96 Echo_Client_Request_Interceptor::receive_reply (
97 PortableInterceptor::ClientRequestInfo_ptr ri
)
99 client_interceptor_check_
++;
101 CORBA::String_var op
= ri
->operation ();
104 ACE_DEBUG ((LM_DEBUG
,
105 "Echo_Client_Request_Interceptor::receive_reply "
110 if (ACE_OS::strcmp (op
.in (), "normal") == 0)
112 Dynamic::ParameterList_var paramlist
=
116 CORBA::ULong i
= 0; // index -- explicitly used to avoid
117 // overloaded operator ambiguity.
118 paramlist
[i
].argument
>>= param
;
120 else if (ACE_OS::strcmp (op
.in (), "calculate") == 0)
122 Dynamic::ParameterList_var paramlist
=
125 CORBA::Long param1
, param2
, result
;
126 CORBA::ULong i
= 0; // index -- explicitly used to avoid
127 // overloaded operator ambiguity.
128 paramlist
[i
++].argument
>>= param1
;
129 paramlist
[i
].argument
>>= param2
;
131 CORBA::Any_var result_any
= ri
->result ();
133 (result_any
.in ()) >>= result
;
136 ACE_DEBUG ((LM_DEBUG
,
137 "The result of calculate is %d + %d = %d\n",
146 Echo_Client_Request_Interceptor::receive_exception (
147 PortableInterceptor::ClientRequestInfo_ptr ri
)
149 client_interceptor_check_
++;
151 CORBA::String_var op
= ri
->operation ();
153 CORBA::String_var exception_id
=
154 ri
->received_exception_id ();
156 ACE_DEBUG ((LM_DEBUG
,
157 "Echo_Client_Request_Interceptor::received_exception "
161 ACE_DEBUG ((LM_DEBUG
,
162 "Exception ID = %C\n",
163 exception_id
.in ()));
166 Echo_Server_Request_Interceptor::Echo_Server_Request_Interceptor ()
167 : myname_ ("Echo_Server_Interceptor")
171 Echo_Server_Request_Interceptor::~Echo_Server_Request_Interceptor ()
176 Echo_Server_Request_Interceptor::name ()
178 return CORBA::string_dup (this->myname_
);
182 Echo_Server_Request_Interceptor::destroy ()
187 Echo_Server_Request_Interceptor::receive_request_service_contexts (
188 PortableInterceptor::ServerRequestInfo_ptr
)
193 Echo_Server_Request_Interceptor::receive_request (
194 PortableInterceptor::ServerRequestInfo_ptr ri
)
196 ++server_interceptor_check_
;
198 CORBA::String_var op
= ri
->operation ();
200 PortableInterceptor::ObjectId_var test_oid
=
203 ACE_DEBUG ((LM_DEBUG
,
204 "Echo_Server_Request_Interceptor::receive_request from \"%C\"\n",
207 if (ACE_OS::strcmp (op
.in (), "normal") == 0)
209 Dynamic::ParameterList_var paramlist
=
213 CORBA::ULong i
= 0; // index -- explicitly used to avoid
214 // overloaded operator ambiguity.
215 paramlist
[i
].argument
>>= param
;
217 ACE_DEBUG ((LM_DEBUG
,
222 CORBA::String_var tmdi
=
223 ri
->target_most_derived_interface ();
225 ACE_DEBUG ((LM_DEBUG
,
226 "Target most derived interface: %C\n",
231 Echo_Server_Request_Interceptor::send_reply (
232 PortableInterceptor::ServerRequestInfo_ptr ri
)
234 ++server_interceptor_check_
;
236 CORBA::String_var op
= ri
->operation ();
238 ACE_DEBUG ((LM_DEBUG
,
239 "Echo_Server_Request_Interceptor::send_reply from \"%C\"\n",
242 if (ACE_OS::strcmp (op
.in (), "normal") == 0)
244 Dynamic::ParameterList_var paramlist
=
248 CORBA::ULong i
= 0; // index -- explicitly used to avoid
249 // overloaded operator ambiguity.
250 paramlist
[i
].argument
>>= param
;
251 ACE_DEBUG ((LM_DEBUG
,
256 if (ACE_OS::strcmp (op
.in (), "calculate") == 0)
258 Dynamic::ParameterList_var paramlist
=
261 CORBA::Long param1
, param2
, result
= 0;
262 CORBA::ULong i
= 0; // index -- explicitly used to avoid
263 // overloaded operator ambiguity.
264 paramlist
[i
++].argument
>>= param1
;
265 paramlist
[i
].argument
>>= param2
;
267 CORBA::Any_var result_any
= ri
->result ();
269 (result_any
.in ()) >>= result
;
271 ACE_DEBUG ((LM_DEBUG
,
272 "The result of calculate is %d + %d = %d\n",
280 Echo_Server_Request_Interceptor::send_exception (
281 PortableInterceptor::ServerRequestInfo_ptr ri
)
283 ++server_interceptor_check_
;
285 CORBA::String_var op
= ri
->operation ();
287 ACE_DEBUG ((LM_DEBUG
,
288 "Echo_Server_Request_Interceptor::send_exception "
294 ri
->sending_exception ();
296 CORBA::TypeCode_var type
= any
->type ();
298 const char *exception_id
= type
->id ();
300 ACE_DEBUG ((LM_DEBUG
,
301 "Exception ID = %C\n",
306 Echo_Server_Request_Interceptor::send_other (
307 PortableInterceptor::ServerRequestInfo_ptr
)
309 ++server_interceptor_check_
;