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"
9 #include "ace/OS_NS_string.h"
11 Echo_Server_Request_Interceptor::Echo_Server_Request_Interceptor (void)
12 : myname_ ("Echo_Server_Interceptor")
16 Echo_Server_Request_Interceptor::~Echo_Server_Request_Interceptor ()
21 Echo_Server_Request_Interceptor::name (void)
23 return CORBA::string_dup (this->myname_
);
27 Echo_Server_Request_Interceptor::destroy (void)
32 Echo_Server_Request_Interceptor::receive_request_service_contexts (
33 PortableInterceptor::ServerRequestInfo_ptr
)
38 Echo_Server_Request_Interceptor::receive_request (
39 PortableInterceptor::ServerRequestInfo_ptr ri
)
41 bool catched_exception
= false;
44 PortableInterceptor::ReplyStatus rstatus
= ri
->reply_status ();
45 ACE_UNUSED_ARG (rstatus
);
47 catch (const ::CORBA::BAD_INV_ORDER
&)
49 catched_exception
= true;
52 if (!catched_exception
)
55 "(%P|%t) ERROR, no exception when getting reply status\n"));
58 CORBA::String_var op
= ri
->operation ();
61 "Echo_Server_Request_Interceptor::receive_request from \"%C\"\n",
64 if (ACE_OS::strcmp (op
.in (), "normal") == 0)
66 Dynamic::ParameterList_var paramlist
=
70 CORBA::ULong i
= 0; // index -- explicitly used to avoid
71 // overloaded operator ambiguity.
72 paramlist
[i
].argument
>>= param
;
79 CORBA::TypeCode_var second_typecode
= paramlist
[i
].argument
.type ();
80 if (second_typecode
->kind () != CORBA::tk_null
)
83 "(%P|%t) ERROR in receive_request while checking "
84 "the type of the extracted out"
89 CORBA::String_var tmdi
=
90 ri
->target_most_derived_interface ();
93 "Target most derived interface: %C\n",
98 Echo_Server_Request_Interceptor::send_reply (
99 PortableInterceptor::ServerRequestInfo_ptr ri
)
102 CORBA::String_var op
= ri
->operation ();
104 ACE_DEBUG ((LM_DEBUG
,
105 "Echo_Server_Request_Interceptor::send_reply from \"%C\"\n",
108 if (ACE_OS::strcmp (op
.in (), "normal") == 0)
110 Dynamic::ParameterList_var paramlist
=
114 CORBA::ULong i
= 0; // index -- explicitly used to avoid
115 // overloaded operator ambiguity.
116 paramlist
[i
].argument
>>= param
;
117 ACE_DEBUG ((LM_DEBUG
,
122 if (ACE_OS::strcmp (op
.in (), "calculate") == 0)
124 Dynamic::ParameterList_var paramlist
=
127 CORBA::Long param1
, param2
, result
= 0;
128 CORBA::ULong i
= 0; // index -- explicitly used to avoid
129 // overloaded operator ambiguity.
130 paramlist
[i
++].argument
>>= param1
;
131 paramlist
[i
].argument
>>= param2
;
133 CORBA::Any_var result_any
= ri
->result ();
135 (result_any
.in ()) >>= result
;
137 ACE_DEBUG ((LM_DEBUG
,
138 "The result of calculate is %d + %d = %d\n",
146 Echo_Server_Request_Interceptor::send_exception (
147 PortableInterceptor::ServerRequestInfo_ptr ri
)
150 CORBA::String_var op
= ri
->operation ();
152 ACE_DEBUG ((LM_DEBUG
,
153 "Echo_Server_Request_Interceptor::send_exception "
159 ri
->sending_exception ();
161 CORBA::TypeCode_var type
= any
->type ();
163 const char *exception_id
= type
->id ();
165 ACE_DEBUG ((LM_DEBUG
,
166 "Exception ID = %C\n",
171 Echo_Server_Request_Interceptor::send_other (
172 PortableInterceptor::ServerRequestInfo_ptr
)