Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / tests / Portable_Interceptors / PICurrent / ClientRequestInterceptor.cpp
blobbdb22b875cee578402ee36b1fe8ff765510eb0f3
1 #include "ClientRequestInterceptor.h"
2 #include "tao/CORBA_String.h"
3 #include "ace/Log_Msg.h"
4 #include "ace/OS_NS_string.h"
6 ClientRequestInterceptor::ClientRequestInterceptor (
7 PortableInterceptor::SlotId id,
8 PortableInterceptor::Current_ptr pi_current)
9 : slot_id_ (id),
10 pi_current_ (PortableInterceptor::Current::_duplicate (pi_current))
14 char *
15 ClientRequestInterceptor::name ()
17 return CORBA::string_dup ("ClientRequestInterceptor");
20 void
21 ClientRequestInterceptor::destroy (void)
25 void
26 ClientRequestInterceptor::send_request (
27 PortableInterceptor::ClientRequestInfo_ptr ri)
29 CORBA::String_var op = ri->operation ();
31 if (ACE_OS::strcmp (op.in (), "invoke_me") != 0)
32 return; // Don't mess with PICurrent if not invoking test method.
34 try
36 // Retrieve data from the RSC (request scope current).
37 CORBA::Long number = 0;
39 CORBA::Any_var data =
40 ri->get_slot (this->slot_id_);
42 if (!(data.in () >>= number))
44 ACE_ERROR ((LM_ERROR,
45 "(%P|%t) ERROR: Unable to extract data from Any.\n"));
47 throw CORBA::INTERNAL ();
50 ACE_DEBUG ((LM_DEBUG,
51 "(%P|%t) Extracted <%d> from RSC slot %u\n",
52 number,
53 this->slot_id_));
55 CORBA::Any new_data;
56 CORBA::String_var s = CORBA::string_dup ("Et tu Brute?");
58 new_data <<= s.in ();
60 // Now reset the contents of our slot in the thread-scope
61 // current (TSC).
62 this->pi_current_->set_slot (this->slot_id_,
63 new_data);
65 // Now retrieve the data from the RSC again. It should not have
66 // changed!
67 CORBA::Long number2 = -1;
69 CORBA::Any_var data2 =
70 ri->get_slot (this->slot_id_);
72 if (!(data2.in () >>= number2)
73 || number != number2)
75 ACE_ERROR ((LM_ERROR,
76 "(%P|%t) ERROR: RSC was modified after "
77 "TSC was modified.\n"));
79 throw CORBA::INTERNAL ();
83 catch (const PortableInterceptor::InvalidSlot& ex)
85 ex._tao_print_exception ("Exception thrown in ""send_request()\n");
87 ACE_DEBUG ((LM_DEBUG,
88 "Invalid slot: %u\n",
89 this->slot_id_));
91 throw CORBA::INTERNAL ();
94 ACE_DEBUG ((LM_INFO,
95 "(%P|%t) Client side RSC/TSC semantics appear "
96 "to be correct.\n"));
99 void
100 ClientRequestInterceptor::send_poll (
101 PortableInterceptor::ClientRequestInfo_ptr)
105 void
106 ClientRequestInterceptor::receive_reply (
107 PortableInterceptor::ClientRequestInfo_ptr)
111 void
112 ClientRequestInterceptor::receive_exception (
113 PortableInterceptor::ClientRequestInfo_ptr)
117 void
118 ClientRequestInterceptor::receive_other (
119 PortableInterceptor::ClientRequestInfo_ptr)