1 #include "client_interceptor.h"
2 #include "tao/OctetSeqC.h"
4 #include "ace/Log_Msg.h"
5 #include "ace/OS_NS_string.h"
7 const IOP::ServiceId service_id
= 0xdeadbeef;
8 const char *request_msg
= "12345678";
10 Echo_Client_Request_Interceptor::
11 Echo_Client_Request_Interceptor (const char *id
)
12 : myname_ ("Echo_Client_Interceptor"),
13 orb_id_ (CORBA::string_dup (id
))
17 Echo_Client_Request_Interceptor::~Echo_Client_Request_Interceptor ()
22 Echo_Client_Request_Interceptor::name ()
24 return CORBA::string_dup (this->myname_
);
28 Echo_Client_Request_Interceptor::destroy ()
33 Echo_Client_Request_Interceptor::send_poll (
34 PortableInterceptor::ClientRequestInfo_ptr
)
39 Echo_Client_Request_Interceptor::send_request (
40 PortableInterceptor::ClientRequestInfo_ptr ri
)
42 if (CORBA::is_nil (this->orb_
.in ()))
46 this->orb_
= CORBA::ORB_init (argc
, argv
,
50 CORBA::String_var operation
= ri
->operation ();
52 CORBA::Object_var target
= ri
->target ();
54 CORBA::String_var ior
=
55 this->orb_
->object_to_string (target
.in ());
60 "from \"%C\" on object: %C\n",
67 // Populate target member of the ClientRequestInfo.
69 // Make the context to send the context to the target
70 IOP::ServiceContext sc
;
71 sc
.context_id
= ::service_id
;
73 CORBA::ULong string_len
= ACE_OS::strlen (request_msg
) + 1;
74 CORBA::Octet
*buf
= CORBA::OctetSeq::allocbuf (string_len
);
75 ACE_OS::strcpy (reinterpret_cast<char *> (buf
), request_msg
);
77 sc
.context_data
.replace (string_len
, string_len
, buf
, 1);
79 // Add this context to the service context list.
80 ri
->add_request_service_context (sc
, 0);
82 // Check that the request service context can be retrieved.
83 IOP::ServiceContext_var sc2
=
84 ri
->get_request_service_context (::service_id
);
87 reinterpret_cast<const char *> (sc2
->context_data
.get_buffer ());
89 if (ACE_OS::strcmp (buf2
, request_msg
) != 0)
92 "ERROR: Expected request service context to be: %C.\n"
101 Echo_Client_Request_Interceptor::receive_reply (
102 PortableInterceptor::ClientRequestInfo_ptr
)
107 Echo_Client_Request_Interceptor::receive_other (
108 PortableInterceptor::ClientRequestInfo_ptr
)
113 Echo_Client_Request_Interceptor::receive_exception (
114 PortableInterceptor::ClientRequestInfo_ptr
)