Merge pull request #2303 from jwillemsen/jwi-803
[ACE_TAO.git] / TAO / tests / TransportCurrent / IIOP / Current_Test_Impl.cpp
blob4f8461eb7e51b00a7ed5ec33cf5d558661ce3905
1 // -*- C++ -*-
2 #include "tao/TransportCurrent/TC_IIOPC.h"
3 #include "tao/TransportCurrent/TCC.h"
5 #include "Current_Test_Impl.h"
7 Current_Test_Impl::Current_Test_Impl (CORBA::ORB_ptr orb,
8 PortableServer::POA_ptr poa,
9 int do_collocated_calls)
10 : orb_ (CORBA::ORB::_duplicate (orb))
11 , poa_ (PortableServer::POA::_duplicate (poa))
12 , do_collocated_calls_ (do_collocated_calls)
16 Current_Test_Impl::~Current_Test_Impl ()
20 ::CORBA::Long
21 Current_Test_Impl::self_test ()
23 return 0;
26 void
27 Current_Test_Impl::test_transport_current ()
29 if (TAO_debug_level > 2) {
30 ACE_DEBUG ((LM_DEBUG,
31 ACE_TEXT ("(%P|%t) server - Testing access to IIOP Transport Current ...\n")));
34 CORBA::Object_var tcobject =
35 this->orb_->resolve_initial_references ("TAO::Transport::IIOP::Current");
37 TAO::Transport::IIOP::Current_var tc =
38 TAO::Transport::IIOP::Current::_narrow (tcobject.in ());
40 if (CORBA::is_nil (tc.in()))
42 ACE_ERROR ((LM_ERROR,
43 ACE_TEXT ("Unable to narrow down to TAO::Transport::IIOP::Current\n")));
44 throw CORBA::INTERNAL ();
47 CORBA::String_var rhost (tc->remote_host ());
48 CORBA::String_var lhost (tc->local_host ());
49 ACE_DEBUG ((LM_DEBUG,
50 ACE_TEXT ("(%P|%t) server - [%s:%d] -> [%s:%d]\n"),
51 rhost.in (), tc->remote_port (),
52 lhost.in (), tc->local_port ()));
54 if (TAO_debug_level > 2) {
55 ACE_DEBUG ((LM_DEBUG,
56 ACE_TEXT ("(%P|%t) server - Successfully accessed IIOP Transport Current\n")));
61 void
62 Current_Test_Impl::invoked_by_client ()
64 if (TAO_debug_level >= 1) {
65 ACE_DEBUG ((LM_DEBUG,
66 ACE_TEXT ("(%P|%t) server - Test method invoked by client.\n")));
69 this->test_transport_current ();
71 if (this->do_collocated_calls_)
73 CORBA::Object_var selfobject =
74 poa_->servant_to_reference (this);
76 Test::Transport::CurrentTest_var self =
77 Test::Transport::CurrentTest::_narrow (selfobject.in ());
79 if (TAO_debug_level >= 1) {
80 ACE_DEBUG ((LM_DEBUG,
81 ACE_TEXT ("(%P|%t) server - Making a collocated invocation to invoked_during_upcall().\n")));
83 self->invoked_during_upcall ();
85 else
87 if (TAO_debug_level >= 1)
89 ACE_DEBUG ((LM_DEBUG,
90 ACE_TEXT ("(%P|%t) server - skipping collocated calls\n")));
97 void
98 Current_Test_Impl::invoked_during_upcall ()
100 if (TAO_debug_level > 2) {
101 ACE_DEBUG ((LM_DEBUG,
102 ACE_TEXT ("(%P|%t) server - Test method invoked ")
103 ACE_TEXT ("by the server during upcall.\n")));
107 void
108 Current_Test_Impl::shutdown ()
110 if (TAO_debug_level > 2) {
111 ACE_DEBUG ((LM_DEBUG,
112 ACE_TEXT ("(%P|%t) server - shutting down.\n")));
115 this->orb_->shutdown (false);