Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / tests / POA / Generic_Servant / test_i.cpp
blobbc4a01965df5daac395d94d5a37b27c85e830abb
1 #include "test_i.h"
2 #include "ace/OS_NS_unistd.h"
3 #include "ace/OS_NS_string.h"
5 // Constructor
6 test_i::test_i (CORBA::ORB_ptr orb,
7 PortableServer::POA_ptr poa)
8 : orb_ (CORBA::ORB::_duplicate (orb)),
9 poa_ (PortableServer::POA::_duplicate (poa))
13 PortableServer::POA_ptr
14 test_i::_default_POA ()
16 return PortableServer::POA::_duplicate (this->poa_.in ());
19 void
20 test_i::method ()
24 void
25 test_i::oneway_method ()
29 void
30 test_i::sleep (CORBA::ULong timeout,
31 const char *method)
33 ACE_DEBUG ((LM_DEBUG,
34 "Thread %t starting %s with timeout %d\n",
35 method,
36 timeout));
38 ACE_OS::sleep (timeout);
40 ACE_DEBUG ((LM_DEBUG,
41 "Thread %t completes %s\n",
42 method));
45 void
46 test_i::timed_method (CORBA::ULong timeout)
48 this->sleep (timeout,
49 "test_i::timed_method");
52 void
53 test_i::timed_oneway_method (CORBA::ULong timeout)
55 this->sleep (timeout,
56 "test_i::timed_oneway_method");
59 void
60 test_i::shutdown ()
62 this->orb_->shutdown (false);
66 // This is the point of entry into this library.
67 extern "C" GENERIC_SERVANT_Export PortableServer::Servant create_test_i (CORBA::ORB_ptr orb,
68 PortableServer::POA_ptr poa);
70 PortableServer::Servant
71 create_test_i (CORBA::ORB_ptr orb,
72 PortableServer::POA_ptr poa)
74 PortableServer::Servant servant;
76 ACE_NEW_RETURN (servant,
77 test_i (orb,
78 poa),
79 0);
80 return servant;
84 extern "C" GENERIC_SERVANT_Export PortableServer::Servant supply_servant (const PortableServer::ObjectId &oid,
85 PortableServer::POA_ptr poa,
86 CORBA::ORB_ptr orb);
88 PortableServer::Servant
89 supply_servant (const PortableServer::ObjectId &oid,
90 PortableServer::POA_ptr poa,
91 CORBA::ORB_ptr orb)
93 PortableServer::Servant servant = 0;
95 // Convert ObjectId to string.
96 CORBA::String_var s = PortableServer::ObjectId_to_string (oid);
98 if (ACE_OS::strstr (s.in (), "test") != 0)
99 ACE_NEW_RETURN (servant,
100 test_i (orb,
101 poa),
103 return servant;
106 extern "C" GENERIC_SERVANT_Export void destroy_servant (const PortableServer::ObjectId &oid,
107 PortableServer::POA_ptr poa,
108 PortableServer::Servant servant);
110 void
111 destroy_servant (const PortableServer::ObjectId & /* oid */,
112 PortableServer::POA_ptr /* poa */,
113 PortableServer::Servant servant)
115 delete servant;