Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / tests / TransportCurrent / IIOP / Current_Test_Impl.cpp
blob9d3e9ab646e7f68d5ec4876d52726636c04cff13
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 (void)
20 ::CORBA::Long
21 Current_Test_Impl::self_test (void)
23 return 0;
26 void
27 Current_Test_Impl::test_transport_current (void)
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")));
62 void
63 Current_Test_Impl::invoked_by_client (void)
65 if (TAO_debug_level >= 1) {
66 ACE_DEBUG ((LM_DEBUG,
67 ACE_TEXT ("(%P|%t) server - Test method invoked by client.\n")));
70 this->test_transport_current ();
72 if (this->do_collocated_calls_)
74 CORBA::Object_var selfobject =
75 poa_->servant_to_reference (this);
77 Test::Transport::CurrentTest_var self =
78 Test::Transport::CurrentTest::_narrow (selfobject.in ());
80 if (TAO_debug_level >= 1) {
81 ACE_DEBUG ((LM_DEBUG,
82 ACE_TEXT ("(%P|%t) server - Making a collocated invocation to invoked_during_upcall().\n")));
84 self->invoked_during_upcall ();
86 else
88 if (TAO_debug_level >= 1)
90 ACE_DEBUG ((LM_DEBUG,
91 ACE_TEXT ("(%P|%t) server - skipping collocated calls\n")));
98 void
99 Current_Test_Impl::invoked_during_upcall (void)
101 if (TAO_debug_level > 2) {
102 ACE_DEBUG ((LM_DEBUG,
103 ACE_TEXT ("(%P|%t) server - Test method invoked ")
104 ACE_TEXT ("by the server during upcall.\n")));
108 void
109 Current_Test_Impl::shutdown (void)
111 if (TAO_debug_level > 2) {
112 ACE_DEBUG ((LM_DEBUG,
113 ACE_TEXT ("(%P|%t) server - shutting down.\n")));
116 this->orb_->shutdown (0);