4 test_i::test_i (PortableInterceptor::Current_ptr current
,
5 PortableInterceptor::SlotId id
,
7 : current_ (PortableInterceptor::Current::_duplicate (current
)),
9 orb_ (CORBA::ORB::_duplicate (orb
))
13 test_i::~test_i (void)
18 test_i::invoke_me (void)
21 "Test method invoked.\n"));
23 // @note "TSC" is "thread scope current"
24 // "RSC" is "request scope current"
26 // ----------------------------------------------------
28 // Verify that the following RSC->TSC->RSC copying scenario works:
30 // 1. ServerRequestInterceptor::receive_request_service_contexts()
31 // a. ServerRequestInfo::set_slot()
32 // b. RSC->TSC shallow copy
33 // 2. servant implementation invokes method on another server
34 // a. TSC->RSC shallow copy
35 // b. ClientRequestInterceptor::send_request()
36 // i. ClientRequestInfo::get_slot()
38 // By this point all of step 1 has occurred. Step 2 will now
40 PICurrentTest::test_var my_ref
= this->_this ();
42 // ----------------------------------------------------
44 CORBA::Any_var retrieved_any
;
48 // Retrieve data placed into RSC PICurrent by the
49 // receive_request_service_contexts() interception point, and
50 // then copied into the TSC current.
52 this->current_
->get_slot (this->slot_id_
);
54 catch (const PortableInterceptor::InvalidSlot
& ex
)
56 ex
._tao_print_exception (
57 "Exception thrown in ""test_i::invoke_me() when calling ""Current::get_slot\n");
63 throw CORBA::INTERNAL ();
65 catch (const CORBA::Exception
& ex
)
67 ex
._tao_print_exception ("Unexpected exception\n");
70 CORBA::Long retrieved
;
71 if (retrieved_any
.in() >>= retrieved
)
73 "(%P|%t) Retrieved number <%d> from TSC.\n",
78 "(%P|%t) Problem extracting data from "
79 "CORBA::Any retrieved from TSC.\n"));
81 throw CORBA::INTERNAL ();
83 // ----------------------------------------------------
85 // Note that the invocation must occur through the object
86 // reference to force the client request interceptor
87 // (ClientRequestInterceptor2) to be invoked. This assumes that
88 // DIRECT collocation (and possibly THRU_POA collocation) is
90 my_ref
->invoke_you ();
92 // ----------------------------------------------------
94 // Insert some data into the TSC PICurrent object.
95 const char str
[] = "Drink milk!";
103 this->current_
->set_slot (this->slot_id_
,
106 catch (const PortableInterceptor::InvalidSlot
& ex
)
108 ex
._tao_print_exception (
109 "Exception thrown in ""test_i::invoke_me() when calling ""Current::set_slot\n");
111 ACE_DEBUG ((LM_DEBUG
,
112 "Invalid slot: %u\n",
115 throw CORBA::INTERNAL ();
118 ACE_DEBUG ((LM_DEBUG
,
119 "(%P|%t) String \"%C\" inserted into TSC.\n",
124 test_i::invoke_you (void)
126 // Nothing to be tested here. This method is here just so that we
127 // have a different method
131 test_i::invoke_we (void)
133 // Insert some data into the TSC PICurrent object.
134 const char str
[] = "We drink milk!";
142 this->current_
->set_slot (this->slot_id_
,
145 catch (const PortableInterceptor::InvalidSlot
& ex
)
147 ex
._tao_print_exception (
148 "Exception thrown in ""test_i::invoke_me() when calling ""Current::set_slot\n");
150 ACE_DEBUG ((LM_DEBUG
,
151 "Invalid slot: %u\n",
154 throw CORBA::INTERNAL ();
157 ACE_DEBUG ((LM_DEBUG
,
158 "(%P|%t) String \"%C\" inserted into TSC.\n",
163 test_i::shutdown (void)
165 ACE_DEBUG ((LM_DEBUG
,
166 "(%P|%t) Server is shutting down.\n"));
168 this->orb_
->shutdown (0);