Revert "Minor modernization of DynamicAny code"
[ACE_TAO.git] / TAO / tests / TransportCurrent / lib / Client_Request_Interceptor.cpp
blob3ef844d0e4129a8a23f264fcd35a612cb1ddb261
1 // -*- C++ -*-
2 #include "ace/Log_Msg.h"
4 #include "Current_TestC.h"
5 #include "Client_Request_Interceptor.h"
6 #include "Client_ORBInitializer.h"
8 namespace Test
10 Client_Request_Interceptor::Client_Request_Interceptor (const char *orb_id,
11 TEST test)
12 : orb_id_ (CORBA::string_dup (orb_id))
13 , request_count_ (0)
14 , requestID_ (1)
15 , test_ (test)
19 CORBA::Long
20 Client_Request_Interceptor::interceptions ()
22 return this->request_count_;
25 char *
26 Client_Request_Interceptor::name ()
28 return CORBA::string_dup ("Client_Request_Interceptor");
31 void
32 Client_Request_Interceptor::test_transport_current (const ACE_TCHAR* amethod)
34 ACE_DEBUG ((LM_DEBUG,
35 ACE_TEXT ("CRI (%P|%t) Test accessing Transport Current from %s\n"),
36 amethod));
38 ++this->request_count_;
40 int tmp = 0;
41 ACE_TCHAR **argv = 0;
42 CORBA::ORB_var orb = CORBA::ORB_init (tmp,
43 argv,
44 orb_id_.in ());
46 // Call the test function, which will throw an exception on
47 // failure
48 (*this->test_) (orb.in ());
50 ACE_DEBUG ((LM_DEBUG,
51 ACE_TEXT ("CRI (%P|%t) Successfully tested Transport Current from %s\n"),
52 amethod));
55 void
56 Client_Request_Interceptor::destroy ()
60 void
61 Client_Request_Interceptor::send_request (PortableInterceptor::ClientRequestInfo_ptr ri)
63 // Test TC
64 test_transport_current (ACE_TEXT ("send_request"));
66 CORBA::Boolean const response_expected =
67 ri->response_expected ();
69 // Oneway?
70 if (response_expected)
71 ACE_DEBUG ((LM_DEBUG, ACE_TEXT("CRI (%P|%t) Sending a two-way\n")));
72 else
73 ACE_DEBUG ((LM_DEBUG, ACE_TEXT("CRI (%P|%t) Sending a one-way\n")));
75 // Make the context to send the context to the target
76 IOP::ServiceContext sc;
77 sc.context_id = Test::Transport::CurrentTest::ContextTag;
79 // How long can a number really get?
80 char temp[32];
82 ACE_GUARD (TAO_SYNCH_MUTEX, monitor, this->lock_);
84 ACE_OS::sprintf (temp, "%ld", this->requestID_);
85 ++this->requestID_;
88 CORBA::ULong string_len = ACE_OS::strlen (temp) + 1;
89 CORBA::Octet *buf = CORBA::OctetSeq::allocbuf (string_len);
90 ACE_OS::strcpy (reinterpret_cast <char *> (buf), temp);
92 sc.context_data.replace (string_len, string_len, buf, 1);
94 // Add this context to the service context list.
95 ri->add_request_service_context (sc, 0);
98 void
99 Client_Request_Interceptor::send_poll (PortableInterceptor::ClientRequestInfo_ptr)
101 test_transport_current (ACE_TEXT ("send_poll"));
104 void
105 Client_Request_Interceptor::receive_reply (PortableInterceptor::ClientRequestInfo_ptr)
107 test_transport_current (ACE_TEXT ("receive_reply"));
110 void
111 Client_Request_Interceptor::receive_exception (PortableInterceptor::ClientRequestInfo_ptr)
113 test_transport_current (ACE_TEXT ("receive_exception"));
116 void
117 Client_Request_Interceptor::receive_other (PortableInterceptor::ClientRequestInfo_ptr)
119 test_transport_current (ACE_TEXT ("receive_other"));