2 * @file Client_Interceptor.cpp
4 * @author Carlos O'Ryan <coryan@atdesk.com>
7 #include "Client_Interceptor.h"
8 #include "Shared_Interceptor.h"
9 #include "tao/OctetSeqC.h"
11 #include "ace/Log_Msg.h"
12 #include "ace/OS_NS_string.h"
14 unsigned long Echo_Client_Request_Interceptor::request_count
= 0;
15 unsigned long Echo_Client_Request_Interceptor::reply_count
= 0;
16 unsigned long Echo_Client_Request_Interceptor::other_count
= 0;
17 unsigned long Echo_Client_Request_Interceptor::exception_count
= 0;
19 Echo_Client_Request_Interceptor::
20 Echo_Client_Request_Interceptor ()
25 Echo_Client_Request_Interceptor::name ()
27 return CORBA::string_dup ("Echo_Client_Interceptor");
31 Echo_Client_Request_Interceptor::destroy ()
36 Echo_Client_Request_Interceptor::send_poll (
37 PortableInterceptor::ClientRequestInfo_ptr
)
40 "ERROR, unexpected interception point called send_poll()\n"));
41 throw CORBA::BAD_PARAM ();
45 Echo_Client_Request_Interceptor::send_request (
46 PortableInterceptor::ClientRequestInfo_ptr ri
)
48 IOP::ServiceContext sc
;
49 sc
.context_id
= ::service_id
;
51 CORBA::Octet
*buf
= CORBA::OctetSeq::allocbuf(magic_cookie_len
);
52 ACE_OS::memcpy(buf
, magic_cookie
, magic_cookie_len
);
53 sc
.context_data
.replace (magic_cookie_len
, magic_cookie_len
, buf
, 1);
55 // Add this context to the service context list.
56 ri
->add_request_service_context (sc
,
59 // Check that the request service context can be retrieved.
60 IOP::ServiceContext_var rc
=
61 ri
->get_request_service_context (::service_id
);
63 if (rc
->context_data
.length() != magic_cookie_len
65 magic_cookie
, rc
->context_data
.get_buffer(),
66 magic_cookie_len
) != 0
69 throw CORBA::BAD_PARAM();
72 Echo_Client_Request_Interceptor::request_count
++;
76 Echo_Client_Request_Interceptor::receive_reply (
77 PortableInterceptor::ClientRequestInfo_ptr ri
)
79 // Check that the request service context can be retrieved.
80 IOP::ServiceContext_var rc
=
81 ri
->get_request_service_context (::service_id
);
83 if (rc
->context_data
.length() != magic_cookie_len
85 magic_cookie
, rc
->context_data
.get_buffer(),
86 magic_cookie_len
) != 0
89 throw CORBA::BAD_PARAM();
92 ++Echo_Client_Request_Interceptor::reply_count
;
96 Echo_Client_Request_Interceptor::receive_other (
97 PortableInterceptor::ClientRequestInfo_ptr ri
)
99 // Check that the request service context can be retrieved.
100 IOP::ServiceContext_var rc
=
101 ri
->get_request_service_context (::service_id
);
103 if (rc
->context_data
.length() != magic_cookie_len
105 magic_cookie
, rc
->context_data
.get_buffer(),
106 magic_cookie_len
) != 0
109 throw CORBA::BAD_PARAM ();
112 Echo_Client_Request_Interceptor::other_count
++;
116 Echo_Client_Request_Interceptor::receive_exception (
117 PortableInterceptor::ClientRequestInfo_ptr
)
119 Echo_Client_Request_Interceptor::exception_count
++;