1 #include "tao/AnyTypeCode/TypeCode.h"
2 #include "tao/AnyTypeCode/AnyTypeCode_Adapter_Impl.h"
3 #include "tao/AnyTypeCode/DynamicC.h"
5 #include "server_interceptor.h"
8 #include "ace/Log_Msg.h"
11 Echo_Server_Request_Interceptor::Echo_Server_Request_Interceptor (int& result
)
17 Echo_Server_Request_Interceptor::name ()
19 return CORBA::string_dup ("Echo_Server_Interceptor");
23 Echo_Server_Request_Interceptor::destroy ()
28 Echo_Server_Request_Interceptor::receive_request_service_contexts (
29 PortableInterceptor::ServerRequestInfo_ptr ri
)
31 bool catched_exception
= false;
34 CORBA::String_var tmdi
= ri
->target_most_derived_interface ();
36 catch (const ::CORBA::BAD_INV_ORDER
& ex
)
38 // BAD_INV_ORDER should be thrown with minor code 14
39 catched_exception
= (ex
.minor () == (CORBA::OMGVMCID
| 14));
42 if (!catched_exception
)
46 "(%P|%t) ERROR, no exception when calling target_most_derived_interface from receive_request_service_contexts\n"));
49 catched_exception
= false;
52 CORBA::Boolean
const tmdi
= ri
->target_is_a ("FOO");
55 catch (const ::CORBA::BAD_INV_ORDER
& ex
)
57 // BAD_INV_ORDER should be thrown with minor code 14
58 catched_exception
= (ex
.minor () == (CORBA::OMGVMCID
| 14));
61 if (!catched_exception
)
65 "(%P|%t) ERROR, no exception when calling target_is_a from receive_request_service_contexts\n"));
68 catched_exception
= false;
71 PortableInterceptor::ReplyStatus
const tmdi
= ri
->reply_status ();
74 catch (const ::CORBA::BAD_INV_ORDER
& ex
)
76 // BAD_INV_ORDER should be thrown with minor code 14
77 catched_exception
= (ex
.minor () == (CORBA::OMGVMCID
| 14));
80 if (!catched_exception
)
84 "(%P|%t) ERROR, no exception when calling reply_status from receive_request_service_contexts\n"));
87 catched_exception
= false;
90 Dynamic::ParameterList_var paramlist
= ri
->arguments ();
92 catch (const ::CORBA::BAD_INV_ORDER
& ex
)
94 // BAD_INV_ORDER should be thrown with minor code 14
95 catched_exception
= (ex
.minor () == (CORBA::OMGVMCID
| 14));
98 if (!catched_exception
)
101 ACE_ERROR ((LM_ERROR
,
102 "(%P|%t) ERROR, no exception when calling arguments from receive_request_service_contexts\n"));
107 Echo_Server_Request_Interceptor::receive_request (
108 PortableInterceptor::ServerRequestInfo_ptr ri
)
110 bool catched_exception
= false;
113 PortableInterceptor::ReplyStatus rstatus
= ri
->reply_status ();
114 ACE_UNUSED_ARG (rstatus
);
116 catch (const ::CORBA::BAD_INV_ORDER
& ex
)
118 // BAD_INV_ORDER should be thrown with minor code 14
119 catched_exception
= (ex
.minor () == (CORBA::OMGVMCID
| 14));
122 if (!catched_exception
)
125 ACE_ERROR ((LM_ERROR
,
126 "(%P|%t) ERROR, no exception when getting reply status\n"));
129 CORBA::String_var op
= ri
->operation ();
131 ACE_DEBUG ((LM_DEBUG
,
132 "Echo_Server_Request_Interceptor::receive_request from \"%C\"\n",
135 CORBA::Boolean targetisa
= ri
->target_is_a ("FOO");
139 ACE_ERROR ((LM_ERROR
,
140 "(%P|%t) ERROR in receive_request while checking "
141 "target_is_a, it is not a FOO\n"));
143 targetisa
= ri
->target_is_a ("IDL:Test_Interceptors/Visual:1.0");
147 ACE_ERROR ((LM_ERROR
,
148 "(%P|%t) ERROR in receive_request while checking "
149 "target_is_a, it should be IDL:Test_Interceptors/Visual:1.0\n"));
152 if (std::strcmp (op
.in (), "normal") == 0)
154 Dynamic::ParameterList_var paramlist
= ri
->arguments ();
157 CORBA::ULong i
= 0; // index -- explicitly used to avoid
158 // overloaded operator ambiguity.
159 paramlist
[i
].argument
>>= param
;
161 ACE_DEBUG ((LM_DEBUG
,
166 CORBA::TypeCode_var second_typecode
= paramlist
[i
].argument
.type ();
167 if (second_typecode
->kind () != CORBA::tk_null
)
170 ACE_ERROR ((LM_ERROR
,
171 "(%P|%t) ERROR in receive_request while checking "
172 "the type of the extracted out"
177 CORBA::String_var tmdi
= ri
->target_most_derived_interface ();
179 ACE_DEBUG ((LM_DEBUG
,
180 "Target most derived interface: %C\n",
183 if (std::strcmp (tmdi
.in (), "IDL:Test_Interceptors/Visual:1.0") != 0)
186 ACE_ERROR ((LM_ERROR
,
187 "(%P|%t) ERROR in receive_request while checking "
188 "target_most_derived_interface\n"));
191 catched_exception
= false;
194 PortableInterceptor::ReplyStatus
const tmdi
= ri
->reply_status ();
195 ACE_UNUSED_ARG(tmdi
);
197 catch (const ::CORBA::BAD_INV_ORDER
& ex
)
199 // BAD_INV_ORDER should be thrown with minor code 14
200 catched_exception
= (ex
.minor () == (CORBA::OMGVMCID
| 14));
203 if (!catched_exception
)
206 ACE_ERROR ((LM_ERROR
,
207 "(%P|%t) ERROR, no exception when calling reply_status from receive_request\n"));
212 Echo_Server_Request_Interceptor::send_reply (PortableInterceptor::ServerRequestInfo_ptr ri
)
214 CORBA::String_var op
= ri
->operation ();
216 ACE_DEBUG ((LM_DEBUG
,
217 "Echo_Server_Request_Interceptor::send_reply from \"%C\"\n",
220 if (std::strcmp (op
.in (), "normal") == 0)
222 Dynamic::ParameterList_var paramlist
= ri
->arguments ();
225 CORBA::ULong i
= 0; // index -- explicitly used to avoid
226 // overloaded operator ambiguity.
227 paramlist
[i
].argument
>>= param
;
228 ACE_DEBUG ((LM_DEBUG
,
233 if (std::strcmp (op
.in (), "calculate") == 0)
235 Dynamic::ParameterList_var paramlist
= ri
->arguments ();
237 CORBA::Long param1
, param2
, result
= 0;
238 CORBA::ULong i
= 0; // index -- explicitly used to avoid
239 // overloaded operator ambiguity.
240 paramlist
[i
++].argument
>>= param1
;
241 paramlist
[i
].argument
>>= param2
;
243 CORBA::Any_var result_any
= ri
->result ();
245 (result_any
.in ()) >>= result
;
247 ACE_DEBUG ((LM_DEBUG
,
248 "The result of calculate is %d + %d = %d\n",
256 Echo_Server_Request_Interceptor::send_exception (
257 PortableInterceptor::ServerRequestInfo_ptr ri
)
259 CORBA::String_var op
= ri
->operation ();
261 ACE_DEBUG ((LM_DEBUG
,
262 "Echo_Server_Request_Interceptor::send_exception "
266 CORBA::Any_var any
= ri
->sending_exception ();
268 CORBA::TypeCode_var type
= any
->type ();
270 CORBA::String_var exception_id
= type
->id ();
272 ACE_DEBUG ((LM_DEBUG
,
273 "Exception ID = %C\n",
274 exception_id
.in ()));
278 Echo_Server_Request_Interceptor::send_other (
279 PortableInterceptor::ServerRequestInfo_ptr
)