Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / interop-tests / CdrOutArg / tao / client_interceptor.cpp
blobd23af7e6cba1bb12464cb4b2917a0949942ba1df
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 ()
21 char *
22 Echo_Client_Request_Interceptor::name ()
24 return CORBA::string_dup (this->myname_);
27 void
28 Echo_Client_Request_Interceptor::destroy ()
32 void
33 Echo_Client_Request_Interceptor::send_poll (
34 PortableInterceptor::ClientRequestInfo_ptr)
38 void
39 Echo_Client_Request_Interceptor::send_request (
40 PortableInterceptor::ClientRequestInfo_ptr ri)
42 if (CORBA::is_nil (this->orb_.in ()))
44 int argc = 0;
45 ACE_TCHAR **argv = 0;
46 this->orb_ = CORBA::ORB_init (argc, argv,
47 this->orb_id_.in ());
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 ());
57 #if 0
58 ACE_DEBUG ((LM_DEBUG,
59 "%C.send_request "
60 "from \"%C\" on object: %C\n",
61 this->myname_,
62 operation.in (),
63 ior.in ()));
64 #endif /*if 0*/
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);
86 const char *buf2 =
87 reinterpret_cast<const char *> (sc2->context_data.get_buffer ());
89 if (ACE_OS::strcmp (buf2, request_msg) != 0)
91 ACE_ERROR ((LM_ERROR,
92 "ERROR: Expected request service context to be: %C.\n"
93 " Got: %C\n",
94 request_msg,
95 buf2));
100 void
101 Echo_Client_Request_Interceptor::receive_reply (
102 PortableInterceptor::ClientRequestInfo_ptr )
106 void
107 Echo_Client_Request_Interceptor::receive_other (
108 PortableInterceptor::ClientRequestInfo_ptr)
112 void
113 Echo_Client_Request_Interceptor::receive_exception (
114 PortableInterceptor::ClientRequestInfo_ptr )